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 exprel - module scipy.special

Signature de la fonction exprel

Description

exprel.__doc__

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

exprel(x)

Relative error exponential, ``(exp(x) - 1)/x``.

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.
``exprel(x)`` is implemented to avoid the loss of precision that occurs when
`x` is near zero.

Parameters
----------
x : ndarray
    Input array.  `x` must contain real numbers.

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

See Also
--------
expm1

Notes
-----
.. versionadded:: 0.17.0

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

>>> exprel(0.01)
1.0050167084168056
>>> exprel([-0.25, -0.1, 0, 0.1, 0.25])
array([ 0.88479687,  0.95162582,  1.        ,  1.05170918,  1.13610167])

Compare ``exprel(5e-9)`` to the naive calculation.  The exact value
is ``1.00000000250000000416...``.

>>> exprel(5e-9)
1.0000000025

>>> (np.exp(5e-9) - 1)/5e-9
0.99999999392252903