expint
Exponential integral function
Syntax
Description
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 valuesx
,expint(x)
returns-ei(-x)
. For negative valuesx
, 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]
Usevpa
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]
Usevpa
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. Ifn
is a nonpositive integer, thenexpint(n, x)
returns an explicit expression in the formexp(-x)*p(1/x)
, wherep
is a polynomial of degree1 - 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
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, usesym
to convert the numbers to symbolic objects, and then callexpint
for those symbolic objects. You can approximate the results with floating-point numbers usingvpa
.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 realx
,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)
标量扩展成一个向量或矩阵same size as the other argument with all elements equal to that scalar.
Algorithms
The relation betweenexpint
andei
is
expint(1,-x) = ei(x) + (ln(x)-ln(1/x))/2 - ln(-x)
Both functionsei (x)
andexpint(1,x)
have a logarithmic singularity at the origin and a branch cut along the negative real axis. Theei
function is not continuous when approached from above or below this branch cut.
Theexpint
function is related to the upper incomplete gamma functionigamma
as
expint(n,x) = (x^(n-1))*igamma(1-n,x)