Exponential, Logarithmic, Sine, and Cosine Integrals

by Pavel Holoborodko on November 22, 2011

The Multiprecision Computing Toolbox version 3.1.6 introduces multiple new routines for computing special functions in arbitrary precision:

expint(z, n)    % Exponential Integral, En(z)
eint(x)         % Exponential Integral (in terms of Cauchy principal value)
logint(x)       % Logarithmic Integral
cosint(z)       % Cosine Integral
sinint(z)       % Sine Integral
chint(z)        % Hyperbolic Cosine Integral
shint(z)        % Hyperbolic Sine Integral

The specific details of the implementation are given below.

Exponential Integrals

expint(z [,n]) computes the generalized exponential integral defined by

    \begin{align*} \mathop{E_{n}\/}\nolimits\!\left(z\right)=\int_{1}^{{\infty}}\frac{e^{{-z\,t}}}{t^n}dt = z^{(n-1)}\int_{z}^{{\infty}}\frac{e^{{-t}}}{t^n}dt, & \qquad [n=0,1,2,\dots;\,\Re(z) > 0] \\ \end{align*}

If no n is supplied, the routine computes E_{1} by default (to match MATLAB’s built-in expint):

    \begin{align*} \mathop{E_{1}\/}\nolimits\!\left(z\right)=\int_{z}^{{\infty}}\frac{e^{{-t}}}{t}dt, & \qquad |{\rm arg}(z)|<\pi \\ \end{align*}

eint(x) gives the exponential integral in terms of the Cauchy principal value

    \[ \mathop{\mathrm{Ei}\/}\nolimits\!\left(x\right)=-\,\dashint_{{-x}}^{{\infty}}\frac{e^{{-t}}}{t}dt=\dashint_{{-\infty}}^{{x}}\frac{e^{{t}}}{t}dt, \qquad (x > 0) \]

Logarithmic Integral

The function logint(x) calculates the logarithmic integral related to \mathop{\mathrm{Ei}\/}\nolimits\!\left(x\right) as

    \[ \mathop{\mathrm{li}\/}\nolimits\!\left(x\right)=\dashint_{{0}}^{{x}}\frac{dt}{\mathop{\ln\/}\nolimits t}=\mathop{\mathrm{Ei}\/}\nolimits\!\left(\mathop{\ln\/}\nolimits x\right), \qquad (x > 1) \]

Sine and Cosine Integrals

cosint(z), sinint(z) compute the trigonometric integrals defined by

    \begin{align*} \mathop{\mathrm{Si}\/}\nolimits\!\left(z\right)&=\int _{0}^{z}\frac{\mathop{\sin\/}\nolimits t}{t}dt \\ \mathop{\mathrm{Ci}\/}\nolimits\!\left(z\right)&=\mathop{\ln\/}\nolimits z+\gamma+\int _{0}^{z}\frac{\mathop{\cos\/}\nolimits t-1}{t}dt \qquad |{\rm arg}(z)|<\pi\\ \end{align*}

chint(z), shint(z) provide hyperbolic analogs

    \begin{align*} \mathop{\mathrm{Shi}\/}\nolimits\!\left(z\right)&=\int _{0}^{z}\frac{\mathop{\sinh\/}\nolimits t}{t}dt \\ \mathop{\mathrm{Chi}\/}\nolimits\!\left(z\right)&=\mathop{\ln\/}\nolimits z+\gamma+\int _{0}^{z}\frac{\mathop{\cosh\/}\nolimits t-1}{t}dt \qquad |{\rm arg}(z)|<\pi \end{align*}


All of the new functions are implemented using convergent series for small arguments. Continued fractions are used to evaluate the functions for larger arguments (by Lentz’s algorithm). As a result, computations are fast and stable, even for extremely large operands:

>> mp.Digits(50);
>> format short g
>> expint(mp('(1-i)*10^6'))
2.1210911712154725095282810380420777177470925995558e-434301 + 
>> tic; expint(mp('(1-i)*10^6')); toc;
Elapsed time is 0.002218 seconds.

The implementation of the hyperbolic integrals chint(z), shint(z) is only preliminary, they have not been finalized yet. Please note that at this time they can be unstable.

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: