blob: 53379672eaf234fdfa68fa695598c772563649b9 [file] [log] [blame]
Fred Drake3a0351c1998-04-04 07:23:21 +00001\section{Built-in Module \module{cmath}}
Fred Drakeb91e9341998-07-23 17:59:49 +00002\declaremodule{builtin}{cmath}
Guido van Rossum14a80241997-07-17 16:13:45 +00003
Fred Drakeb91e9341998-07-23 17:59:49 +00004
5\modulesynopsis{Mathematical functions for complex numbers.}
6
Guido van Rossum14a80241997-07-17 16:13:45 +00007This module is always available.
8It provides access to mathematical functions for complex numbers.
9The functions are:
Fred Drake1b914b31997-09-30 20:14:50 +000010
Guido van Rossum14a80241997-07-17 16:13:45 +000011\begin{funcdesc}{acos}{x}
Fred Drake1b914b31997-09-30 20:14:50 +000012Return the arc cosine of \var{x}.
Guido van Rossum14a80241997-07-17 16:13:45 +000013\end{funcdesc}
Fred Drake1b914b31997-09-30 20:14:50 +000014
15\begin{funcdesc}{acosh}{x}
16Return the hyperbolic arc cosine of \var{x}.
17\end{funcdesc}
18
19\begin{funcdesc}{asin}{x}
20Return the arc sine of \var{x}.
21\end{funcdesc}
22
23\begin{funcdesc}{asinh}{x}
24Return the hyperbolic arc sine of \var{x}.
25\end{funcdesc}
26
27\begin{funcdesc}{atan}{x}
28Return the arc tangent of \var{x}.
29\end{funcdesc}
30
31\begin{funcdesc}{atanh}{x}
32Return the hyperbolic arc tangent of \var{x}.
33\end{funcdesc}
34
35\begin{funcdesc}{cos}{x}
36Return the cosine of \var{x}.
37\end{funcdesc}
38
39\begin{funcdesc}{cosh}{x}
40Return the hyperbolic cosine of \var{x}.
41\end{funcdesc}
42
43\begin{funcdesc}{exp}{x}
Guido van Rossumc57aff21998-02-11 22:33:28 +000044Return the exponential value \code{e**\var{x}}.
Fred Drake1b914b31997-09-30 20:14:50 +000045\end{funcdesc}
46
47\begin{funcdesc}{log}{x}
48Return the natural logarithm of \var{x}.
49\end{funcdesc}
50
51\begin{funcdesc}{log10}{x}
52Return the base-10 logarithm of \var{x}.
53\end{funcdesc}
54
55\begin{funcdesc}{sin}{x}
56Return the sine of \var{x}.
57\end{funcdesc}
58
59\begin{funcdesc}{sinh}{x}
60Return the hyperbolic sine of \var{x}.
61\end{funcdesc}
62
63\begin{funcdesc}{sqrt}{x}
64Return the square root of \var{x}.
65\end{funcdesc}
66
67\begin{funcdesc}{tan}{x}
68Return the tangent of \var{x}.
69\end{funcdesc}
70
71\begin{funcdesc}{tanh}{x}
72Return the hyperbolic tangent of \var{x}.
73\end{funcdesc}
Guido van Rossum14a80241997-07-17 16:13:45 +000074
75The module also defines two mathematical constants:
Fred Drake1b914b31997-09-30 20:14:50 +000076
Guido van Rossum14a80241997-07-17 16:13:45 +000077\begin{datadesc}{pi}
Fred Drake1b914b31997-09-30 20:14:50 +000078The mathematical constant \emph{pi}, as a real.
Guido van Rossum14a80241997-07-17 16:13:45 +000079\end{datadesc}
Fred Drake1b914b31997-09-30 20:14:50 +000080
81\begin{datadesc}{e}
82The mathematical constant \emph{e}, as a real.
83\end{datadesc}
Guido van Rossum14a80241997-07-17 16:13:45 +000084
85Note that the selection of functions is similar, but not identical, to
Fred Drakeaa5dba01998-01-09 21:30:03 +000086that in module \code{math}\refbimodindex{math}. The reason for having
87two modules is, that some users aren't interested in complex numbers,
88and perhaps don't even know what they are. They would rather have
89\code{math.sqrt(-1)} raise an exception than return a complex number.
90Also note that the functions defined in \code{cmath} always return a
91complex number, even if the answer can be expressed as a real number
92(in which case the complex number has an imaginary part of zero).