Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Doc/library/math.rst

    r2 r391  
    66   :synopsis: Mathematical functions (sin() etc.).
    77
     8.. testsetup::
     9
     10   from math import fsum
    811
    912This module is always available.  It provides access to the mathematical
     
    3437.. function:: copysign(x, y)
    3538
    36    Return *x* with the sign of *y*. ``copysign`` copies the sign bit of an IEEE
    37    754 float, ``copysign(1, -0.0)`` returns *-1.0*.
     39   Return *x* with the sign of *y*.  On a platform that supports
     40   signed zeros, ``copysign(1.0, -0.0)`` returns *-1.0*.
    3841
    3942   .. versionadded:: 2.6
     
    5760   Return the floor of *x* as a float, the largest integer value less than or equal
    5861   to *x*.
    59 
    60    .. versionchanged:: 2.6
    61       Added :meth:`__floor__` delegation.
    6262
    6363
     
    9191
    9292        >>> sum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1])
    93         0.99999999999999989
     93        0.9999999999999999
    9494        >>> fsum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1])
    9595        1.0
     
    110110.. function:: isinf(x)
    111111
    112    Checks if the float *x* is positive or negative infinite.
     112   Check if the float *x* is positive or negative infinity.
    113113
    114114   .. versionadded:: 2.6
     
    117117.. function:: isnan(x)
    118118
    119    Checks if the float *x* is a NaN (not a number). NaNs are part of the
    120    IEEE 754 standards. Operation like but not limited to ``inf * 0``,
    121    ``inf / inf`` or any operation involving a NaN, e.g. ``nan * 1``, return
    122    a NaN.
     119   Check if the float *x* is a NaN (not a number).  For more information
     120   on NaNs, see the IEEE 754 standards.
    123121
    124122   .. versionadded:: 2.6
     
    139137.. function:: trunc(x)
    140138
    141    Return the :class:`Real` value *x* truncated to an :class:`Integral` (usually
    142    a long integer). Delegates to ``x.__trunc__()``.
     139   Return the :class:`~numbers.Real` value *x* truncated to an
     140   :class:`~numbers.Integral` (usually a long integer).  Uses the
     141   ``__trunc__`` method.
    143142
    144143   .. versionadded:: 2.6
     
    163162
    164163   Return ``e**x``.
     164
     165
     166.. function:: expm1(x)
     167
     168   Return ``e**x - 1``.  For small floats *x*, the subtraction in
     169   ``exp(x) - 1`` can result in a significant loss of precision; the
     170   :func:`expm1` function provides a way to compute this quantity to
     171   full precision::
     172
     173      >>> from math import exp, expm1
     174      >>> exp(1e-5) - 1  # gives result accurate to 11 places
     175      1.0000050000069649e-05
     176      >>> expm1(1e-5)    # result accurate to full precision
     177      1.0000050000166668e-05
     178
     179   .. versionadded:: 2.7
    165180
    166181
     
    199214   is undefined, and raises :exc:`ValueError`.
    200215
     216   Unlike the built-in ``**`` operator, :func:`math.pow` converts both
     217   its arguments to type :class:`float`.  Use ``**`` or the built-in
     218   :func:`pow` function for computing exact integer powers.
     219
    201220   .. versionchanged:: 2.6
    202221      The outcome of ``1**nan`` and ``nan**0`` was undefined.
     
    232251   with the positive X axis. The point of :func:`atan2` is that the signs of both
    233252   inputs are known to it, so it can compute the correct quadrant for the angle.
    234    For example, ``atan(1``) and ``atan2(1, 1)`` are both ``pi/4``, but ``atan2(-1,
     253   For example, ``atan(1)`` and ``atan2(1, 1)`` are both ``pi/4``, but ``atan2(-1,
    235254   -1)`` is ``-3*pi/4``.
    236255
     
    309328
    310329
     330Special functions
     331-----------------
     332
     333.. function:: erf(x)
     334
     335   Return the error function at *x*.
     336
     337   .. versionadded:: 2.7
     338
     339
     340.. function:: erfc(x)
     341
     342   Return the complementary error function at *x*.
     343
     344   .. versionadded:: 2.7
     345
     346
     347.. function:: gamma(x)
     348
     349   Return the Gamma function at *x*.
     350
     351   .. versionadded:: 2.7
     352
     353
     354.. function:: lgamma(x)
     355
     356   Return the natural logarithm of the absolute value of the Gamma
     357   function at *x*.
     358
     359   .. versionadded:: 2.7
     360
     361
    311362Constants
    312363---------
     
    314365.. data:: pi
    315366
    316    The mathematical constant *pi*.
     367   The mathematical constant π = 3.141592..., to available precision.
    317368
    318369
    319370.. data:: e
    320371
    321    The mathematical constant *e*.
     372   The mathematical constant e = 2.718281..., to available precision.
    322373
    323374
     
    325376
    326377   The :mod:`math` module consists mostly of thin wrappers around the platform C
    327    math library functions.  Behavior in exceptional cases is loosely specified
    328    by the C standards, and Python inherits much of its math-function
    329    error-reporting behavior from the platform C implementation.  As a result,
    330    the specific exceptions raised in error cases (and even whether some
    331    arguments are considered to be exceptional at all) are not defined in any
    332    useful cross-platform or cross-release way.  For example, whether
    333    ``math.log(0)`` returns ``-Inf`` or raises :exc:`ValueError` or
    334    :exc:`OverflowError` isn't defined, and in cases where ``math.log(0)`` raises
    335    :exc:`OverflowError`, ``math.log(0L)`` may raise :exc:`ValueError` instead.
    336 
    337    All functions return a quiet *NaN* if at least one of the args is *NaN*.
    338    Signaling *NaN*\s raise an exception. The exception type still depends on the
    339    platform and libm implementation. It's usually :exc:`ValueError` for *EDOM*
    340    and :exc:`OverflowError` for errno *ERANGE*.
     378   math library functions.  Behavior in exceptional cases follows Annex F of
     379   the C99 standard where appropriate.  The current implementation will raise
     380   :exc:`ValueError` for invalid operations like ``sqrt(-1.0)`` or ``log(0.0)``
     381   (where C99 Annex F recommends signaling invalid operation or divide-by-zero),
     382   and :exc:`OverflowError` for results that overflow (for example,
     383   ``exp(1000.0)``).  A NaN will not be returned from any of the functions
     384   above unless one or more of the input arguments was a NaN; in that case,
     385   most functions will return a NaN, but (again following C99 Annex F) there
     386   are some exceptions to this rule, for example ``pow(float('nan'), 0.0)`` or
     387   ``hypot(float('nan'), float('inf'))``.
     388
     389   Note that Python makes no effort to distinguish signaling NaNs from
     390   quiet NaNs, and behavior for signaling NaNs remains unspecified.
     391   Typical behavior is to treat all NaNs as though they were quiet.
    341392
    342393   .. versionchanged:: 2.6
    343       In earlier versions of Python the outcome of an operation with NaN as
    344       input depended on platform and libm implementation.
     394      Behavior in special cases now aims to follow C99 Annex F.  In earlier
     395      versions of Python the behavior in special cases was loosely specified.
    345396
    346397
Note: See TracChangeset for help on using the changeset viewer.