Mercurial > cpython-lru_cache-weakref
annotate Doc/lib/libmath.tex @ 13163:a09e8635534d legacy-trunk
Don't try to guess the name of a .def file -- if one is supplied, use it,
otherwise just generate an '/export:' option.
| author | Greg Ward <gward@python.net> |
|---|---|
| date | Thu, 29 Jun 2000 23:09:20 +0000 |
| parents | 8dca55867998 |
| children | 03aa26819ac2 |
| rev | line source |
|---|---|
| 8918 | 1 \section{\module{math} --- |
| 10646 | 2 Mathematical functions} |
| 3 | |
|
8716
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
4 \declaremodule{builtin}{math} |
|
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
5 \modulesynopsis{Mathematical functions (\function{sin()} etc.).} |
|
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
6 |
| 10646 | 7 This module is always available. It provides access to the |
|
12223
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
10646
diff
changeset
|
8 mathematical functions defined by the C standard. |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
10646
diff
changeset
|
9 |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
10646
diff
changeset
|
10 These functions cannot be used with complex numbers; use the functions |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
10646
diff
changeset
|
11 of the same name from the \refmodule{cmath} module if you require |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
10646
diff
changeset
|
12 support for complex numbers. The distinction between functions which |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
10646
diff
changeset
|
13 support complex numbers and those which don't is made since most users |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
10646
diff
changeset
|
14 do not want to learn quite as much mathematics as required to |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
10646
diff
changeset
|
15 understand complex numbers. Receiving an exception instead of a |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
10646
diff
changeset
|
16 complex result allows earlier detection of the unexpected complex |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
10646
diff
changeset
|
17 number used as a parameter, so that the programmer can determine how |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
10646
diff
changeset
|
18 and why it was generated in the first place. |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
10646
diff
changeset
|
19 |
|
e82e82b3b9ad
Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents:
10646
diff
changeset
|
20 The following functions provided by this module: |
| 6363 | 21 |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 \begin{funcdesc}{acos}{x} |
| 6363 | 23 Return the arc cosine of \var{x}. |
| 24 \end{funcdesc} | |
| 25 | |
| 26 \begin{funcdesc}{asin}{x} | |
| 27 Return the arc sine of \var{x}. | |
| 28 \end{funcdesc} | |
| 29 | |
| 30 \begin{funcdesc}{atan}{x} | |
| 31 Return the arc tangent of \var{x}. | |
| 32 \end{funcdesc} | |
| 33 | |
|
9607
8483953a9248
Rename the parameters of atan2(), based on comments from Guido & Peter
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
34 \begin{funcdesc}{atan2}{y, x} |
|
8483953a9248
Rename the parameters of atan2(), based on comments from Guido & Peter
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
35 Return \code{atan(\var{y} / \var{x})}. |
| 6363 | 36 \end{funcdesc} |
| 37 | |
| 38 \begin{funcdesc}{ceil}{x} | |
|
7157
a6fa9f3cad13
Added descriptions for log() and log10().
Fred Drake <fdrake@acm.org>
parents:
7048
diff
changeset
|
39 Return the ceiling of \var{x} as a real. |
| 6363 | 40 \end{funcdesc} |
| 41 | |
| 42 \begin{funcdesc}{cos}{x} | |
| 43 Return the cosine of \var{x}. | |
| 44 \end{funcdesc} | |
| 45 | |
| 46 \begin{funcdesc}{cosh}{x} | |
| 47 Return the hyperbolic cosine of \var{x}. | |
| 48 \end{funcdesc} | |
| 49 | |
| 50 \begin{funcdesc}{exp}{x} | |
|
6647
a7ea74a27993
Get rid of math mode in some places.
Guido van Rossum <guido@python.org>
parents:
6485
diff
changeset
|
51 Return \code{e**\var{x}}. |
| 6363 | 52 \end{funcdesc} |
| 53 | |
| 54 \begin{funcdesc}{fabs}{x} | |
| 55 Return the absolute value of the real \var{x}. | |
| 56 \end{funcdesc} | |
| 57 | |
| 58 \begin{funcdesc}{floor}{x} | |
|
7157
a6fa9f3cad13
Added descriptions for log() and log10().
Fred Drake <fdrake@acm.org>
parents:
7048
diff
changeset
|
59 Return the floor of \var{x} as a real. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 \end{funcdesc} |
| 6363 | 61 |
| 62 \begin{funcdesc}{fmod}{x, y} | |
|
7048
3eca5f37501a
Typographical nits: Always set parameter names in \var{} in the running text.
Fred Drake <fdrake@acm.org>
parents:
6647
diff
changeset
|
63 Return \code{\var{x} \%\ \var{y}}. |
| 6363 | 64 \end{funcdesc} |
| 65 | |
| 66 \begin{funcdesc}{frexp}{x} | |
|
12714
8dca55867998
New description for math.frexp() -- poor description noted by
Fred Drake <fdrake@acm.org>
parents:
12669
diff
changeset
|
67 Convert a floating-point number to fractional and integral |
|
8dca55867998
New description for math.frexp() -- poor description noted by
Fred Drake <fdrake@acm.org>
parents:
12669
diff
changeset
|
68 components. If \var{x} is zero, returns \code{(0.0, 0)}, otherwise |
|
8dca55867998
New description for math.frexp() -- poor description noted by
Fred Drake <fdrake@acm.org>
parents:
12669
diff
changeset
|
69 returns \code{(\var{frac}, \var{exp})} such that \code{\var{frac} * |
|
8dca55867998
New description for math.frexp() -- poor description noted by
Fred Drake <fdrake@acm.org>
parents:
12669
diff
changeset
|
70 2**\var{exp}} will equal \var{x}. \var{exp} will be an integer, and |
|
8dca55867998
New description for math.frexp() -- poor description noted by
Fred Drake <fdrake@acm.org>
parents:
12669
diff
changeset
|
71 the absolute value of \var{frac} will be in the range [0.5, 1.0) |
|
8dca55867998
New description for math.frexp() -- poor description noted by
Fred Drake <fdrake@acm.org>
parents:
12669
diff
changeset
|
72 (\var{frac} will share the sign of \var{x}). |
| 6363 | 73 \end{funcdesc} |
| 74 | |
| 75 \begin{funcdesc}{hypot}{x, y} | |
|
7048
3eca5f37501a
Typographical nits: Always set parameter names in \var{} in the running text.
Fred Drake <fdrake@acm.org>
parents:
6647
diff
changeset
|
76 Return the Euclidean distance, \code{sqrt(\var{x}*\var{x} + \var{y}*\var{y})}. |
| 6363 | 77 \end{funcdesc} |
| 78 | |
| 79 \begin{funcdesc}{ldexp}{x, i} | |
|
6647
a7ea74a27993
Get rid of math mode in some places.
Guido van Rossum <guido@python.org>
parents:
6485
diff
changeset
|
80 Return \code{\var{x} * (2**\var{i})}. |
| 6363 | 81 \end{funcdesc} |
| 82 | |
|
7157
a6fa9f3cad13
Added descriptions for log() and log10().
Fred Drake <fdrake@acm.org>
parents:
7048
diff
changeset
|
83 \begin{funcdesc}{log}{x} |
|
a6fa9f3cad13
Added descriptions for log() and log10().
Fred Drake <fdrake@acm.org>
parents:
7048
diff
changeset
|
84 Return the natural logarithm of \var{x}. |
|
a6fa9f3cad13
Added descriptions for log() and log10().
Fred Drake <fdrake@acm.org>
parents:
7048
diff
changeset
|
85 \end{funcdesc} |
|
a6fa9f3cad13
Added descriptions for log() and log10().
Fred Drake <fdrake@acm.org>
parents:
7048
diff
changeset
|
86 |
|
a6fa9f3cad13
Added descriptions for log() and log10().
Fred Drake <fdrake@acm.org>
parents:
7048
diff
changeset
|
87 \begin{funcdesc}{log10}{x} |
|
a6fa9f3cad13
Added descriptions for log() and log10().
Fred Drake <fdrake@acm.org>
parents:
7048
diff
changeset
|
88 Return the base-10 logarithm of \var{x}. |
|
a6fa9f3cad13
Added descriptions for log() and log10().
Fred Drake <fdrake@acm.org>
parents:
7048
diff
changeset
|
89 \end{funcdesc} |
|
a6fa9f3cad13
Added descriptions for log() and log10().
Fred Drake <fdrake@acm.org>
parents:
7048
diff
changeset
|
90 |
| 6363 | 91 \begin{funcdesc}{modf}{x} |
| 92 Return the fractional and integer parts of \var{x}. Both results | |
|
7157
a6fa9f3cad13
Added descriptions for log() and log10().
Fred Drake <fdrake@acm.org>
parents:
7048
diff
changeset
|
93 carry the sign of \var{x}. The integer part is returned as a real. |
| 6363 | 94 \end{funcdesc} |
| 95 | |
| 96 \begin{funcdesc}{pow}{x, y} | |
|
6647
a7ea74a27993
Get rid of math mode in some places.
Guido van Rossum <guido@python.org>
parents:
6485
diff
changeset
|
97 Return \code{\var{x}**\var{y}}. |
| 6363 | 98 \end{funcdesc} |
| 99 | |
|
12663
1ea8cf885f7b
Added math.rint() -- round according to current IEEE754 mode
Guido van Rossum <guido@python.org>
parents:
12223
diff
changeset
|
100 \begin{funcdesc}{rint}{x, y} |
|
1ea8cf885f7b
Added math.rint() -- round according to current IEEE754 mode
Guido van Rossum <guido@python.org>
parents:
12223
diff
changeset
|
101 Return the integer nearest to \var{x} as a real. |
|
12669
2a6dc65c060f
The addition of rint() (by Peter Schneider-Kamp; I forgot to mention
Guido van Rossum <guido@python.org>
parents:
12663
diff
changeset
|
102 (Only available on platforms where this is in the standard C math library.) |
|
12663
1ea8cf885f7b
Added math.rint() -- round according to current IEEE754 mode
Guido van Rossum <guido@python.org>
parents:
12223
diff
changeset
|
103 \end{funcdesc} |
|
1ea8cf885f7b
Added math.rint() -- round according to current IEEE754 mode
Guido van Rossum <guido@python.org>
parents:
12223
diff
changeset
|
104 |
| 6363 | 105 \begin{funcdesc}{sin}{x} |
| 106 Return the sine of \var{x}. | |
| 107 \end{funcdesc} | |
| 108 | |
| 109 \begin{funcdesc}{sinh}{x} | |
| 110 Return the hyperbolic sine of \var{x}. | |
| 111 \end{funcdesc} | |
| 112 | |
| 113 \begin{funcdesc}{sqrt}{x} | |
| 114 Return the square root of \var{x}. | |
| 115 \end{funcdesc} | |
| 116 | |
| 117 \begin{funcdesc}{tan}{x} | |
| 118 Return the tangent of \var{x}. | |
| 119 \end{funcdesc} | |
| 120 | |
| 121 \begin{funcdesc}{tanh}{x} | |
| 122 Return the hyperbolic tangent of \var{x}. | |
| 123 \end{funcdesc} | |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
124 |
|
7157
a6fa9f3cad13
Added descriptions for log() and log10().
Fred Drake <fdrake@acm.org>
parents:
7048
diff
changeset
|
125 Note that \function{frexp()} and \function{modf()} have a different |
| 10646 | 126 call/return pattern than their C equivalents: they take a single |
|
7157
a6fa9f3cad13
Added descriptions for log() and log10().
Fred Drake <fdrake@acm.org>
parents:
7048
diff
changeset
|
127 argument and return a pair of values, rather than returning their |
|
a6fa9f3cad13
Added descriptions for log() and log10().
Fred Drake <fdrake@acm.org>
parents:
7048
diff
changeset
|
128 second return value through an `output parameter' (there is no such |
|
a6fa9f3cad13
Added descriptions for log() and log10().
Fred Drake <fdrake@acm.org>
parents:
7048
diff
changeset
|
129 thing in Python). |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
130 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
131 The module also defines two mathematical constants: |
| 6363 | 132 |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
133 \begin{datadesc}{pi} |
| 6363 | 134 The mathematical constant \emph{pi}. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
135 \end{datadesc} |
| 5818 | 136 |
| 6363 | 137 \begin{datadesc}{e} |
| 138 The mathematical constant \emph{e}. | |
| 139 \end{datadesc} | |
| 140 | |
|
6485
2f258162aae2
Restore the \seealso formatting that got lost when I updated the math
Fred Drake <fdrake@acm.org>
parents:
6363
diff
changeset
|
141 \begin{seealso} |
|
2f258162aae2
Restore the \seealso formatting that got lost when I updated the math
Fred Drake <fdrake@acm.org>
parents:
6363
diff
changeset
|
142 \seemodule{cmath}{Complex number versions of many of these functions.} |
|
2f258162aae2
Restore the \seealso formatting that got lost when I updated the math
Fred Drake <fdrake@acm.org>
parents:
6363
diff
changeset
|
143 \end{seealso} |
