TITLE: Efficiently calculating the logarithmic integral with complex argument
QUESTION [5 upvotes]: My number theory library of choice doesn't implement the logarithmic integral for complex values.  I thought that I might take a crack at coding it, but I thought I'd ask here first for algorithmic advice and/or references.  I'm sure there are better methods than naively calculating the integral.

REPLY [10 votes]: For this answer, I'm assuming the definition
$$\mathrm{li}(z):=\mathrm{PV}\int_0^z\frac{\mathrm{d}u}{\ln\;u}$$
where we assume the Cauchy principal value (the more common definition in number theory that has a lower limit of 2 differs merely by a constant).
Well, the first thing you have to note is the identity
$$\mathrm{li}(z)=\mathrm{Ei}(\ln\;z)$$
where $\mathrm{Ei}(z)$ is an exponential integral. (Again, I repeat my advice to people who encounter strange functions: you would really do well to check the DLMF first for identities and references.)
Now, $\mathrm{Ei}(z)$ is a slightly more tractable beastie to numerically evaluate, since the singularity at $z=0$ can be confined to a logarithmic part; to wit:
$\mathrm{Ei}(z)=\gamma+\ln\;z+\int_0^z \frac{\exp(u)-1}{u}\mathrm{d}u$
where the last portion is an entire function.
Now, depending on which of the left or right half-planes should the exponential integral be evaluated, your strategy will differ (it is a common fact that most special function routines are polyalgorithms, since their behavior can markedly differ in different regions of the complex plane). I will be vague for the rest of this answer since you did not clarify your region of interest. Suffice it to say that one usually uses a continued fraction for arguments in the left half-plane, a power series for small to medium-sized arguments, and asymptotic expansions for large arguments.
If implementing it yourself is starting to sound daunting (because it is), I will have to point out this paper and the corresponding FORTRAN subroutine.
Hope this helps a bit.