scipy.special.expn#

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

Generalized exponential integral En.

For integer \(n \geq 0\) and real \(x \geq 0\) the generalized exponential integral is defined as [DLMF]

\[E_n(x) = x^{n - 1} \int_x^\infty \frac{e^{-t}}{t^n} dt.\]
Parameters:
narray_like

Non-negative integers

xarray_like

Real argument

outndarray, optional

Optional output array for the function results

Returns:
scalar or ndarray

Values of the generalized exponential integral

See also

exp1

special case of \(E_n\) for \(n = 1\)

expi

related to \(E_n\) when \(n = 1\)

Notes

Array API Standard Support

expn 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. expn does not currently support out for the PyTorch backend.

See Support for the array API standard for more information.

References

[DLMF]

Digital Library of Mathematical Functions, 8.19.2 https://dlmf.nist.gov/8.19#E2

Examples

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

Its domain is nonnegative n and x.

>>> sc.expn(-1, 1.0), sc.expn(1, -1.0)
(nan, nan)

It has a pole at x = 0 for n = 1, 2; for larger n it is equal to 1 / (n - 1).

>>> sc.expn([0, 1, 2, 3, 4], 0)
array([       inf,        inf, 1.        , 0.5       , 0.33333333])

For n equal to 0 it reduces to exp(-x) / x.

>>> x = np.array([1, 2, 3, 4])
>>> sc.expn(0, x)
array([0.36787944, 0.06766764, 0.01659569, 0.00457891])
>>> np.exp(-x) / x
array([0.36787944, 0.06766764, 0.01659569, 0.00457891])

For n equal to 1 it reduces to exp1.

>>> sc.expn(1, x)
array([0.21938393, 0.04890051, 0.01304838, 0.00377935])
>>> sc.exp1(x)
array([0.21938393, 0.04890051, 0.01304838, 0.00377935])