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