Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Module « scipy.special »

Fonction expm1 - module scipy.special

Signature de la fonction expm1

Description

expm1.__doc__

expm1(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])

expm1(x)

Compute ``exp(x) - 1``.

When `x` is near zero, ``exp(x)`` is near 1, so the numerical calculation
of ``exp(x) - 1`` can suffer from catastrophic loss of precision.
``expm1(x)`` is implemented to avoid the loss of precision that occurs when
`x` is near zero.

Parameters
----------
x : array_like
    `x` must contain real numbers.

Returns
-------
float
    ``exp(x) - 1`` computed element-wise.

Examples
--------
>>> from scipy.special import expm1

>>> expm1(1.0)
1.7182818284590451
>>> expm1([-0.2, -0.1, 0, 0.1, 0.2])
array([-0.18126925, -0.09516258,  0.        ,  0.10517092,  0.22140276])

The exact value of ``exp(7.5e-13) - 1`` is::

    7.5000000000028125000000007031250000001318...*10**-13.

Here is what ``expm1(7.5e-13)`` gives:

>>> expm1(7.5e-13)
7.5000000000028135e-13

Compare that to ``exp(7.5e-13) - 1``, where the subtraction results in
a "catastrophic" loss of precision:

>>> np.exp(7.5e-13) - 1
7.5006667543675576e-13