annotate Doc/library/cmath.rst @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents b36cb4602e21
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42604
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
1 :mod:`cmath` --- Mathematical functions for complex numbers
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
2 ===========================================================
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
3
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
4 .. module:: cmath
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
5 :synopsis: Mathematical functions for complex numbers.
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
6
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
7
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
8 This module is always available. It provides access to mathematical functions
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
9 for complex numbers. The functions in this module accept integers,
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
10 floating-point numbers or complex numbers as arguments. They will also accept
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
11 any Python object that has either a :meth:`__complex__` or a :meth:`__float__`
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
12 method: these methods are used to convert the object to a complex or
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
13 floating-point number, respectively, and the function is then applied to the
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
14 result of the conversion.
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
15
46473
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
16 .. note::
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
17
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
18 On platforms with hardware and system-level support for signed
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
19 zeros, functions involving branch cuts are continuous on *both*
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
20 sides of the branch cut: the sign of the zero distinguishes one
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
21 side of the branch cut from the other. On platforms that do not
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
22 support signed zeros the continuity is as specified below.
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
23
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
24
55471
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
25 Conversions to and from polar coordinates
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
26 -----------------------------------------
46473
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
27
55471
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
28 A Python complex number ``z`` is stored internally using *rectangular*
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
29 or *Cartesian* coordinates. It is completely determined by its *real
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
30 part* ``z.real`` and its *imaginary part* ``z.imag``. In other
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
31 words::
46473
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
32
55471
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
33 z == z.real + z.imag*1j
46473
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
34
55471
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
35 *Polar coordinates* give an alternative way to represent a complex
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
36 number. In polar coordinates, a complex number *z* is defined by the
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
37 modulus *r* and the phase angle *phi*. The modulus *r* is the distance
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
38 from *z* to the origin, while the phase *phi* is the counterclockwise
58082
fc87a2fc47a5 Merged revisions 77230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 55475
diff changeset
39 angle, measured in radians, from the positive x-axis to the line
fc87a2fc47a5 Merged revisions 77230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 55475
diff changeset
40 segment that joins the origin to *z*.
46473
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
41
55471
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
42 The following functions can be used to convert from the native
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
43 rectangular coordinates to polar coordinates and back.
46473
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
44
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
45 .. function:: phase(x)
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
46
55471
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
47 Return the phase of *x* (also known as the *argument* of *x*), as a
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
48 float. ``phase(x)`` is equivalent to ``math.atan2(x.imag,
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
49 x.real)``. The result lies in the range [-π, π], and the branch
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
50 cut for this operation lies along the negative real axis,
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
51 continuous from above. On systems with support for signed zeros
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
52 (which includes most systems in current use), this means that the
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
53 sign of the result is the same as the sign of ``x.imag``, even when
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
54 ``x.imag`` is zero::
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
55
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
56 >>> phase(complex(-1.0, 0.0))
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
57 3.1415926535897931
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
58 >>> phase(complex(-1.0, -0.0))
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
59 -3.1415926535897931
46473
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
60
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
61 .. versionadded:: 2.6
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
62
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
63
55471
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
64 .. note::
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
65
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
66 The modulus (absolute value) of a complex number *x* can be
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
67 computed using the built-in :func:`abs` function. There is no
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
68 separate :mod:`cmath` module function for this operation.
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
69
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
70
46473
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
71 .. function:: polar(x)
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
72
55471
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
73 Return the representation of *x* in polar coordinates. Returns a
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
74 pair ``(r, phi)`` where *r* is the modulus of *x* and phi is the
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
75 phase of *x*. ``polar(x)`` is equivalent to ``(abs(x),
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
76 phase(x))``.
46473
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
77
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
78 .. versionadded:: 2.6
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
79
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
80
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
81 .. function:: rect(r, phi)
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
82
55471
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
83 Return the complex number *x* with polar coordinates *r* and *phi*.
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
84 Equivalent to ``r * (math.cos(phi) + math.sin(phi)*1j)``.
46473
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
85
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
86 .. versionadded:: 2.6
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
87
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
88
55471
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
89 Power and logarithmic functions
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
90 -------------------------------
42604
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
91
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
92 .. function:: exp(x)
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
93
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
94 Return the exponential value ``e**x``.
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
95
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
96
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
97 .. function:: log(x[, base])
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
98
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
99 Returns the logarithm of *x* to the given *base*. If the *base* is not
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
100 specified, returns the natural logarithm of *x*. There is one branch cut, from 0
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
101 along the negative real axis to -∞, continuous from above.
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
102
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
103 .. versionchanged:: 2.4
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
104 *base* argument added.
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
105
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
106
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
107 .. function:: log10(x)
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
108
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
109 Return the base-10 logarithm of *x*. This has the same branch cut as
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
110 :func:`log`.
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
111
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
112
55471
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
113 .. function:: sqrt(x)
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
114
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
115 Return the square root of *x*. This has the same branch cut as :func:`log`.
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
116
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
117
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
118 Trigonometric functions
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
119 -----------------------
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
120
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
121 .. function:: acos(x)
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
122
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
123 Return the arc cosine of *x*. There are two branch cuts: One extends right from
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
124 1 along the real axis to ∞, continuous from below. The other extends left from
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
125 -1 along the real axis to -∞, continuous from above.
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
126
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
127
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
128 .. function:: asin(x)
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
129
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
130 Return the arc sine of *x*. This has the same branch cuts as :func:`acos`.
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
131
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
132
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
133 .. function:: atan(x)
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
134
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
135 Return the arc tangent of *x*. There are two branch cuts: One extends from
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
136 ``1j`` along the imaginary axis to ``∞j``, continuous from the right. The
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
137 other extends from ``-1j`` along the imaginary axis to ``-∞j``, continuous
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
138 from the left.
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
139
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
140 .. versionchanged:: 2.6
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
141 direction of continuity of upper cut reversed
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
142
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
143
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
144 .. function:: cos(x)
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
145
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
146 Return the cosine of *x*.
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
147
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
148
42604
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
149 .. function:: sin(x)
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
150
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
151 Return the sine of *x*.
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
152
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
153
55471
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
154 .. function:: tan(x)
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
155
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
156 Return the tangent of *x*.
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
157
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
158
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
159 Hyperbolic functions
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
160 --------------------
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
161
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
162 .. function:: acosh(x)
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
163
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
164 Return the hyperbolic arc cosine of *x*. There is one branch cut, extending left
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
165 from 1 along the real axis to -∞, continuous from above.
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
166
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
167
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
168 .. function:: asinh(x)
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
169
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
170 Return the hyperbolic arc sine of *x*. There are two branch cuts:
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
171 One extends from ``1j`` along the imaginary axis to ``∞j``,
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
172 continuous from the right. The other extends from ``-1j`` along
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
173 the imaginary axis to ``-∞j``, continuous from the left.
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
174
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
175 .. versionchanged:: 2.6
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
176 branch cuts moved to match those recommended by the C99 standard
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
177
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
178
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
179 .. function:: atanh(x)
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
180
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
181 Return the hyperbolic arc tangent of *x*. There are two branch cuts: One
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
182 extends from ``1`` along the real axis to ``∞``, continuous from below. The
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
183 other extends from ``-1`` along the real axis to ``-∞``, continuous from
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
184 above.
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
185
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
186 .. versionchanged:: 2.6
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
187 direction of continuity of right cut reversed
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
188
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
189
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
190 .. function:: cosh(x)
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
191
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
192 Return the hyperbolic cosine of *x*.
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
193
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
194
42604
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
195 .. function:: sinh(x)
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
196
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
197 Return the hyperbolic sine of *x*.
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
198
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
199
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
200 .. function:: tanh(x)
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
201
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
202 Return the hyperbolic tangent of *x*.
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
203
55471
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
204
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
205 Classification functions
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
206 ------------------------
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
207
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
208 .. function:: isinf(x)
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
209
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
210 Return *True* if the real or the imaginary part of x is positive
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
211 or negative infinity.
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
212
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
213 .. versionadded:: 2.6
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
214
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
215
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
216 .. function:: isnan(x)
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
217
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
218 Return *True* if the real or imaginary part of x is not a number (NaN).
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
219
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
220 .. versionadded:: 2.6
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
221
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
222
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
223 Constants
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
224 ---------
42604
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
225
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
226
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
227 .. data:: pi
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
228
55471
7fd9adc81280 Merged revisions 74184,74230 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 50522
diff changeset
229 The mathematical constant *π*, as a float.
42604
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
230
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
231
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
232 .. data:: e
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
233
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
234 The mathematical constant *e*, as a float.
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
235
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
236 .. index:: module: math
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
237
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
238 Note that the selection of functions is similar, but not identical, to that in
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
239 module :mod:`math`. The reason for having two modules is that some users aren't
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
240 interested in complex numbers, and perhaps don't even know what they are. They
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
241 would rather have ``math.sqrt(-1)`` raise an exception than return a complex
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
242 number. Also note that the functions defined in :mod:`cmath` always return a
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
243 complex number, even if the answer can be expressed as a real number (in which
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
244 case the complex number has an imaginary part of zero).
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
245
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
246 A note on branch cuts: They are curves along which the given function fails to
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
247 be continuous. They are a necessary feature of many complex functions. It is
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
248 assumed that if you need to compute with complex functions, you will understand
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
249 about branch cuts. Consult almost any (not too elementary) book on complex
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
250 variables for enlightenment. For information of the proper choice of branch
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
251 cuts for numerical purposes, a good reference should be the following:
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
252
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
253
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
254 .. seealso::
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
255
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
256 Kahan, W: Branch cuts for complex elementary functions; or, Much ado about
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
257 nothing's sign bit. In Iserles, A., and Powell, M. (eds.), The state of the art
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
258 in numerical analysis. Clarendon Press (1987) pp165-211.
9e1529bf0442 Move the 3k reST doc tree in place.
Georg Brandl <georg@python.org>
parents:
diff changeset
259
46473
5bc7b20dc04a I finally got the time to update and merge Mark's and my trunk-math branch. The patch is collaborated work of Mark Dickinson and me. It was mostly done a few months ago. The patch fixes a lot of loose ends and edge cases related to operations with NaN, INF, very small values and complex math.
Christian Heimes <christian@cheimes.de>
parents: 42604
diff changeset
260