Exponential integral function
Compute the exponential integrals for floating-point numbers. Because these numbers are not symbolic objects, you get floating-point results.
s = [expint(1/3), expint(1), expint(-2)]
s = 0.8289 + 0.0000i 0.2194 + 0.0000i -4.9542 - 3.1416i
Compute the exponential integrals for the same numbers converted
to symbolic objects. For positive values x
, expint(x)
returns -ei(-x)
.
For negative values x
, it returns -pi*i
- ei(-x)
.
s = [expint(sym(1)/3), expint(sym(1)), expint(sym(-2))]
s = [ -ei(-1/3), -ei(-1), - ei(2) - pi*1i]
Use vpa
to approximate this result with
10-digit accuracy.
vpa(s, 10)
ans = [ 0.8288877453, 0.2193839344, - 4.954234356 - 3.141592654i]
When computing two-argument exponential integrals, convert the numbers to symbolic objects.
s = [expint(2, sym(1)/3), expint(sym(1), Inf), expint(-1, sym(-2))]
s = [ expint(2, 1/3), 0, -exp(2)/4]
Use vpa
to approximate this result with 25-digit
accuracy.
vpa(s, 25)
ans = [ 0.4402353954575937050522018, 0, -1.847264024732662556807607]
Compute two-argument exponential integrals.
If n
is a nonpositive integer, then expint(n,
x)
returns an explicit expression in the form exp(-x)*p(1/x)
,
where p
is a polynomial of degree 1 -
n
.
syms x expint(0, x) expint(-1, x) expint(-2, x)
ans = exp(-x)/x ans = exp(-x)*(1/x + 1/x^2) ans = exp(-x)*(1/x + 2/x^2 + 2/x^3)
Compute the first, second, and third derivatives of a one-argument exponential integral.
syms x diff(expint(x), x) diff(expint(x), x, 2) diff(expint(x), x, 3)
ans = -exp(-x)/x ans = exp(-x)/x + exp(-x)/x^2 ans = - exp(-x)/x - (2*exp(-x))/x^2 - (2*exp(-x))/x^3
Compute the first derivatives of a two-argument exponential integral.
syms n x diff(expint(n, x), x) diff(expint(n, x), n)
ans = -expint(n - 1, x) ans = - hypergeom([1 - n, 1 - n], [2 - n, 2 - n],... -x)/(n - 1)^2 - (x^(n - 1)*pi*(psi(n) - ... log(x) + pi*cot(pi*n)))/(sin(pi*n)*gamma(n))
Calling expint
for numbers that
are not symbolic objects invokes the MATLAB® expint
function. This function accepts
one argument only. To compute the two-argument exponential integral,
use sym
to convert the numbers
to symbolic objects, and then call expint
for those
symbolic objects. You can approximate the results with floating-point
numbers using vpa
.
The following values of the exponential integral differ
from those returned by the MATLAB expint
function: expint(sym(Inf))
= 0
, expint(-sym(Inf)) = -Inf
, expint(sym(NaN))
= NaN
.
For positive real x
, expint(x) = -ei(-x)
.
For negative real x
, expint(x) = -pi*i -
ei(-x)
.
If one input argument is a scalar and the other argument
is a vector or a matrix, then expint(n,x)
expands
the scalar into a vector or matrix of the same size as the other argument
with all elements equal to that scalar.
The relation between expint
and ei
is
expint(1,-x) = ei(x) + (ln(x)-ln(1/x))/2 - ln(-x)
Both functions ei(x)
and expint(1,x)
have
a logarithmic singularity at the origin and a branch cut along the
negative real axis. The ei
function is not continuous
when approached from above or below this branch cut.
The expint
function is related to the upper
incomplete gamma function igamma
as
expint(n,x) = (x^(n-1))*igamma(1-n,x)