Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame^] | 1 | \section{\module{cmath} --- |
| 2 | Mathematical functions for complex numbers.} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 3 | \declaremodule{builtin}{cmath} |
Guido van Rossum | 14a8024 | 1997-07-17 16:13:45 +0000 | [diff] [blame] | 4 | |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 5 | |
| 6 | \modulesynopsis{Mathematical functions for complex numbers.} |
| 7 | |
Guido van Rossum | 14a8024 | 1997-07-17 16:13:45 +0000 | [diff] [blame] | 8 | This module is always available. |
| 9 | It provides access to mathematical functions for complex numbers. |
| 10 | The functions are: |
Fred Drake | 1b914b3 | 1997-09-30 20:14:50 +0000 | [diff] [blame] | 11 | |
Guido van Rossum | 14a8024 | 1997-07-17 16:13:45 +0000 | [diff] [blame] | 12 | \begin{funcdesc}{acos}{x} |
Fred Drake | 1b914b3 | 1997-09-30 20:14:50 +0000 | [diff] [blame] | 13 | Return the arc cosine of \var{x}. |
Guido van Rossum | 14a8024 | 1997-07-17 16:13:45 +0000 | [diff] [blame] | 14 | \end{funcdesc} |
Fred Drake | 1b914b3 | 1997-09-30 20:14:50 +0000 | [diff] [blame] | 15 | |
| 16 | \begin{funcdesc}{acosh}{x} |
| 17 | Return the hyperbolic arc cosine of \var{x}. |
| 18 | \end{funcdesc} |
| 19 | |
| 20 | \begin{funcdesc}{asin}{x} |
| 21 | Return the arc sine of \var{x}. |
| 22 | \end{funcdesc} |
| 23 | |
| 24 | \begin{funcdesc}{asinh}{x} |
| 25 | Return the hyperbolic arc sine of \var{x}. |
| 26 | \end{funcdesc} |
| 27 | |
| 28 | \begin{funcdesc}{atan}{x} |
| 29 | Return the arc tangent of \var{x}. |
| 30 | \end{funcdesc} |
| 31 | |
| 32 | \begin{funcdesc}{atanh}{x} |
| 33 | Return the hyperbolic arc tangent of \var{x}. |
| 34 | \end{funcdesc} |
| 35 | |
| 36 | \begin{funcdesc}{cos}{x} |
| 37 | Return the cosine of \var{x}. |
| 38 | \end{funcdesc} |
| 39 | |
| 40 | \begin{funcdesc}{cosh}{x} |
| 41 | Return the hyperbolic cosine of \var{x}. |
| 42 | \end{funcdesc} |
| 43 | |
| 44 | \begin{funcdesc}{exp}{x} |
Guido van Rossum | c57aff2 | 1998-02-11 22:33:28 +0000 | [diff] [blame] | 45 | Return the exponential value \code{e**\var{x}}. |
Fred Drake | 1b914b3 | 1997-09-30 20:14:50 +0000 | [diff] [blame] | 46 | \end{funcdesc} |
| 47 | |
| 48 | \begin{funcdesc}{log}{x} |
| 49 | Return the natural logarithm of \var{x}. |
| 50 | \end{funcdesc} |
| 51 | |
| 52 | \begin{funcdesc}{log10}{x} |
| 53 | Return the base-10 logarithm of \var{x}. |
| 54 | \end{funcdesc} |
| 55 | |
| 56 | \begin{funcdesc}{sin}{x} |
| 57 | Return the sine of \var{x}. |
| 58 | \end{funcdesc} |
| 59 | |
| 60 | \begin{funcdesc}{sinh}{x} |
| 61 | Return the hyperbolic sine of \var{x}. |
| 62 | \end{funcdesc} |
| 63 | |
| 64 | \begin{funcdesc}{sqrt}{x} |
| 65 | Return the square root of \var{x}. |
| 66 | \end{funcdesc} |
| 67 | |
| 68 | \begin{funcdesc}{tan}{x} |
| 69 | Return the tangent of \var{x}. |
| 70 | \end{funcdesc} |
| 71 | |
| 72 | \begin{funcdesc}{tanh}{x} |
| 73 | Return the hyperbolic tangent of \var{x}. |
| 74 | \end{funcdesc} |
Guido van Rossum | 14a8024 | 1997-07-17 16:13:45 +0000 | [diff] [blame] | 75 | |
| 76 | The module also defines two mathematical constants: |
Fred Drake | 1b914b3 | 1997-09-30 20:14:50 +0000 | [diff] [blame] | 77 | |
Guido van Rossum | 14a8024 | 1997-07-17 16:13:45 +0000 | [diff] [blame] | 78 | \begin{datadesc}{pi} |
Fred Drake | 1b914b3 | 1997-09-30 20:14:50 +0000 | [diff] [blame] | 79 | The mathematical constant \emph{pi}, as a real. |
Guido van Rossum | 14a8024 | 1997-07-17 16:13:45 +0000 | [diff] [blame] | 80 | \end{datadesc} |
Fred Drake | 1b914b3 | 1997-09-30 20:14:50 +0000 | [diff] [blame] | 81 | |
| 82 | \begin{datadesc}{e} |
| 83 | The mathematical constant \emph{e}, as a real. |
| 84 | \end{datadesc} |
Guido van Rossum | 14a8024 | 1997-07-17 16:13:45 +0000 | [diff] [blame] | 85 | |
| 86 | Note that the selection of functions is similar, but not identical, to |
Fred Drake | aa5dba0 | 1998-01-09 21:30:03 +0000 | [diff] [blame] | 87 | that in module \code{math}\refbimodindex{math}. The reason for having |
| 88 | two modules is, that some users aren't interested in complex numbers, |
| 89 | and 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. |
| 91 | Also note that the functions defined in \code{cmath} always return a |
| 92 | complex 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). |