Oops -- Lib/Test should be Lib/test, of course!
[python/dscho.git] / Doc / libmath.tex
blob1cc6b202dbcca4a5d4be5bc99a5f36cd626b1496
1 \section{Built-in Module \module{math}}
2 \label{module-math}
4 \bimodindex{math}
5 This module is always available.
6 It provides access to the mathematical functions defined by the \C{}
7 standard.
8 They are:
10 \begin{funcdesc}{acos}{x}
11 Return the arc cosine of \var{x}.
12 \end{funcdesc}
14 \begin{funcdesc}{asin}{x}
15 Return the arc sine of \var{x}.
16 \end{funcdesc}
18 \begin{funcdesc}{atan}{x}
19 Return the arc tangent of \var{x}.
20 \end{funcdesc}
22 \begin{funcdesc}{atan2}{x, y}
23 Return \code{atan(\var{x} / \var{y})}.
24 \end{funcdesc}
26 \begin{funcdesc}{ceil}{x}
27 Return the ceiling of \var{x} as a real.
28 \end{funcdesc}
30 \begin{funcdesc}{cos}{x}
31 Return the cosine of \var{x}.
32 \end{funcdesc}
34 \begin{funcdesc}{cosh}{x}
35 Return the hyperbolic cosine of \var{x}.
36 \end{funcdesc}
38 \begin{funcdesc}{exp}{x}
39 Return \code{e**\var{x}}.
40 \end{funcdesc}
42 \begin{funcdesc}{fabs}{x}
43 Return the absolute value of the real \var{x}.
44 \end{funcdesc}
46 \begin{funcdesc}{floor}{x}
47 Return the floor of \var{x} as a real.
48 \end{funcdesc}
50 \begin{funcdesc}{fmod}{x, y}
51 Return \code{\var{x} \%\ \var{y}}.
52 \end{funcdesc}
54 \begin{funcdesc}{frexp}{x}
55 Return the matissa and exponent for \var{x}. The mantissa is
56 positive.
57 \end{funcdesc}
59 \begin{funcdesc}{hypot}{x, y}
60 Return the Euclidean distance, \code{sqrt(\var{x}*\var{x} + \var{y}*\var{y})}.
61 \end{funcdesc}
63 \begin{funcdesc}{ldexp}{x, i}
64 Return \code{\var{x} * (2**\var{i})}.
65 \end{funcdesc}
67 \begin{funcdesc}{log}{x}
68 Return the natural logarithm of \var{x}.
69 \end{funcdesc}
71 \begin{funcdesc}{log10}{x}
72 Return the base-10 logarithm of \var{x}.
73 \end{funcdesc}
75 \begin{funcdesc}{modf}{x}
76 Return the fractional and integer parts of \var{x}. Both results
77 carry the sign of \var{x}. The integer part is returned as a real.
78 \end{funcdesc}
80 \begin{funcdesc}{pow}{x, y}
81 Return \code{\var{x}**\var{y}}.
82 \end{funcdesc}
84 \begin{funcdesc}{sin}{x}
85 Return the sine of \var{x}.
86 \end{funcdesc}
88 \begin{funcdesc}{sinh}{x}
89 Return the hyperbolic sine of \var{x}.
90 \end{funcdesc}
92 \begin{funcdesc}{sqrt}{x}
93 Return the square root of \var{x}.
94 \end{funcdesc}
96 \begin{funcdesc}{tan}{x}
97 Return the tangent of \var{x}.
98 \end{funcdesc}
100 \begin{funcdesc}{tanh}{x}
101 Return the hyperbolic tangent of \var{x}.
102 \end{funcdesc}
104 Note that \function{frexp()} and \function{modf()} have a different
105 call/return pattern than their \C{} equivalents: they take a single
106 argument and return a pair of values, rather than returning their
107 second return value through an `output parameter' (there is no such
108 thing in Python).
110 The module also defines two mathematical constants:
112 \begin{datadesc}{pi}
113 The mathematical constant \emph{pi}.
114 \end{datadesc}
116 \begin{datadesc}{e}
117 The mathematical constant \emph{e}.
118 \end{datadesc}
120 \begin{seealso}
121 \seemodule{cmath}{Complex number versions of many of these functions.}
122 \end{seealso}