3 ms·
Not even close. The prime number theorem itself gives Li(x) as an approximation to pi(x), where Li(x) = \int_2^x dt / (ln t). (If you don't read LaTeX, this sa
by pmiller2 6y ago
Not even close. The prime number theorem itself gives Li(x) as an approximation to pi(x), where Li(x) = \int_2^x dt / (ln t). (If you don't read LaTeX, this says "integral from 2 to x of dt / ln t". Li(x) can be numerically evaluated with pretty good accuracy.
Here is the approximation to pi(10^12) using Li(x) in Wolfram Alpha: https://www.wolframalpha.com/input/?i=Round%5BLogIntegral%5B10%5E12%5D+-+LogIntegral%5B2%5D%5D https://www.wolframalpha.com/input/?i=Round%5BLogIntegral%5B...
The numerical value is 37607950280. Compared with the true value of 37607912018, this gives a relative error of around 1.0 * 10^-6, or 5 correct digits.
Edit: Here is an algorithm to approximate pi(x) more directly: https://en.wikipedia.org/wiki/Meissel%E2%80%93Lehmer_algorithm https://en.wikipedia.org/wiki/Meissel%E2%80%93Lehmer_algorit...