expint: Exponential and Logarithmic Integral In pracma: Practical Numerical Math Functions

Description

The exponential integral functions E1 and Ei and the logarithmic integral Li.

The exponential integral is defined for x > 0 as

\int_x^∞ \frac{e^{-t}}{t} dt

and by analytic continuation in the complex plane. It can also be defined as the Cauchy principal value of the integral

\int_{-∞}^x \frac{e^t}{t} dt

This is denoted as Ei(x) and the relationship between Ei and expint(x) for x real, x > 0 is as follows:

Ei(x) = - E1(-x) -i π

The logarithmic integral li(x) for real x, x > 0, is defined as

li(x) = \int_0^x \frac{dt}{log(t)}

and the Eulerian logarithmic integral as Li(x) = li(x) - li(2).

The integral Li approximates the prime number function π(n), i.e., the number of primes below or equal to n (see the examples).

Usage

 1 2 3 4 5 expint(x) expint_E1(x) expint_Ei(x) li(x)

Arguments

 x vector of real or complex numbers.

Details

For x in [-38, 2] we use a series expansion, otherwise a continued fraction, see the references below, chapter 5.

Value

Returns a vector of real or complex numbers, the vectorized exponential integral, resp. the logarithmic integral.

Note

The logarithmic integral li(10^i)-li(2) is an approximation of the number of primes below 10^i, i.e., Pi(10^i), see “?primes”.

References

Abramowitz, M., and I.A. Stegun (1965). Handbook of Mathematical Functions. Dover Publications, New York.

Examples

 1 2 3 4 5 6 7 8 9 10 11 expint_E1(1:10) # 0.2193839 0.0489005 0.0130484 0.0037794 0.0011483 # 0.0003601 0.0001155 0.0000377 0.0000124 0.0000042 expint_Ei(1:10) ## Not run: estimPi <- function(n) round(Re(li(n) - li(2))) # estimated number of primes primesPi <- function(n) length(primes(n)) # true number of primes <= n N <- 1e6 (estimPi(N) - primesPi(N)) / estimPi(N) # deviation is 0.16 percent! ## End(Not run)

Example output

 2.193839e-01 4.890051e-02 1.304838e-02 3.779352e-03 1.148296e-03
 3.600825e-04 1.154817e-04 3.766562e-05 1.244735e-05 4.156969e-06
    1.895118    4.954234    9.933833   19.630874   40.185275   85.989762
  191.504743  440.379900 1037.878291 2492.228976
 0.001640658

pracma documentation built on Dec. 11, 2021, 9:57 a.m.