2007-08-15 11:28:01 -03:00
|
|
|
|
|
|
|
:mod:`math` --- Mathematical functions
|
|
|
|
======================================
|
|
|
|
|
|
|
|
.. module:: math
|
|
|
|
:synopsis: Mathematical functions (sin() etc.).
|
|
|
|
|
|
|
|
|
|
|
|
This module is always available. It provides access to the mathematical
|
|
|
|
functions defined by the C standard.
|
|
|
|
|
|
|
|
These functions cannot be used with complex numbers; use the functions of the
|
|
|
|
same name from the :mod:`cmath` module if you require support for complex
|
|
|
|
numbers. The distinction between functions which support complex numbers and
|
|
|
|
those which don't is made since most users do not want to learn quite as much
|
|
|
|
mathematics as required to understand complex numbers. Receiving an exception
|
|
|
|
instead of a complex result allows earlier detection of the unexpected complex
|
|
|
|
number used as a parameter, so that the programmer can determine how and why it
|
|
|
|
was generated in the first place.
|
|
|
|
|
|
|
|
The following functions are provided by this module. Except when explicitly
|
|
|
|
noted otherwise, all return values are floats.
|
|
|
|
|
|
|
|
|
Merged revisions 67654,67676-67677,67681,67692,67725,67746,67748,67761,67784-67785,67787-67788,67802,67832,67848-67849,67859,67862-67864,67880,67882,67885,67889-67892,67895 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r67654 | georg.brandl | 2008-12-07 16:42:09 -0600 (Sun, 07 Dec 2008) | 2 lines
#4457: rewrite __import__() documentation.
................
r67676 | benjamin.peterson | 2008-12-08 20:03:03 -0600 (Mon, 08 Dec 2008) | 1 line
specify how things are copied
................
r67677 | benjamin.peterson | 2008-12-08 20:05:11 -0600 (Mon, 08 Dec 2008) | 1 line
revert unrelated change to installer script
................
r67681 | jeremy.hylton | 2008-12-09 15:03:10 -0600 (Tue, 09 Dec 2008) | 2 lines
Add simple unittests for Request
................
r67692 | amaury.forgeotdarc | 2008-12-10 18:03:42 -0600 (Wed, 10 Dec 2008) | 2 lines
#1030250: correctly pass the dry_run option to the mkpath() function.
................
r67725 | benjamin.peterson | 2008-12-12 22:02:20 -0600 (Fri, 12 Dec 2008) | 1 line
fix incorrect example
................
r67746 | antoine.pitrou | 2008-12-13 17:12:30 -0600 (Sat, 13 Dec 2008) | 3 lines
Issue #4163: Use unicode-friendly word splitting in the textwrap functions when given an unicode string.
................
r67748 | benjamin.peterson | 2008-12-13 19:46:11 -0600 (Sat, 13 Dec 2008) | 1 line
remove has_key usage
................
r67761 | benjamin.peterson | 2008-12-14 11:26:04 -0600 (Sun, 14 Dec 2008) | 1 line
fix missing bracket
................
r67784 | georg.brandl | 2008-12-15 02:33:58 -0600 (Mon, 15 Dec 2008) | 2 lines
#4446: document "platforms" argument for setup().
................
r67785 | georg.brandl | 2008-12-15 02:36:11 -0600 (Mon, 15 Dec 2008) | 2 lines
#4611: fix typo.
................
r67787 | georg.brandl | 2008-12-15 02:58:59 -0600 (Mon, 15 Dec 2008) | 2 lines
#4578: fix has_key() usage in compiler package.
................
r67788 | georg.brandl | 2008-12-15 03:07:39 -0600 (Mon, 15 Dec 2008) | 2 lines
#4568: remove limitation in varargs callback example.
................
r67802 | amaury.forgeotdarc | 2008-12-15 16:29:14 -0600 (Mon, 15 Dec 2008) | 4 lines
#3632: the "pyo" macro from gdbinit can now run when the GIL is released.
Patch by haypo.
................
r67832 | antoine.pitrou | 2008-12-17 16:46:54 -0600 (Wed, 17 Dec 2008) | 4 lines
Issue #2467: gc.DEBUG_STATS reports invalid elapsed times.
Patch by Neil Schemenauer, very slightly modified.
................
r67848 | benjamin.peterson | 2008-12-18 20:28:56 -0600 (Thu, 18 Dec 2008) | 1 line
fix typo
................
r67849 | benjamin.peterson | 2008-12-18 20:31:35 -0600 (Thu, 18 Dec 2008) | 1 line
_call_method -> _callmethod and _get_value to _getvalue
................
r67859 | amaury.forgeotdarc | 2008-12-19 16:56:48 -0600 (Fri, 19 Dec 2008) | 4 lines
#4700: crtlicense.txt is displayed by the license() command and should be kept ascii-only.
Will port to 3.0
................
r67862 | benjamin.peterson | 2008-12-19 20:48:02 -0600 (Fri, 19 Dec 2008) | 1 line
copy sentence from docstring
................
r67863 | benjamin.peterson | 2008-12-19 20:51:26 -0600 (Fri, 19 Dec 2008) | 1 line
add headings
................
r67864 | benjamin.peterson | 2008-12-19 20:57:19 -0600 (Fri, 19 Dec 2008) | 1 line
beef up docstring
................
r67880 | benjamin.peterson | 2008-12-20 16:49:24 -0600 (Sat, 20 Dec 2008) | 1 line
remove redundant sentence
................
r67882 | benjamin.peterson | 2008-12-20 16:59:49 -0600 (Sat, 20 Dec 2008) | 1 line
add some recent releases to the list
................
r67885 | benjamin.peterson | 2008-12-20 17:48:54 -0600 (Sat, 20 Dec 2008) | 1 line
silence annoying DeprecationWarning
................
r67889 | benjamin.peterson | 2008-12-20 19:04:32 -0600 (Sat, 20 Dec 2008) | 1 line
sphinx.web is long gone
................
r67890 | benjamin.peterson | 2008-12-20 19:12:26 -0600 (Sat, 20 Dec 2008) | 1 line
update readme
................
r67891 | benjamin.peterson | 2008-12-20 19:14:47 -0600 (Sat, 20 Dec 2008) | 1 line
there are way too many places which need to have the current version added
................
r67892 | benjamin.peterson | 2008-12-20 19:29:32 -0600 (Sat, 20 Dec 2008) | 9 lines
Merged revisions 67809 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r67809 | benjamin.peterson | 2008-12-15 21:54:45 -0600 (Mon, 15 Dec 2008) | 1 line
fix logic error
........
................
r67895 | neal.norwitz | 2008-12-21 08:28:32 -0600 (Sun, 21 Dec 2008) | 2 lines
Add Tarek for work on distutils.
................
2008-12-21 13:01:26 -04:00
|
|
|
Number-theoretic and representation functions
|
|
|
|
---------------------------------------------
|
2007-08-15 11:28:01 -03:00
|
|
|
|
|
|
|
.. function:: ceil(x)
|
|
|
|
|
2008-01-05 04:47:13 -04:00
|
|
|
Return the ceiling of *x* as a float, the smallest integer value greater than or
|
|
|
|
equal to *x*.
|
2007-08-15 11:28:01 -03:00
|
|
|
|
|
|
|
|
2008-01-03 18:32:26 -04:00
|
|
|
.. function:: copysign(x, y)
|
|
|
|
|
|
|
|
Return *x* with the sign of *y*. ``copysign`` copies the sign bit of an IEEE
|
|
|
|
754 float, ``copysign(1, -0.0)`` returns *-1.0*.
|
|
|
|
|
2008-01-04 14:25:05 -04:00
|
|
|
.. versionadded:: 2.6
|
2008-01-03 18:32:26 -04:00
|
|
|
|
|
|
|
|
2007-08-15 11:28:01 -03:00
|
|
|
.. function:: fabs(x)
|
|
|
|
|
|
|
|
Return the absolute value of *x*.
|
|
|
|
|
2008-06-18 06:28:22 -03:00
|
|
|
|
2008-06-09 03:54:45 -03:00
|
|
|
.. function:: factorial(x)
|
|
|
|
|
2008-06-18 06:20:17 -03:00
|
|
|
Return *x* factorial. Raises :exc:`ValueError` if *x* is not integral or
|
2008-06-09 03:54:45 -03:00
|
|
|
is negative.
|
2007-08-15 11:28:01 -03:00
|
|
|
|
2008-06-18 06:28:22 -03:00
|
|
|
.. versionadded:: 2.6
|
|
|
|
|
|
|
|
|
2007-08-15 11:28:01 -03:00
|
|
|
.. function:: floor(x)
|
|
|
|
|
2008-01-05 04:47:13 -04:00
|
|
|
Return the floor of *x* as a float, the largest integer value less than or equal
|
|
|
|
to *x*.
|
2007-08-15 11:28:01 -03:00
|
|
|
|
2008-01-05 15:28:16 -04:00
|
|
|
.. versionchanged:: 2.6
|
|
|
|
Added :meth:`__floor__` delegation.
|
|
|
|
|
2007-08-15 11:28:01 -03:00
|
|
|
|
|
|
|
.. function:: fmod(x, y)
|
|
|
|
|
|
|
|
Return ``fmod(x, y)``, as defined by the platform C library. Note that the
|
|
|
|
Python expression ``x % y`` may not return the same result. The intent of the C
|
|
|
|
standard is that ``fmod(x, y)`` be exactly (mathematically; to infinite
|
|
|
|
precision) equal to ``x - n*y`` for some integer *n* such that the result has
|
|
|
|
the same sign as *x* and magnitude less than ``abs(y)``. Python's ``x % y``
|
|
|
|
returns a result with the sign of *y* instead, and may not be exactly computable
|
|
|
|
for float arguments. For example, ``fmod(-1e-100, 1e100)`` is ``-1e-100``, but
|
|
|
|
the result of Python's ``-1e-100 % 1e100`` is ``1e100-1e-100``, which cannot be
|
|
|
|
represented exactly as a float, and rounds to the surprising ``1e100``. For
|
|
|
|
this reason, function :func:`fmod` is generally preferred when working with
|
|
|
|
floats, while Python's ``x % y`` is preferred when working with integers.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: frexp(x)
|
|
|
|
|
|
|
|
Return the mantissa and exponent of *x* as the pair ``(m, e)``. *m* is a float
|
|
|
|
and *e* is an integer such that ``x == m * 2**e`` exactly. If *x* is zero,
|
|
|
|
returns ``(0.0, 0)``, otherwise ``0.5 <= abs(m) < 1``. This is used to "pick
|
|
|
|
apart" the internal representation of a float in a portable way.
|
|
|
|
|
|
|
|
|
2008-07-30 13:20:10 -03:00
|
|
|
.. function:: fsum(iterable)
|
|
|
|
|
|
|
|
Return an accurate floating point sum of values in the iterable. Avoids
|
2009-02-19 01:53:22 -04:00
|
|
|
loss of precision by tracking multiple intermediate partial sums::
|
|
|
|
|
|
|
|
>>> sum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1])
|
|
|
|
0.99999999999999989
|
|
|
|
>>> fsum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1])
|
|
|
|
1.0
|
|
|
|
|
|
|
|
The algorithm's accuracy depends on IEEE-754 arithmetic guarantees and the
|
|
|
|
typical case where the rounding mode is half-even. On some non-Windows
|
|
|
|
builds, the underlying C library uses extended precision addition and may
|
|
|
|
occasionally double-round an intermediate sum causing it to be off in its
|
|
|
|
least significant bit.
|
2008-07-30 17:23:15 -03:00
|
|
|
|
2009-02-19 02:57:23 -04:00
|
|
|
For further discussion and two alternative approaches, see the `ASPN cookbook
|
|
|
|
recipes for accurate floating point summation
|
|
|
|
<http://code.activestate.com/recipes/393090/>`_\.
|
|
|
|
|
2008-07-30 13:20:10 -03:00
|
|
|
.. versionadded:: 2.6
|
|
|
|
|
|
|
|
|
2008-01-03 16:23:15 -04:00
|
|
|
.. function:: isinf(x)
|
|
|
|
|
|
|
|
Checks if the float *x* is positive or negative infinite.
|
|
|
|
|
2008-01-04 14:25:05 -04:00
|
|
|
.. versionadded:: 2.6
|
2008-01-03 16:23:15 -04:00
|
|
|
|
|
|
|
|
|
|
|
.. function:: isnan(x)
|
|
|
|
|
|
|
|
Checks if the float *x* is a NaN (not a number). NaNs are part of the
|
Merged revisions 68133-68134,68141-68142,68145-68146,68148-68149,68159-68162,68166,68171-68174,68179,68195-68196,68210,68214-68215,68217-68222 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r68133 | antoine.pitrou | 2009-01-01 16:38:03 +0100 (Thu, 01 Jan 2009) | 1 line
fill in actual issue number in tests
........
r68134 | hirokazu.yamamoto | 2009-01-01 16:45:39 +0100 (Thu, 01 Jan 2009) | 2 lines
Issue #4797: IOError.filename was not set when _fileio.FileIO failed to open
file with `str' filename on Windows.
........
r68141 | benjamin.peterson | 2009-01-01 17:43:12 +0100 (Thu, 01 Jan 2009) | 1 line
fix highlighting
........
r68142 | benjamin.peterson | 2009-01-01 18:29:49 +0100 (Thu, 01 Jan 2009) | 2 lines
welcome to 2009, Python!
........
r68145 | amaury.forgeotdarc | 2009-01-02 01:03:54 +0100 (Fri, 02 Jan 2009) | 5 lines
#4801 _collections module fails to build on cygwin.
_PyObject_GC_TRACK is the macro version of PyObject_GC_Track,
and according to documentation it should not be used for extension modules.
........
r68146 | ronald.oussoren | 2009-01-02 11:44:46 +0100 (Fri, 02 Jan 2009) | 2 lines
Fix for issue4472: "configure --enable-shared doesn't work on OSX"
........
r68148 | ronald.oussoren | 2009-01-02 11:48:31 +0100 (Fri, 02 Jan 2009) | 2 lines
Forgot to add a NEWS item in my previous checkin
........
r68149 | ronald.oussoren | 2009-01-02 11:50:48 +0100 (Fri, 02 Jan 2009) | 2 lines
Fix for issue4780
........
r68159 | ronald.oussoren | 2009-01-02 15:48:17 +0100 (Fri, 02 Jan 2009) | 2 lines
Fix for issue 1627952
........
r68160 | ronald.oussoren | 2009-01-02 15:52:09 +0100 (Fri, 02 Jan 2009) | 2 lines
Fix for issue r1737832
........
r68161 | ronald.oussoren | 2009-01-02 16:00:05 +0100 (Fri, 02 Jan 2009) | 3 lines
Fix for issue 1149804
........
r68162 | ronald.oussoren | 2009-01-02 16:06:00 +0100 (Fri, 02 Jan 2009) | 3 lines
Fix for issue 4472 is incompatible with Cygwin, this patch
should fix that.
........
r68166 | benjamin.peterson | 2009-01-02 19:26:23 +0100 (Fri, 02 Jan 2009) | 1 line
document PyMemberDef
........
r68171 | georg.brandl | 2009-01-02 21:25:14 +0100 (Fri, 02 Jan 2009) | 3 lines
#4811: fix markup glitches (mostly remains of the conversion),
found by Gabriel Genellina.
........
r68172 | martin.v.loewis | 2009-01-02 21:32:55 +0100 (Fri, 02 Jan 2009) | 2 lines
Issue #4075: Use OutputDebugStringW in Py_FatalError.
........
r68173 | martin.v.loewis | 2009-01-02 21:40:14 +0100 (Fri, 02 Jan 2009) | 2 lines
Issue #4051: Prevent conflict of UNICODE macros in cPickle.
........
r68174 | benjamin.peterson | 2009-01-02 21:47:27 +0100 (Fri, 02 Jan 2009) | 1 line
fix compilation on non-Windows platforms
........
r68179 | raymond.hettinger | 2009-01-02 22:26:45 +0100 (Fri, 02 Jan 2009) | 1 line
Issue #4615. Document how to use itertools for de-duping.
........
r68195 | georg.brandl | 2009-01-03 14:45:15 +0100 (Sat, 03 Jan 2009) | 2 lines
Remove useless string literal.
........
r68196 | georg.brandl | 2009-01-03 15:29:53 +0100 (Sat, 03 Jan 2009) | 2 lines
Fix indentation.
........
r68210 | georg.brandl | 2009-01-03 20:10:12 +0100 (Sat, 03 Jan 2009) | 2 lines
Set eol-style correctly for mp_distributing.py.
........
r68214 | georg.brandl | 2009-01-03 20:44:48 +0100 (Sat, 03 Jan 2009) | 2 lines
Make indentation consistent.
........
r68215 | georg.brandl | 2009-01-03 21:15:14 +0100 (Sat, 03 Jan 2009) | 2 lines
Fix role name.
........
r68217 | georg.brandl | 2009-01-03 21:30:15 +0100 (Sat, 03 Jan 2009) | 2 lines
Add rstlint, a little tool to find subtle markup problems and inconsistencies in the Doc sources.
........
r68218 | georg.brandl | 2009-01-03 21:38:59 +0100 (Sat, 03 Jan 2009) | 2 lines
Recognize usage of the default role.
........
r68219 | georg.brandl | 2009-01-03 21:47:01 +0100 (Sat, 03 Jan 2009) | 2 lines
Fix uses of the default role.
........
r68220 | georg.brandl | 2009-01-03 21:55:06 +0100 (Sat, 03 Jan 2009) | 2 lines
Remove trailing whitespace.
........
r68221 | georg.brandl | 2009-01-03 22:04:55 +0100 (Sat, 03 Jan 2009) | 2 lines
Remove tabs from the documentation.
........
r68222 | georg.brandl | 2009-01-03 22:11:58 +0100 (Sat, 03 Jan 2009) | 2 lines
Disable the line length checker by default.
........
2009-01-03 17:55:17 -04:00
|
|
|
IEEE 754 standards. Operation like but not limited to ``inf * 0``,
|
2008-01-03 16:23:15 -04:00
|
|
|
``inf / inf`` or any operation involving a NaN, e.g. ``nan * 1``, return
|
|
|
|
a NaN.
|
|
|
|
|
2008-01-04 14:25:05 -04:00
|
|
|
.. versionadded:: 2.6
|
2008-01-03 16:23:15 -04:00
|
|
|
|
|
|
|
|
2007-08-15 11:28:01 -03:00
|
|
|
.. function:: ldexp(x, i)
|
|
|
|
|
|
|
|
Return ``x * (2**i)``. This is essentially the inverse of function
|
|
|
|
:func:`frexp`.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: modf(x)
|
|
|
|
|
Merged revisions 67654,67676-67677,67681,67692,67725,67746,67748,67761,67784-67785,67787-67788,67802,67832,67848-67849,67859,67862-67864,67880,67882,67885,67889-67892,67895 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r67654 | georg.brandl | 2008-12-07 16:42:09 -0600 (Sun, 07 Dec 2008) | 2 lines
#4457: rewrite __import__() documentation.
................
r67676 | benjamin.peterson | 2008-12-08 20:03:03 -0600 (Mon, 08 Dec 2008) | 1 line
specify how things are copied
................
r67677 | benjamin.peterson | 2008-12-08 20:05:11 -0600 (Mon, 08 Dec 2008) | 1 line
revert unrelated change to installer script
................
r67681 | jeremy.hylton | 2008-12-09 15:03:10 -0600 (Tue, 09 Dec 2008) | 2 lines
Add simple unittests for Request
................
r67692 | amaury.forgeotdarc | 2008-12-10 18:03:42 -0600 (Wed, 10 Dec 2008) | 2 lines
#1030250: correctly pass the dry_run option to the mkpath() function.
................
r67725 | benjamin.peterson | 2008-12-12 22:02:20 -0600 (Fri, 12 Dec 2008) | 1 line
fix incorrect example
................
r67746 | antoine.pitrou | 2008-12-13 17:12:30 -0600 (Sat, 13 Dec 2008) | 3 lines
Issue #4163: Use unicode-friendly word splitting in the textwrap functions when given an unicode string.
................
r67748 | benjamin.peterson | 2008-12-13 19:46:11 -0600 (Sat, 13 Dec 2008) | 1 line
remove has_key usage
................
r67761 | benjamin.peterson | 2008-12-14 11:26:04 -0600 (Sun, 14 Dec 2008) | 1 line
fix missing bracket
................
r67784 | georg.brandl | 2008-12-15 02:33:58 -0600 (Mon, 15 Dec 2008) | 2 lines
#4446: document "platforms" argument for setup().
................
r67785 | georg.brandl | 2008-12-15 02:36:11 -0600 (Mon, 15 Dec 2008) | 2 lines
#4611: fix typo.
................
r67787 | georg.brandl | 2008-12-15 02:58:59 -0600 (Mon, 15 Dec 2008) | 2 lines
#4578: fix has_key() usage in compiler package.
................
r67788 | georg.brandl | 2008-12-15 03:07:39 -0600 (Mon, 15 Dec 2008) | 2 lines
#4568: remove limitation in varargs callback example.
................
r67802 | amaury.forgeotdarc | 2008-12-15 16:29:14 -0600 (Mon, 15 Dec 2008) | 4 lines
#3632: the "pyo" macro from gdbinit can now run when the GIL is released.
Patch by haypo.
................
r67832 | antoine.pitrou | 2008-12-17 16:46:54 -0600 (Wed, 17 Dec 2008) | 4 lines
Issue #2467: gc.DEBUG_STATS reports invalid elapsed times.
Patch by Neil Schemenauer, very slightly modified.
................
r67848 | benjamin.peterson | 2008-12-18 20:28:56 -0600 (Thu, 18 Dec 2008) | 1 line
fix typo
................
r67849 | benjamin.peterson | 2008-12-18 20:31:35 -0600 (Thu, 18 Dec 2008) | 1 line
_call_method -> _callmethod and _get_value to _getvalue
................
r67859 | amaury.forgeotdarc | 2008-12-19 16:56:48 -0600 (Fri, 19 Dec 2008) | 4 lines
#4700: crtlicense.txt is displayed by the license() command and should be kept ascii-only.
Will port to 3.0
................
r67862 | benjamin.peterson | 2008-12-19 20:48:02 -0600 (Fri, 19 Dec 2008) | 1 line
copy sentence from docstring
................
r67863 | benjamin.peterson | 2008-12-19 20:51:26 -0600 (Fri, 19 Dec 2008) | 1 line
add headings
................
r67864 | benjamin.peterson | 2008-12-19 20:57:19 -0600 (Fri, 19 Dec 2008) | 1 line
beef up docstring
................
r67880 | benjamin.peterson | 2008-12-20 16:49:24 -0600 (Sat, 20 Dec 2008) | 1 line
remove redundant sentence
................
r67882 | benjamin.peterson | 2008-12-20 16:59:49 -0600 (Sat, 20 Dec 2008) | 1 line
add some recent releases to the list
................
r67885 | benjamin.peterson | 2008-12-20 17:48:54 -0600 (Sat, 20 Dec 2008) | 1 line
silence annoying DeprecationWarning
................
r67889 | benjamin.peterson | 2008-12-20 19:04:32 -0600 (Sat, 20 Dec 2008) | 1 line
sphinx.web is long gone
................
r67890 | benjamin.peterson | 2008-12-20 19:12:26 -0600 (Sat, 20 Dec 2008) | 1 line
update readme
................
r67891 | benjamin.peterson | 2008-12-20 19:14:47 -0600 (Sat, 20 Dec 2008) | 1 line
there are way too many places which need to have the current version added
................
r67892 | benjamin.peterson | 2008-12-20 19:29:32 -0600 (Sat, 20 Dec 2008) | 9 lines
Merged revisions 67809 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r67809 | benjamin.peterson | 2008-12-15 21:54:45 -0600 (Mon, 15 Dec 2008) | 1 line
fix logic error
........
................
r67895 | neal.norwitz | 2008-12-21 08:28:32 -0600 (Sun, 21 Dec 2008) | 2 lines
Add Tarek for work on distutils.
................
2008-12-21 13:01:26 -04:00
|
|
|
Return the fractional and integer parts of *x*. Both results carry the sign
|
|
|
|
of *x* and are floats.
|
2007-08-15 11:28:01 -03:00
|
|
|
|
2008-06-18 06:28:22 -03:00
|
|
|
|
2008-02-01 02:22:46 -04:00
|
|
|
.. function:: trunc(x)
|
|
|
|
|
|
|
|
Return the :class:`Real` value *x* truncated to an :class:`Integral` (usually
|
|
|
|
a long integer). Delegates to ``x.__trunc__()``.
|
|
|
|
|
|
|
|
.. versionadded:: 2.6
|
|
|
|
|
2008-06-18 06:28:22 -03:00
|
|
|
|
2007-08-15 11:28:01 -03:00
|
|
|
Note that :func:`frexp` and :func:`modf` have a different call/return pattern
|
|
|
|
than their C equivalents: they take a single argument and return a pair of
|
|
|
|
values, rather than returning their second return value through an 'output
|
|
|
|
parameter' (there is no such thing in Python).
|
|
|
|
|
|
|
|
For the :func:`ceil`, :func:`floor`, and :func:`modf` functions, note that *all*
|
|
|
|
floating-point numbers of sufficiently large magnitude are exact integers.
|
|
|
|
Python floats typically carry no more than 53 bits of precision (the same as the
|
|
|
|
platform C double type), in which case any float *x* with ``abs(x) >= 2**52``
|
|
|
|
necessarily has no fractional bits.
|
|
|
|
|
Merged revisions 67654,67676-67677,67681,67692,67725,67746,67748,67761,67784-67785,67787-67788,67802,67832,67848-67849,67859,67862-67864,67880,67882,67885,67889-67892,67895 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r67654 | georg.brandl | 2008-12-07 16:42:09 -0600 (Sun, 07 Dec 2008) | 2 lines
#4457: rewrite __import__() documentation.
................
r67676 | benjamin.peterson | 2008-12-08 20:03:03 -0600 (Mon, 08 Dec 2008) | 1 line
specify how things are copied
................
r67677 | benjamin.peterson | 2008-12-08 20:05:11 -0600 (Mon, 08 Dec 2008) | 1 line
revert unrelated change to installer script
................
r67681 | jeremy.hylton | 2008-12-09 15:03:10 -0600 (Tue, 09 Dec 2008) | 2 lines
Add simple unittests for Request
................
r67692 | amaury.forgeotdarc | 2008-12-10 18:03:42 -0600 (Wed, 10 Dec 2008) | 2 lines
#1030250: correctly pass the dry_run option to the mkpath() function.
................
r67725 | benjamin.peterson | 2008-12-12 22:02:20 -0600 (Fri, 12 Dec 2008) | 1 line
fix incorrect example
................
r67746 | antoine.pitrou | 2008-12-13 17:12:30 -0600 (Sat, 13 Dec 2008) | 3 lines
Issue #4163: Use unicode-friendly word splitting in the textwrap functions when given an unicode string.
................
r67748 | benjamin.peterson | 2008-12-13 19:46:11 -0600 (Sat, 13 Dec 2008) | 1 line
remove has_key usage
................
r67761 | benjamin.peterson | 2008-12-14 11:26:04 -0600 (Sun, 14 Dec 2008) | 1 line
fix missing bracket
................
r67784 | georg.brandl | 2008-12-15 02:33:58 -0600 (Mon, 15 Dec 2008) | 2 lines
#4446: document "platforms" argument for setup().
................
r67785 | georg.brandl | 2008-12-15 02:36:11 -0600 (Mon, 15 Dec 2008) | 2 lines
#4611: fix typo.
................
r67787 | georg.brandl | 2008-12-15 02:58:59 -0600 (Mon, 15 Dec 2008) | 2 lines
#4578: fix has_key() usage in compiler package.
................
r67788 | georg.brandl | 2008-12-15 03:07:39 -0600 (Mon, 15 Dec 2008) | 2 lines
#4568: remove limitation in varargs callback example.
................
r67802 | amaury.forgeotdarc | 2008-12-15 16:29:14 -0600 (Mon, 15 Dec 2008) | 4 lines
#3632: the "pyo" macro from gdbinit can now run when the GIL is released.
Patch by haypo.
................
r67832 | antoine.pitrou | 2008-12-17 16:46:54 -0600 (Wed, 17 Dec 2008) | 4 lines
Issue #2467: gc.DEBUG_STATS reports invalid elapsed times.
Patch by Neil Schemenauer, very slightly modified.
................
r67848 | benjamin.peterson | 2008-12-18 20:28:56 -0600 (Thu, 18 Dec 2008) | 1 line
fix typo
................
r67849 | benjamin.peterson | 2008-12-18 20:31:35 -0600 (Thu, 18 Dec 2008) | 1 line
_call_method -> _callmethod and _get_value to _getvalue
................
r67859 | amaury.forgeotdarc | 2008-12-19 16:56:48 -0600 (Fri, 19 Dec 2008) | 4 lines
#4700: crtlicense.txt is displayed by the license() command and should be kept ascii-only.
Will port to 3.0
................
r67862 | benjamin.peterson | 2008-12-19 20:48:02 -0600 (Fri, 19 Dec 2008) | 1 line
copy sentence from docstring
................
r67863 | benjamin.peterson | 2008-12-19 20:51:26 -0600 (Fri, 19 Dec 2008) | 1 line
add headings
................
r67864 | benjamin.peterson | 2008-12-19 20:57:19 -0600 (Fri, 19 Dec 2008) | 1 line
beef up docstring
................
r67880 | benjamin.peterson | 2008-12-20 16:49:24 -0600 (Sat, 20 Dec 2008) | 1 line
remove redundant sentence
................
r67882 | benjamin.peterson | 2008-12-20 16:59:49 -0600 (Sat, 20 Dec 2008) | 1 line
add some recent releases to the list
................
r67885 | benjamin.peterson | 2008-12-20 17:48:54 -0600 (Sat, 20 Dec 2008) | 1 line
silence annoying DeprecationWarning
................
r67889 | benjamin.peterson | 2008-12-20 19:04:32 -0600 (Sat, 20 Dec 2008) | 1 line
sphinx.web is long gone
................
r67890 | benjamin.peterson | 2008-12-20 19:12:26 -0600 (Sat, 20 Dec 2008) | 1 line
update readme
................
r67891 | benjamin.peterson | 2008-12-20 19:14:47 -0600 (Sat, 20 Dec 2008) | 1 line
there are way too many places which need to have the current version added
................
r67892 | benjamin.peterson | 2008-12-20 19:29:32 -0600 (Sat, 20 Dec 2008) | 9 lines
Merged revisions 67809 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r67809 | benjamin.peterson | 2008-12-15 21:54:45 -0600 (Mon, 15 Dec 2008) | 1 line
fix logic error
........
................
r67895 | neal.norwitz | 2008-12-21 08:28:32 -0600 (Sun, 21 Dec 2008) | 2 lines
Add Tarek for work on distutils.
................
2008-12-21 13:01:26 -04:00
|
|
|
|
|
|
|
Power and logarithmic functions
|
|
|
|
-------------------------------
|
2007-08-15 11:28:01 -03:00
|
|
|
|
|
|
|
.. function:: exp(x)
|
|
|
|
|
|
|
|
Return ``e**x``.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: log(x[, base])
|
|
|
|
|
|
|
|
Return the logarithm of *x* to the given *base*. If the *base* is not specified,
|
|
|
|
return the natural logarithm of *x* (that is, the logarithm to base *e*).
|
|
|
|
|
|
|
|
.. versionchanged:: 2.3
|
|
|
|
*base* argument added.
|
|
|
|
|
|
|
|
|
2008-04-18 20:13:07 -03:00
|
|
|
.. function:: log1p(x)
|
|
|
|
|
|
|
|
Return the natural logarithm of *1+x* (base *e*). The
|
|
|
|
result is calculated in a way which is accurate for *x* near zero.
|
|
|
|
|
|
|
|
.. versionadded:: 2.6
|
|
|
|
|
|
|
|
|
2007-08-15 11:28:01 -03:00
|
|
|
.. function:: log10(x)
|
|
|
|
|
|
|
|
Return the base-10 logarithm of *x*.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: pow(x, y)
|
|
|
|
|
2008-04-19 18:35:35 -03:00
|
|
|
Return ``x`` raised to the power ``y``. Exceptional cases follow
|
|
|
|
Annex 'F' of the C99 standard as far as possible. In particular,
|
|
|
|
``pow(1.0, x)`` and ``pow(x, 0.0)`` always return ``1.0``, even
|
|
|
|
when ``x`` is a zero or a NaN. If both ``x`` and ``y`` are finite,
|
|
|
|
``x`` is negative, and ``y`` is not an integer then ``pow(x, y)``
|
|
|
|
is undefined, and raises :exc:`ValueError`.
|
2008-04-18 20:13:07 -03:00
|
|
|
|
|
|
|
.. versionchanged:: 2.6
|
2008-04-19 18:35:35 -03:00
|
|
|
The outcome of ``1**nan`` and ``nan**0`` was undefined.
|
2007-08-15 11:28:01 -03:00
|
|
|
|
|
|
|
|
|
|
|
.. function:: sqrt(x)
|
|
|
|
|
|
|
|
Return the square root of *x*.
|
|
|
|
|
|
|
|
|
Merged revisions 67654,67676-67677,67681,67692,67725,67746,67748,67761,67784-67785,67787-67788,67802,67832,67848-67849,67859,67862-67864,67880,67882,67885,67889-67892,67895 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r67654 | georg.brandl | 2008-12-07 16:42:09 -0600 (Sun, 07 Dec 2008) | 2 lines
#4457: rewrite __import__() documentation.
................
r67676 | benjamin.peterson | 2008-12-08 20:03:03 -0600 (Mon, 08 Dec 2008) | 1 line
specify how things are copied
................
r67677 | benjamin.peterson | 2008-12-08 20:05:11 -0600 (Mon, 08 Dec 2008) | 1 line
revert unrelated change to installer script
................
r67681 | jeremy.hylton | 2008-12-09 15:03:10 -0600 (Tue, 09 Dec 2008) | 2 lines
Add simple unittests for Request
................
r67692 | amaury.forgeotdarc | 2008-12-10 18:03:42 -0600 (Wed, 10 Dec 2008) | 2 lines
#1030250: correctly pass the dry_run option to the mkpath() function.
................
r67725 | benjamin.peterson | 2008-12-12 22:02:20 -0600 (Fri, 12 Dec 2008) | 1 line
fix incorrect example
................
r67746 | antoine.pitrou | 2008-12-13 17:12:30 -0600 (Sat, 13 Dec 2008) | 3 lines
Issue #4163: Use unicode-friendly word splitting in the textwrap functions when given an unicode string.
................
r67748 | benjamin.peterson | 2008-12-13 19:46:11 -0600 (Sat, 13 Dec 2008) | 1 line
remove has_key usage
................
r67761 | benjamin.peterson | 2008-12-14 11:26:04 -0600 (Sun, 14 Dec 2008) | 1 line
fix missing bracket
................
r67784 | georg.brandl | 2008-12-15 02:33:58 -0600 (Mon, 15 Dec 2008) | 2 lines
#4446: document "platforms" argument for setup().
................
r67785 | georg.brandl | 2008-12-15 02:36:11 -0600 (Mon, 15 Dec 2008) | 2 lines
#4611: fix typo.
................
r67787 | georg.brandl | 2008-12-15 02:58:59 -0600 (Mon, 15 Dec 2008) | 2 lines
#4578: fix has_key() usage in compiler package.
................
r67788 | georg.brandl | 2008-12-15 03:07:39 -0600 (Mon, 15 Dec 2008) | 2 lines
#4568: remove limitation in varargs callback example.
................
r67802 | amaury.forgeotdarc | 2008-12-15 16:29:14 -0600 (Mon, 15 Dec 2008) | 4 lines
#3632: the "pyo" macro from gdbinit can now run when the GIL is released.
Patch by haypo.
................
r67832 | antoine.pitrou | 2008-12-17 16:46:54 -0600 (Wed, 17 Dec 2008) | 4 lines
Issue #2467: gc.DEBUG_STATS reports invalid elapsed times.
Patch by Neil Schemenauer, very slightly modified.
................
r67848 | benjamin.peterson | 2008-12-18 20:28:56 -0600 (Thu, 18 Dec 2008) | 1 line
fix typo
................
r67849 | benjamin.peterson | 2008-12-18 20:31:35 -0600 (Thu, 18 Dec 2008) | 1 line
_call_method -> _callmethod and _get_value to _getvalue
................
r67859 | amaury.forgeotdarc | 2008-12-19 16:56:48 -0600 (Fri, 19 Dec 2008) | 4 lines
#4700: crtlicense.txt is displayed by the license() command and should be kept ascii-only.
Will port to 3.0
................
r67862 | benjamin.peterson | 2008-12-19 20:48:02 -0600 (Fri, 19 Dec 2008) | 1 line
copy sentence from docstring
................
r67863 | benjamin.peterson | 2008-12-19 20:51:26 -0600 (Fri, 19 Dec 2008) | 1 line
add headings
................
r67864 | benjamin.peterson | 2008-12-19 20:57:19 -0600 (Fri, 19 Dec 2008) | 1 line
beef up docstring
................
r67880 | benjamin.peterson | 2008-12-20 16:49:24 -0600 (Sat, 20 Dec 2008) | 1 line
remove redundant sentence
................
r67882 | benjamin.peterson | 2008-12-20 16:59:49 -0600 (Sat, 20 Dec 2008) | 1 line
add some recent releases to the list
................
r67885 | benjamin.peterson | 2008-12-20 17:48:54 -0600 (Sat, 20 Dec 2008) | 1 line
silence annoying DeprecationWarning
................
r67889 | benjamin.peterson | 2008-12-20 19:04:32 -0600 (Sat, 20 Dec 2008) | 1 line
sphinx.web is long gone
................
r67890 | benjamin.peterson | 2008-12-20 19:12:26 -0600 (Sat, 20 Dec 2008) | 1 line
update readme
................
r67891 | benjamin.peterson | 2008-12-20 19:14:47 -0600 (Sat, 20 Dec 2008) | 1 line
there are way too many places which need to have the current version added
................
r67892 | benjamin.peterson | 2008-12-20 19:29:32 -0600 (Sat, 20 Dec 2008) | 9 lines
Merged revisions 67809 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r67809 | benjamin.peterson | 2008-12-15 21:54:45 -0600 (Mon, 15 Dec 2008) | 1 line
fix logic error
........
................
r67895 | neal.norwitz | 2008-12-21 08:28:32 -0600 (Sun, 21 Dec 2008) | 2 lines
Add Tarek for work on distutils.
................
2008-12-21 13:01:26 -04:00
|
|
|
Trigonometric functions
|
|
|
|
-----------------------
|
2007-08-15 11:28:01 -03:00
|
|
|
|
|
|
|
.. function:: acos(x)
|
|
|
|
|
|
|
|
Return the arc cosine of *x*, in radians.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: asin(x)
|
|
|
|
|
|
|
|
Return the arc sine of *x*, in radians.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: atan(x)
|
|
|
|
|
|
|
|
Return the arc tangent of *x*, in radians.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: atan2(y, x)
|
|
|
|
|
|
|
|
Return ``atan(y / x)``, in radians. The result is between ``-pi`` and ``pi``.
|
|
|
|
The vector in the plane from the origin to point ``(x, y)`` makes this angle
|
|
|
|
with the positive X axis. The point of :func:`atan2` is that the signs of both
|
|
|
|
inputs are known to it, so it can compute the correct quadrant for the angle.
|
|
|
|
For example, ``atan(1``) and ``atan2(1, 1)`` are both ``pi/4``, but ``atan2(-1,
|
|
|
|
-1)`` is ``-3*pi/4``.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: cos(x)
|
|
|
|
|
|
|
|
Return the cosine of *x* radians.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: hypot(x, y)
|
|
|
|
|
|
|
|
Return the Euclidean norm, ``sqrt(x*x + y*y)``. This is the length of the vector
|
|
|
|
from the origin to point ``(x, y)``.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: sin(x)
|
|
|
|
|
|
|
|
Return the sine of *x* radians.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: tan(x)
|
|
|
|
|
|
|
|
Return the tangent of *x* radians.
|
|
|
|
|
|
|
|
|
Merged revisions 67654,67676-67677,67681,67692,67725,67746,67748,67761,67784-67785,67787-67788,67802,67832,67848-67849,67859,67862-67864,67880,67882,67885,67889-67892,67895 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r67654 | georg.brandl | 2008-12-07 16:42:09 -0600 (Sun, 07 Dec 2008) | 2 lines
#4457: rewrite __import__() documentation.
................
r67676 | benjamin.peterson | 2008-12-08 20:03:03 -0600 (Mon, 08 Dec 2008) | 1 line
specify how things are copied
................
r67677 | benjamin.peterson | 2008-12-08 20:05:11 -0600 (Mon, 08 Dec 2008) | 1 line
revert unrelated change to installer script
................
r67681 | jeremy.hylton | 2008-12-09 15:03:10 -0600 (Tue, 09 Dec 2008) | 2 lines
Add simple unittests for Request
................
r67692 | amaury.forgeotdarc | 2008-12-10 18:03:42 -0600 (Wed, 10 Dec 2008) | 2 lines
#1030250: correctly pass the dry_run option to the mkpath() function.
................
r67725 | benjamin.peterson | 2008-12-12 22:02:20 -0600 (Fri, 12 Dec 2008) | 1 line
fix incorrect example
................
r67746 | antoine.pitrou | 2008-12-13 17:12:30 -0600 (Sat, 13 Dec 2008) | 3 lines
Issue #4163: Use unicode-friendly word splitting in the textwrap functions when given an unicode string.
................
r67748 | benjamin.peterson | 2008-12-13 19:46:11 -0600 (Sat, 13 Dec 2008) | 1 line
remove has_key usage
................
r67761 | benjamin.peterson | 2008-12-14 11:26:04 -0600 (Sun, 14 Dec 2008) | 1 line
fix missing bracket
................
r67784 | georg.brandl | 2008-12-15 02:33:58 -0600 (Mon, 15 Dec 2008) | 2 lines
#4446: document "platforms" argument for setup().
................
r67785 | georg.brandl | 2008-12-15 02:36:11 -0600 (Mon, 15 Dec 2008) | 2 lines
#4611: fix typo.
................
r67787 | georg.brandl | 2008-12-15 02:58:59 -0600 (Mon, 15 Dec 2008) | 2 lines
#4578: fix has_key() usage in compiler package.
................
r67788 | georg.brandl | 2008-12-15 03:07:39 -0600 (Mon, 15 Dec 2008) | 2 lines
#4568: remove limitation in varargs callback example.
................
r67802 | amaury.forgeotdarc | 2008-12-15 16:29:14 -0600 (Mon, 15 Dec 2008) | 4 lines
#3632: the "pyo" macro from gdbinit can now run when the GIL is released.
Patch by haypo.
................
r67832 | antoine.pitrou | 2008-12-17 16:46:54 -0600 (Wed, 17 Dec 2008) | 4 lines
Issue #2467: gc.DEBUG_STATS reports invalid elapsed times.
Patch by Neil Schemenauer, very slightly modified.
................
r67848 | benjamin.peterson | 2008-12-18 20:28:56 -0600 (Thu, 18 Dec 2008) | 1 line
fix typo
................
r67849 | benjamin.peterson | 2008-12-18 20:31:35 -0600 (Thu, 18 Dec 2008) | 1 line
_call_method -> _callmethod and _get_value to _getvalue
................
r67859 | amaury.forgeotdarc | 2008-12-19 16:56:48 -0600 (Fri, 19 Dec 2008) | 4 lines
#4700: crtlicense.txt is displayed by the license() command and should be kept ascii-only.
Will port to 3.0
................
r67862 | benjamin.peterson | 2008-12-19 20:48:02 -0600 (Fri, 19 Dec 2008) | 1 line
copy sentence from docstring
................
r67863 | benjamin.peterson | 2008-12-19 20:51:26 -0600 (Fri, 19 Dec 2008) | 1 line
add headings
................
r67864 | benjamin.peterson | 2008-12-19 20:57:19 -0600 (Fri, 19 Dec 2008) | 1 line
beef up docstring
................
r67880 | benjamin.peterson | 2008-12-20 16:49:24 -0600 (Sat, 20 Dec 2008) | 1 line
remove redundant sentence
................
r67882 | benjamin.peterson | 2008-12-20 16:59:49 -0600 (Sat, 20 Dec 2008) | 1 line
add some recent releases to the list
................
r67885 | benjamin.peterson | 2008-12-20 17:48:54 -0600 (Sat, 20 Dec 2008) | 1 line
silence annoying DeprecationWarning
................
r67889 | benjamin.peterson | 2008-12-20 19:04:32 -0600 (Sat, 20 Dec 2008) | 1 line
sphinx.web is long gone
................
r67890 | benjamin.peterson | 2008-12-20 19:12:26 -0600 (Sat, 20 Dec 2008) | 1 line
update readme
................
r67891 | benjamin.peterson | 2008-12-20 19:14:47 -0600 (Sat, 20 Dec 2008) | 1 line
there are way too many places which need to have the current version added
................
r67892 | benjamin.peterson | 2008-12-20 19:29:32 -0600 (Sat, 20 Dec 2008) | 9 lines
Merged revisions 67809 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r67809 | benjamin.peterson | 2008-12-15 21:54:45 -0600 (Mon, 15 Dec 2008) | 1 line
fix logic error
........
................
r67895 | neal.norwitz | 2008-12-21 08:28:32 -0600 (Sun, 21 Dec 2008) | 2 lines
Add Tarek for work on distutils.
................
2008-12-21 13:01:26 -04:00
|
|
|
Angular conversion
|
|
|
|
------------------
|
2007-08-15 11:28:01 -03:00
|
|
|
|
|
|
|
.. function:: degrees(x)
|
|
|
|
|
|
|
|
Converts angle *x* from radians to degrees.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: radians(x)
|
|
|
|
|
|
|
|
Converts angle *x* from degrees to radians.
|
|
|
|
|
|
|
|
|
Merged revisions 67654,67676-67677,67681,67692,67725,67746,67748,67761,67784-67785,67787-67788,67802,67832,67848-67849,67859,67862-67864,67880,67882,67885,67889-67892,67895 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r67654 | georg.brandl | 2008-12-07 16:42:09 -0600 (Sun, 07 Dec 2008) | 2 lines
#4457: rewrite __import__() documentation.
................
r67676 | benjamin.peterson | 2008-12-08 20:03:03 -0600 (Mon, 08 Dec 2008) | 1 line
specify how things are copied
................
r67677 | benjamin.peterson | 2008-12-08 20:05:11 -0600 (Mon, 08 Dec 2008) | 1 line
revert unrelated change to installer script
................
r67681 | jeremy.hylton | 2008-12-09 15:03:10 -0600 (Tue, 09 Dec 2008) | 2 lines
Add simple unittests for Request
................
r67692 | amaury.forgeotdarc | 2008-12-10 18:03:42 -0600 (Wed, 10 Dec 2008) | 2 lines
#1030250: correctly pass the dry_run option to the mkpath() function.
................
r67725 | benjamin.peterson | 2008-12-12 22:02:20 -0600 (Fri, 12 Dec 2008) | 1 line
fix incorrect example
................
r67746 | antoine.pitrou | 2008-12-13 17:12:30 -0600 (Sat, 13 Dec 2008) | 3 lines
Issue #4163: Use unicode-friendly word splitting in the textwrap functions when given an unicode string.
................
r67748 | benjamin.peterson | 2008-12-13 19:46:11 -0600 (Sat, 13 Dec 2008) | 1 line
remove has_key usage
................
r67761 | benjamin.peterson | 2008-12-14 11:26:04 -0600 (Sun, 14 Dec 2008) | 1 line
fix missing bracket
................
r67784 | georg.brandl | 2008-12-15 02:33:58 -0600 (Mon, 15 Dec 2008) | 2 lines
#4446: document "platforms" argument for setup().
................
r67785 | georg.brandl | 2008-12-15 02:36:11 -0600 (Mon, 15 Dec 2008) | 2 lines
#4611: fix typo.
................
r67787 | georg.brandl | 2008-12-15 02:58:59 -0600 (Mon, 15 Dec 2008) | 2 lines
#4578: fix has_key() usage in compiler package.
................
r67788 | georg.brandl | 2008-12-15 03:07:39 -0600 (Mon, 15 Dec 2008) | 2 lines
#4568: remove limitation in varargs callback example.
................
r67802 | amaury.forgeotdarc | 2008-12-15 16:29:14 -0600 (Mon, 15 Dec 2008) | 4 lines
#3632: the "pyo" macro from gdbinit can now run when the GIL is released.
Patch by haypo.
................
r67832 | antoine.pitrou | 2008-12-17 16:46:54 -0600 (Wed, 17 Dec 2008) | 4 lines
Issue #2467: gc.DEBUG_STATS reports invalid elapsed times.
Patch by Neil Schemenauer, very slightly modified.
................
r67848 | benjamin.peterson | 2008-12-18 20:28:56 -0600 (Thu, 18 Dec 2008) | 1 line
fix typo
................
r67849 | benjamin.peterson | 2008-12-18 20:31:35 -0600 (Thu, 18 Dec 2008) | 1 line
_call_method -> _callmethod and _get_value to _getvalue
................
r67859 | amaury.forgeotdarc | 2008-12-19 16:56:48 -0600 (Fri, 19 Dec 2008) | 4 lines
#4700: crtlicense.txt is displayed by the license() command and should be kept ascii-only.
Will port to 3.0
................
r67862 | benjamin.peterson | 2008-12-19 20:48:02 -0600 (Fri, 19 Dec 2008) | 1 line
copy sentence from docstring
................
r67863 | benjamin.peterson | 2008-12-19 20:51:26 -0600 (Fri, 19 Dec 2008) | 1 line
add headings
................
r67864 | benjamin.peterson | 2008-12-19 20:57:19 -0600 (Fri, 19 Dec 2008) | 1 line
beef up docstring
................
r67880 | benjamin.peterson | 2008-12-20 16:49:24 -0600 (Sat, 20 Dec 2008) | 1 line
remove redundant sentence
................
r67882 | benjamin.peterson | 2008-12-20 16:59:49 -0600 (Sat, 20 Dec 2008) | 1 line
add some recent releases to the list
................
r67885 | benjamin.peterson | 2008-12-20 17:48:54 -0600 (Sat, 20 Dec 2008) | 1 line
silence annoying DeprecationWarning
................
r67889 | benjamin.peterson | 2008-12-20 19:04:32 -0600 (Sat, 20 Dec 2008) | 1 line
sphinx.web is long gone
................
r67890 | benjamin.peterson | 2008-12-20 19:12:26 -0600 (Sat, 20 Dec 2008) | 1 line
update readme
................
r67891 | benjamin.peterson | 2008-12-20 19:14:47 -0600 (Sat, 20 Dec 2008) | 1 line
there are way too many places which need to have the current version added
................
r67892 | benjamin.peterson | 2008-12-20 19:29:32 -0600 (Sat, 20 Dec 2008) | 9 lines
Merged revisions 67809 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r67809 | benjamin.peterson | 2008-12-15 21:54:45 -0600 (Mon, 15 Dec 2008) | 1 line
fix logic error
........
................
r67895 | neal.norwitz | 2008-12-21 08:28:32 -0600 (Sun, 21 Dec 2008) | 2 lines
Add Tarek for work on distutils.
................
2008-12-21 13:01:26 -04:00
|
|
|
Hyperbolic functions
|
|
|
|
--------------------
|
2007-08-15 11:28:01 -03:00
|
|
|
|
2008-04-19 18:49:22 -03:00
|
|
|
.. function:: acosh(x)
|
2007-08-15 11:28:01 -03:00
|
|
|
|
2008-04-19 18:49:22 -03:00
|
|
|
Return the inverse hyperbolic cosine of *x*.
|
2007-08-15 11:28:01 -03:00
|
|
|
|
2008-04-19 18:49:22 -03:00
|
|
|
.. versionadded:: 2.6
|
2007-08-15 11:28:01 -03:00
|
|
|
|
2008-04-18 20:13:07 -03:00
|
|
|
|
2008-04-19 18:49:22 -03:00
|
|
|
.. function:: asinh(x)
|
|
|
|
|
|
|
|
Return the inverse hyperbolic sine of *x*.
|
2008-04-18 20:13:07 -03:00
|
|
|
|
|
|
|
.. versionadded:: 2.6
|
|
|
|
|
|
|
|
|
2008-04-19 18:49:22 -03:00
|
|
|
.. function:: atanh(x)
|
|
|
|
|
|
|
|
Return the inverse hyperbolic tangent of *x*.
|
|
|
|
|
|
|
|
.. versionadded:: 2.6
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: cosh(x)
|
|
|
|
|
|
|
|
Return the hyperbolic cosine of *x*.
|
|
|
|
|
|
|
|
|
2007-08-15 11:28:01 -03:00
|
|
|
.. function:: sinh(x)
|
|
|
|
|
|
|
|
Return the hyperbolic sine of *x*.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: tanh(x)
|
|
|
|
|
|
|
|
Return the hyperbolic tangent of *x*.
|
|
|
|
|
2008-04-18 20:13:07 -03:00
|
|
|
|
Merged revisions 67654,67676-67677,67681,67692,67725,67746,67748,67761,67784-67785,67787-67788,67802,67832,67848-67849,67859,67862-67864,67880,67882,67885,67889-67892,67895 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r67654 | georg.brandl | 2008-12-07 16:42:09 -0600 (Sun, 07 Dec 2008) | 2 lines
#4457: rewrite __import__() documentation.
................
r67676 | benjamin.peterson | 2008-12-08 20:03:03 -0600 (Mon, 08 Dec 2008) | 1 line
specify how things are copied
................
r67677 | benjamin.peterson | 2008-12-08 20:05:11 -0600 (Mon, 08 Dec 2008) | 1 line
revert unrelated change to installer script
................
r67681 | jeremy.hylton | 2008-12-09 15:03:10 -0600 (Tue, 09 Dec 2008) | 2 lines
Add simple unittests for Request
................
r67692 | amaury.forgeotdarc | 2008-12-10 18:03:42 -0600 (Wed, 10 Dec 2008) | 2 lines
#1030250: correctly pass the dry_run option to the mkpath() function.
................
r67725 | benjamin.peterson | 2008-12-12 22:02:20 -0600 (Fri, 12 Dec 2008) | 1 line
fix incorrect example
................
r67746 | antoine.pitrou | 2008-12-13 17:12:30 -0600 (Sat, 13 Dec 2008) | 3 lines
Issue #4163: Use unicode-friendly word splitting in the textwrap functions when given an unicode string.
................
r67748 | benjamin.peterson | 2008-12-13 19:46:11 -0600 (Sat, 13 Dec 2008) | 1 line
remove has_key usage
................
r67761 | benjamin.peterson | 2008-12-14 11:26:04 -0600 (Sun, 14 Dec 2008) | 1 line
fix missing bracket
................
r67784 | georg.brandl | 2008-12-15 02:33:58 -0600 (Mon, 15 Dec 2008) | 2 lines
#4446: document "platforms" argument for setup().
................
r67785 | georg.brandl | 2008-12-15 02:36:11 -0600 (Mon, 15 Dec 2008) | 2 lines
#4611: fix typo.
................
r67787 | georg.brandl | 2008-12-15 02:58:59 -0600 (Mon, 15 Dec 2008) | 2 lines
#4578: fix has_key() usage in compiler package.
................
r67788 | georg.brandl | 2008-12-15 03:07:39 -0600 (Mon, 15 Dec 2008) | 2 lines
#4568: remove limitation in varargs callback example.
................
r67802 | amaury.forgeotdarc | 2008-12-15 16:29:14 -0600 (Mon, 15 Dec 2008) | 4 lines
#3632: the "pyo" macro from gdbinit can now run when the GIL is released.
Patch by haypo.
................
r67832 | antoine.pitrou | 2008-12-17 16:46:54 -0600 (Wed, 17 Dec 2008) | 4 lines
Issue #2467: gc.DEBUG_STATS reports invalid elapsed times.
Patch by Neil Schemenauer, very slightly modified.
................
r67848 | benjamin.peterson | 2008-12-18 20:28:56 -0600 (Thu, 18 Dec 2008) | 1 line
fix typo
................
r67849 | benjamin.peterson | 2008-12-18 20:31:35 -0600 (Thu, 18 Dec 2008) | 1 line
_call_method -> _callmethod and _get_value to _getvalue
................
r67859 | amaury.forgeotdarc | 2008-12-19 16:56:48 -0600 (Fri, 19 Dec 2008) | 4 lines
#4700: crtlicense.txt is displayed by the license() command and should be kept ascii-only.
Will port to 3.0
................
r67862 | benjamin.peterson | 2008-12-19 20:48:02 -0600 (Fri, 19 Dec 2008) | 1 line
copy sentence from docstring
................
r67863 | benjamin.peterson | 2008-12-19 20:51:26 -0600 (Fri, 19 Dec 2008) | 1 line
add headings
................
r67864 | benjamin.peterson | 2008-12-19 20:57:19 -0600 (Fri, 19 Dec 2008) | 1 line
beef up docstring
................
r67880 | benjamin.peterson | 2008-12-20 16:49:24 -0600 (Sat, 20 Dec 2008) | 1 line
remove redundant sentence
................
r67882 | benjamin.peterson | 2008-12-20 16:59:49 -0600 (Sat, 20 Dec 2008) | 1 line
add some recent releases to the list
................
r67885 | benjamin.peterson | 2008-12-20 17:48:54 -0600 (Sat, 20 Dec 2008) | 1 line
silence annoying DeprecationWarning
................
r67889 | benjamin.peterson | 2008-12-20 19:04:32 -0600 (Sat, 20 Dec 2008) | 1 line
sphinx.web is long gone
................
r67890 | benjamin.peterson | 2008-12-20 19:12:26 -0600 (Sat, 20 Dec 2008) | 1 line
update readme
................
r67891 | benjamin.peterson | 2008-12-20 19:14:47 -0600 (Sat, 20 Dec 2008) | 1 line
there are way too many places which need to have the current version added
................
r67892 | benjamin.peterson | 2008-12-20 19:29:32 -0600 (Sat, 20 Dec 2008) | 9 lines
Merged revisions 67809 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r67809 | benjamin.peterson | 2008-12-15 21:54:45 -0600 (Mon, 15 Dec 2008) | 1 line
fix logic error
........
................
r67895 | neal.norwitz | 2008-12-21 08:28:32 -0600 (Sun, 21 Dec 2008) | 2 lines
Add Tarek for work on distutils.
................
2008-12-21 13:01:26 -04:00
|
|
|
Constants
|
|
|
|
---------
|
2007-08-15 11:28:01 -03:00
|
|
|
|
|
|
|
.. data:: pi
|
|
|
|
|
|
|
|
The mathematical constant *pi*.
|
|
|
|
|
|
|
|
|
|
|
|
.. data:: e
|
|
|
|
|
|
|
|
The mathematical constant *e*.
|
|
|
|
|
2008-04-18 20:13:07 -03:00
|
|
|
|
2007-08-15 11:28:01 -03:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
The :mod:`math` module consists mostly of thin wrappers around the platform C
|
|
|
|
math library functions. Behavior in exceptional cases is loosely specified
|
|
|
|
by the C standards, and Python inherits much of its math-function
|
|
|
|
error-reporting behavior from the platform C implementation. As a result,
|
|
|
|
the specific exceptions raised in error cases (and even whether some
|
|
|
|
arguments are considered to be exceptional at all) are not defined in any
|
|
|
|
useful cross-platform or cross-release way. For example, whether
|
|
|
|
``math.log(0)`` returns ``-Inf`` or raises :exc:`ValueError` or
|
|
|
|
:exc:`OverflowError` isn't defined, and in cases where ``math.log(0)`` raises
|
|
|
|
:exc:`OverflowError`, ``math.log(0L)`` may raise :exc:`ValueError` instead.
|
|
|
|
|
2008-04-19 18:35:35 -03:00
|
|
|
All functions return a quiet *NaN* if at least one of the args is *NaN*.
|
2008-08-30 19:00:28 -03:00
|
|
|
Signaling *NaN*\s raise an exception. The exception type still depends on the
|
2008-04-18 20:13:07 -03:00
|
|
|
platform and libm implementation. It's usually :exc:`ValueError` for *EDOM*
|
|
|
|
and :exc:`OverflowError` for errno *ERANGE*.
|
|
|
|
|
2008-05-12 14:43:13 -03:00
|
|
|
.. versionchanged:: 2.6
|
2008-04-18 20:13:07 -03:00
|
|
|
In earlier versions of Python the outcome of an operation with NaN as
|
|
|
|
input depended on platform and libm implementation.
|
|
|
|
|
2007-08-15 11:28:01 -03:00
|
|
|
|
|
|
|
.. seealso::
|
|
|
|
|
|
|
|
Module :mod:`cmath`
|
|
|
|
Complex number versions of many of these functions.
|