What is the logarithmic integral li(x)?
The logarithmic integral function, written \(\operatorname{li}(x)\), is a special function defined as the integral of \(1/\ln(t)\) from 0 to x. It appears throughout analytic number theory, most famously as the leading-order approximation to the prime-counting function \(\pi(x)\) in the Prime Number Theorem: the number of primes below x is approximately \(\operatorname{li}(x)\). Because the integrand has a pole at t = 1, for x > 1 the integral is interpreted as a Cauchy principal value, which is the standard definition.
How to use this calculator
Enter any real value x with x > 0 and x ≠ 1. The calculator returns \(\operatorname{li}(x)\) to full double precision (about 15 significant figures). Values of x between 0 and 1 give a finite negative result; \(\operatorname{li}(0) = 0\) and \(\operatorname{li}(1) = -\infty\) (reported as undefined). For x ≤ 0 the real-valued li is undefined.
The formula explained
This tool uses the identity \(\operatorname{li}(x) = \operatorname{Ei}(\ln x)\), where Ei is the exponential integral. With \(u = \ln(x)\) and the Euler-Mascheroni constant \(\gamma = 0.5772156649\), we evaluate the convergent series $$\operatorname{li}(x) = \int_{0}^{x} \frac{dt}{\ln t} = \gamma + \ln\!\left|\ln x\right| + \sum_{k=1}^{\infty} \frac{(\ln x)^{k}}{k \cdot k!}$$ The series converges for every real u not equal to 0 and is summed until each term is below about \(10^{-18}\) of the running total.
Worked example
For x = 2: \(u = \ln(2) = 0.6931472\), \(\ln|u| = -0.3665129\), and the series sums to about \(0.8344608\). Adding gamma gives $$\operatorname{li}(2) = 0.5772157 - 0.3665129 + 0.8344608 = 1.04516378$$ matching the known reference value \(1.0451637801\).
FAQ
Why is li(1) infinite? The integrand \(1/\ln(t)\) blows up as t approaches 1 from above, so \(\operatorname{li}(x)\) tends to negative infinity at x = 1.
Where does li(x) equal zero? At the Ramanujan-Soldner constant, \(x \approx 1.4513692349\).
Is li(x) the same as Li(x)? The offset version \(\operatorname{Li}(x) = \operatorname{li}(x) - \operatorname{li}(2)\) is sometimes used so that \(\operatorname{Li}(2) = 0\); this calculator returns the unoffset \(\operatorname{li}(x)\).