#### algorithm of ei (9.2.96)

I would like to calculate Ei (Exponential Integral) function with complex argument in my
programming. Neither IMSL subroutine nor Numerical Recipes subroutines can do the job.
It seems only Maple can do the job. But I don’t know the algorithm of calculating Ei in
Maple.

Maple calculates the n’th exponential integral (which it denotes Ei(n,x)) using one of several
algorithms, depending on the value of n, the location of x in the complex plane and the precision
required (the value of Digits).

The algorithms used (listed in the order in which they are considered) are:

- asymptotic series (A&S 5.1.51)
- Taylor series expansion centred at Re(x)
- continued fraction expansion (A&S 5.1.22)
- Taylor series expansion centred at 0 (A&S 5.1.11/12)

("A&S" = Abramowitz and Stegun). The Cauchy Principal Value function, usually denoted by Ei, and
obtained in Maple as Ei(x), is deﬁned (in Maple) only for real arguments x.

For more detailed information, you can look at the code directly, by readlib’ing and then print’ing any or
all of the following routines:

evalf/Ei
evalf/Ei/{real,complex,asympt,taylory,confrac,taylor}

You can list many Maple procedures (though not their comments) using interface(verboseproc = 2).
Under Maple version 3, the work is done in evalf/Ei/complex. This program prints that procedure,
which I’ll let you decipher. The code is copyrighted.

interface(verboseproc = 2);
readlib(Ei); # See Ei procedure
printlevel := 25;
Ei(5, 10 + 8.9*I); # Calls evalf/Ei/complex
print(`evalf/Ei/complex`);
\begin{Verbatim}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{\href{mailto:israel@math.ubc.ca}{Robert Israel }(21.2.96)}
Well, since most of Maple's code is available, you can
find out for yourself. The following should do it:
\begin{Verbatim}
> interface(verboseproc=2);
> readlib(`evalf/Ei/complex`);

(and then look at the various procedures that this one calls). Good luck in trying to sort it out (there
are no comments).