expint

Exponential integral function

Description

example

expint(x) returns the one-argument exponential integral function defined as

expint(x)=1exttdt.

example

expint(n,x) returns the two-argument exponential integral function defined as

expint(n,x)=1exttndt.

Examples

One-Argument Exponential Integral for Floating-Point and Symbolic Numbers

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]

Two-Argument Exponential Integral for Floating-Point and Symbolic Numbers

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]

Two-Argument Exponential Integral with Nonpositive First Argument

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)

Derivatives of Exponential Integral

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))

Input Arguments

collapse all

Input specified as a symbolic number, variable, expression, function, vector, or matrix.

Input specified as a symbolic number, variable, expression, function, vector, or matrix. When you compute the two-argument exponential integral function, at least one argument must be a scalar.

Tips

  • 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 x, expint(x) = -ei(-x). For negative 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.

Algorithms

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)

See Also

| |

Introduced in R2013a