# How to approximate $\text{li}(z)$ numerically?

I'm trying to implement a function to calculate $\pi(x)$ via Riemann's formula: $$\pi(x) = \operatorname{R}(x^1) - \sum_{\rho}\operatorname{R}(x^{\rho}) - \frac1{\ln x} + \frac1\pi \arctan \frac\pi{\ln x} ,$$ with $\operatorname{R}(x) = \sum_{n=1}^{\infty} \frac{ \mu (n)}{n} \operatorname{li}(x^{1/n})$, the sum runs over the non-trivial roots of $\zeta$ and $\text{li}(z)$ being the logarithmic integral.

The problem is that I don't have function to calculate $\text{li}(z)$. Since I'm not familiar with complex limits I'm not sure if I can write it as a simple sum.

Thanks for your help,

BTW, my result for $x=100,n_{max}=1$ and only one root of $\zeta$ is $30.2748$. Can anyone crosscheck that?

-
Can't you use the exponentially converging series by Ramanuajan mentioned in the article to approximate li$(x)$? – user17762 Jan 9 '13 at 21:15
I guess, you only need it for real $x$? – user17762 Jan 9 '13 at 21:24
@Marvis No $z=x^{1/2 + it_k}$... – draks ... Jan 9 '13 at 21:25
Oh ok. I didn't see you wanted $R(x^{\rho})$. – user17762 Jan 9 '13 at 21:27
I should have an idea about this from your stated purpose, but how accurately do you need to compute this? – Ron Gordon Jan 9 '13 at 22:02

## 1 Answer

Ok I found this very nice paper:

$\phantom{somespace}$On the Evaluation of the Complex-ValuedExponential Integral

by Vincent Pegoraro and Philipp Slusallek Saarland University:

Abstract. Although its applications span a broad scope of scientific fields ranging from applied physics to computer graphics, the exponential integral is a nonelementary special function available in specialized software packages but not in standard libraries, consequently requiring custom implementations on most platforms. In this paper, we provide a concise and comprehensive description of how to evaluate the complex-valued exponential integral. We first introduce some theoretical background on the main characteristics of the function, and outline available third-party proprietary implementations. We then provide an analysis of the various known representations of the function and present an effective algorithm allowing the computation of results within a desired accuracy, together with the corresponding pseudocode in order to facilitate portability onto various systems. An application to the calculation of the closed-form solution to single light scattering in homogeneous participating media illustrates the practical benefits of the provided implementation with the hope that, in the long term, the latter will contribute to standardizing the availability of the complex-valued exponential integral on graphics platforms. CCS: G.1.2 [Numerical Analysis]: Approximation – Special function approximations

They put pseudocodes for all approximations there, which are really close to an implementation.

-