summaryrefslogtreecommitdiffstats
path: root/Doc/libmath.tex
blob: 935b9403c10454d6c91499bc8e14d0412d00d56b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
\section{Built-in Module \sectcode{math}}
\label{module-math}

\bimodindex{math}
\renewcommand{\indexsubitem}{(in module math)}
This module is always available.
It provides access to the mathematical functions defined by the C
standard.
They are:
\iftexi
\begin{funcdesc}{acos}{x}
\funcline{asin}{x}
\funcline{atan}{x}
\funcline{atan2}{x, y}
\funcline{ceil}{x}
\funcline{cos}{x}
\funcline{cosh}{x}
\funcline{exp}{x}
\funcline{fabs}{x}
\funcline{floor}{x}
\funcline{fmod}{x, y}
\funcline{frexp}{x}
\funcline{hypot}{x, y}
\funcline{ldexp}{x, y}
\funcline{log}{x}
\funcline{log10}{x}
\funcline{modf}{x}
\funcline{pow}{x, y}
\funcline{sin}{x}
\funcline{sinh}{x}
\funcline{sqrt}{x}
\funcline{tan}{x}
\funcline{tanh}{x}
\end{funcdesc}
\else
\code{acos(\varvars{x})},
\code{asin(\varvars{x})},
\code{atan(\varvars{x})},
\code{atan2(\varvars{x\, y})},
\code{ceil(\varvars{x})},
\code{cos(\varvars{x})},
\code{cosh(\varvars{x})},
\code{exp(\varvars{x})},
\code{fabs(\varvars{x})},
\code{floor(\varvars{x})},
\code{fmod(\varvars{x\, y})},
\code{frexp(\varvars{x})},
\code{hypot(\varvars{x\, y})},
\code{ldexp(\varvars{x\, y})},
\code{log(\varvars{x})},
\code{log10(\varvars{x})},
\code{modf(\varvars{x})},
\code{pow(\varvars{x\, y})},
\code{sin(\varvars{x})},
\code{sinh(\varvars{x})},
\code{sqrt(\varvars{x})},
\code{tan(\varvars{x})},
\code{tanh(\varvars{x})}.
\fi

Note that \code{frexp} and \code{modf} have a different call/return
pattern than their C equivalents: they take a single argument and
return a pair of values, rather than returning their second return
value through an `output parameter' (there is no such thing in Python).

The module also defines two mathematical constants:
\iftexi
\begin{datadesc}{pi}
\dataline{e}
\end{datadesc}
\else
\code{pi} and \code{e}.
\fi

\begin{seealso}
\seealso{cmath}{versions of these functions that can handle complex numbers}
\end{seealso}