blob: 6c6a90f9c0307757cee454c1902a0bc8ad622e2b [file] [log] [blame]
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00001\section{Built-in Module \sectcode{math}}
2
3\bimodindex{math}
4\renewcommand{\indexsubitem}{(in module math)}
5This module is always available.
6It provides access to the mathematical functions defined by the C
7standard.
8They are:
9\iftexi
10\begin{funcdesc}{acos}{x}
11\funcline{asin}{x}
12\funcline{atan}{x}
13\funcline{atan2}{x, y}
14\funcline{ceil}{x}
15\funcline{cos}{x}
16\funcline{cosh}{x}
17\funcline{exp}{x}
18\funcline{fabs}{x}
19\funcline{floor}{x}
20\funcline{fmod}{x, y}
21\funcline{frexp}{x}
Guido van Rossum411a8bd1994-10-20 22:00:28 +000022\funcline{hypot}{x, y}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000023\funcline{ldexp}{x, y}
24\funcline{log}{x}
25\funcline{log10}{x}
26\funcline{modf}{x}
27\funcline{pow}{x, y}
28\funcline{sin}{x}
29\funcline{sinh}{x}
30\funcline{sqrt}{x}
31\funcline{tan}{x}
32\funcline{tanh}{x}
33\end{funcdesc}
34\else
35\code{acos(\varvars{x})},
36\code{asin(\varvars{x})},
37\code{atan(\varvars{x})},
38\code{atan2(\varvars{x\, y})},
39\code{ceil(\varvars{x})},
40\code{cos(\varvars{x})},
41\code{cosh(\varvars{x})},
42\code{exp(\varvars{x})},
43\code{fabs(\varvars{x})},
44\code{floor(\varvars{x})},
45\code{fmod(\varvars{x\, y})},
46\code{frexp(\varvars{x})},
Guido van Rossum31cce971995-01-04 19:17:34 +000047\code{hypot(\varvars{x\, y})},
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000048\code{ldexp(\varvars{x\, y})},
49\code{log(\varvars{x})},
50\code{log10(\varvars{x})},
51\code{modf(\varvars{x})},
52\code{pow(\varvars{x\, y})},
53\code{sin(\varvars{x})},
54\code{sinh(\varvars{x})},
55\code{sqrt(\varvars{x})},
56\code{tan(\varvars{x})},
57\code{tanh(\varvars{x})}.
58\fi
59
60Note that \code{frexp} and \code{modf} have a different call/return
61pattern than their C equivalents: they take a single argument and
62return a pair of values, rather than returning their second return
63value through an `output parameter' (there is no such thing in Python).
64
Guido van Rossum31cce971995-01-04 19:17:34 +000065The \code{hypot} function, which is not standard C, is not available
66on all platforms.
67
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000068The module also defines two mathematical constants:
69\iftexi
70\begin{datadesc}{pi}
71\dataline{e}
72\end{datadesc}
73\else
74\code{pi} and \code{e}.
75\fi