What is the logarithmic integral li(x)?
The logarithmic integral, written \(\operatorname{li}(x)\), is a special function defined by the integral of \(1/\ln(t)\) from 0 to \(x\). Because the integrand has a singularity at \(t = 1\), for \(x > 1\) the integral is taken as a Cauchy principal value. The function is central to analytic number theory: the Prime Number Theorem states that the prime-counting function \(\pi(x)\) is asymptotic to \(\operatorname{li}(x)\), and \(\operatorname{li}(x)\) is one of the best simple approximations to the number of primes below \(x\). This calculator uses the offset-free definition \(\operatorname{li}(x)\) (lower limit 0), not the Eulerian variant \(\operatorname{Li}(x) = \operatorname{li}(x) - \operatorname{li}(2)\).
How to use this calculator
Enter three values: the initial value of \(x\), the increment (step) added at each row, and the number of iterations (rows). The tool builds a table where row \(i\) has $$x = \text{startX} + i \times \text{step},$$ and the matching value \(\operatorname{li}(x)\). A line graph of \(\operatorname{li}(x)\) versus \(x\) is also produced. For meaningful real output choose a start above 0; the common default range is startX = 2, step = 0.2, 61 iterations, which tabulates \(x\) from 2.0 up to 14.0.
The formula explained
We evaluate $$\operatorname{li}(x) = \operatorname{Ei}(\ln x),$$ where \(\operatorname{Ei}\) is the exponential integral. \(\operatorname{Ei}(z)\) is summed with the convergent series $$\operatorname{Ei}(z) = \gamma + \ln|z| + \sum_{k=1}^{\infty}\frac{z^{k}}{k\cdot k!},$$ where \(\gamma = 0.5772156649\dots\) is the Euler-Mascheroni constant. The series is accumulated until each term is negligible relative to the running sum. Edge cases follow the standard conventions: \(x \le 0\) returns 0, and \(x = 1\) returns negative infinity (the singularity).
Worked example
For \(x = 2\), \(z = \ln 2 = 0.6931472\). Summing \(\gamma + \ln|z| +\) the series gives $$\operatorname{Ei}(0.6931472) = 1.0451638,$$ so \(\operatorname{li}(2) = 1.04516378011749\), matching the published reference value. The single positive real root of \(\operatorname{li}(x)\) is at \(x = 1.45136923488\) (the Ramanujan-Soldner constant), where \(\operatorname{li}(x) = 0\).
FAQ
Why does \(\operatorname{li}(x)\) blow up near \(x = 1\)? The integrand \(1/\ln(t)\) is singular at \(t = 1\), so \(\operatorname{li}(1) = -\infty\) and the function changes rapidly around that point.
Is this \(\operatorname{li}(x)\) or \(\operatorname{Li}(x)\)? This is the un-offset \(\operatorname{li}(x)\) with lower limit 0. The offset version \(\operatorname{Li}(x)\) subtracts \(\operatorname{li}(2)\).
What if my start is 0 or negative? For \(x \le 0\) the real logarithmic integral is not defined, so the calculator returns 0 for those rows.