I am trying to write a program in JAVA to find the values of $li(x)$, but I do not understand how to compute $li(x)$ when $x > 1$.
For the sake of this question, let’s make $x = 2$, as this will allow for similarity in the answers.
Any manner of solution is appreciated, however, preferably none of the steps involved in finding the solution can use anything infinite (infinity, infinite summation, infinite series, limits, etc.) as they cannot be expressed in code.
I have included a link to an online calculator for $li(x)$ which also displays the graph:
.
Thank you very much for your help.
$\endgroup$ 62 Answers
$\begingroup$En efficient algorithm, 24-bits precision, can be found in this book : J.Spanier, K.B.Oldham, "An Atlas of Functions", Hemisphere Publishing Co. N-Y., 1987.
Since it is an old edition, a copy of page 355 is shown below.
For $x=2$ the output is $\quad\text{li}(2)\simeq 1.045164$
More information, from the above referenced document :
$\endgroup$ 6 $\begingroup$You said you’d consider using a series expansion, so try using $$\operatorname{li}(x)=\gamma+\ln\ln x + \sum_{k=1}^{\infty}\frac{\ln^k x}{k!\:k}$$
(eq. 14 here) where $\gamma$ is the Euler-Mascheroni constant.
$\endgroup$ 2