scipy.special.expi#

scipy.special.expi(x, out=None) = <ufunc 'expi'>#

Exponential integral Ei.

For real \(x\), the exponential integral is defined as [1]

\[Ei(x) = \int_{-\infty}^x \frac{e^t}{t} dt.\]

For \(x > 0\) the integral is understood as a Cauchy principal value.

It is extended to the complex plane by analytic continuation of the function on the interval \((0, \infty)\). The complex variant has a branch cut on the negative real axis.

Parameters:
xarray_like

Real or complex valued argument

outndarray, optional

Optional output array for the function results

Returns:
scalar or ndarray

Values of the exponential integral

See also

exp1

Exponential integral \(E_1\)

expn

Generalized exponential integral \(E_n\)

Notes

The exponential integrals \(E_1\) and \(Ei\) satisfy the relation

\[E_1(x) = -Ei(-x)\]

for \(x > 0\).

Array API Standard Support

expi has support for Python Array API Standard compatible backends in addition to NumPy. The following combinations of backend and device (or other capability) are supported.

Library

CPU

GPU

NumPy

n/a

CuPy

n/a

PyTorch

JAX

Dask

n/a

For the NumPy backend, this function supports all NumPy ufunc keyword arguments. Other backends may support out, but none of the other ufunc kwargs. out is typically supported for CuPy and PyTorch, but not currently in cases where SciPy relies on a generic Array API implementation or, for PyTorch on CPU, falls back to the NumPy backend. out is never supported for JAX because JAX arrays are immutable. expi does not currently support out for the PyTorch backend.

See Support for the array API standard for more information.

References

[1]

Digital Library of Mathematical Functions, 6.2.5 https://dlmf.nist.gov/6.2#E5

Examples

>>> import numpy as np
>>> import scipy.special as sc

It is related to exp1.

>>> x = np.array([1, 2, 3, 4])
>>> -sc.expi(-x)
array([0.21938393, 0.04890051, 0.01304838, 0.00377935])
>>> sc.exp1(x)
array([0.21938393, 0.04890051, 0.01304838, 0.00377935])

The complex variant has a branch cut on the negative real axis.

>>> sc.expi(-1 + 1e-12j)
(-0.21938393439552062+3.1415926535894254j)
>>> sc.expi(-1 - 1e-12j)
(-0.21938393439552062-3.1415926535894254j)

As the complex variant approaches the branch cut, the real parts approach the value of the real variant.

>>> sc.expi(-1)
-0.21938393439552062

The SciPy implementation returns the real variant for complex values on the branch cut.

>>> sc.expi(complex(-1, 0.0))
(-0.21938393439552062-0j)
>>> sc.expi(complex(-1, -0.0))
(-0.21938393439552062-0j)