It seems that a reasonable $\log$ approximation for $\pi(x)$ can be given, where

$f(y, x) := \log\left(\dfrac{\log(x)}{\log\left(e(y - \lfloor y\rfloor) + x^{1/x}(1 - y + \lfloor y\rfloor)\right)}\right)$

is an interpolating function between $\log(x)\text{ and }\log(\log(x)).$

Comparing $\pi(x)/\dfrac{x}{\log(x)},\pi(x)/\dfrac{x}{f(1+\frac{\log(x)}{x},x)},\pi(x)/\text{li}(x)$:

enter image description here

f[y_, x_] := Log[Log[x]/Log[(1 - (y - Floor[y])) x^(1/x) + (y - Floor[y]) E]]
t = 8; r = 10^t; LogLogPlot[{PrimePi[n]/(n/f[1 + Log[n]/n, n]), 
PrimePi[n]/(n/Log[n]), PrimePi[n]/LogIntegral[n]}, {n, 1, r}]

Am I correct in assuming that this is an improvement on the $\pi(x)\sim\dfrac{x}{\log(x)}$ approximation?

Re-posted owing to errors in original question


With $y=1+\frac{\log x}{x}$ and consequently $\lfloor y\rfloor=1$ for $x\ge1,$

$$ f(y, x) = \log\left(\frac{\log x}{\log\left(\ \frac{e\log x}{x} + x^{1/x}(1 - \frac{\log x}{x})\ \right)}\right) $$

which can more easily be written

$$ f(y, x) = \log\log x-\log\log\left(\ \frac{e\log x}{x} + x^{1/x}(1 - \frac{\log x}{x})\ \right) $$

Note that $x^{1/x}$ is approximately $1+\frac{\log x}{x}$ and so the latter argument is about

$$ \frac{e\log x}{x} + (1+\frac{\log x}{x})(1 - \frac{\log x}{x})=\frac{e\log x}{x}+1-\frac{\log^2x}{x^2}=1+\frac{e\log x}{x}+o\left(\frac1x\right) $$

That is, the $x^{1/x}(1 - \frac{\log x}{x})$ term is asymptotically negligible. Approximating $$ \log\log\left(\frac{e\log x}{x} + x^{1/x}(1 - \frac{\log x}{x})\right)\approx \log\log\left(\frac{e\log x}{x} + 1\right)\approx \log\left(\frac{e\log x}{x}\right)\approx1+\log\log x-\log x $$

and so $f(y,x)\approx\log x-1.$

In fact $\frac{x}{\log x-1}$ is a better approximation of $\pi(x)$ than $\frac{x}{\log x}$. (Sometimes the 1 in the former expression goes by the name "Legendre's constant"; Legendre had guessed its value to be around 1.08.)

A better approximation:

$$ \frac{e\log x}{x} + x^{1/x}(1 - \frac{\log x}{x})\approx1+\frac{e\log x}{x}-\frac{\log^2x}{2x^2}-\frac{\log^3x}{3x^3} $$

with logarithm about

$$ \frac{e\log x}{x}-(1+e^2)\frac{\log^2x}{2x^2} $$

and so

$$ f(y,x)\approx\log\log x-\log\left(\frac{e\log x}{x}-(1+e^2)\frac{\log^2x}{2x^2}\right)\\ =\log\log x-\log\left(\frac{e\log x}{x}\right)-\log\left(1-(1+e^2)\frac{x}{e\log x}\cdot\frac{\log^2x}{2x^2}\right)\\ =\log x-1-\log\left(1-(1+e^2)\frac{\log x}{2ex}\right)\\ \approx\log x-1-\frac{1+e^2}{2e}\cdot\frac{\log x}{x} $$

But the right approximation at this order is $\log x-1-1/\log x$ and so $f(y,x)$ is too large by about $1/\log x$.

In summary ("TL;DR"): This is a better approximation than $x/\log x$ but not as good as $\frac{1}{\log x-1-1/\log x}$ which is, in turn, not as good as $\operatorname{li}(x).$

  • 2
    $\begingroup$ Thank you for the detailed explanation :) $\endgroup$ – martin Jun 18 '14 at 19:18

When $y=1+(\log x)/x$, your function $f(y,x)$ equals $$ \log\bigg( \frac{\log x}{\log\big(x^{1/x}(1-(\log x)/x)+e(\log x)/x\big)} \bigg). $$ Since $x^{1/x} = 1+(\log x)/x+O((\log x)^2/x^2)$, this is \begin{multline*} \log\bigg( \frac{\log x}{\log\big( 1 + e(\log x)/x + O((\log x)^2/x^2)\big)} \bigg) \\ = \log\bigg( \frac{\log x}{e(\log x)/x + O((\log x)^2/x^2)} \bigg) \\ = \log\bigg( \frac{\log x}{e(\log x)/x} \bigg( 1 + O\bigg( \frac{\log x}x \bigg) \bigg) \bigg) \\ = \log x - 1 + O\bigg( \frac{\log x}x \bigg). \end{multline*} So essentially, your function is just $\log x-1$. And it is well known that $x/(\log x-1)$ is a better approximation to $\pi(x)$ than $x/\log x$, since the former expression matches the first two terms of the asymptotic series $$ \mathop{\rm li}(x) = \frac x{\log x} + \frac x{\log^2x} + \frac{2x}{\log^3x} + \cdots. $$

  • $\begingroup$ Yes, this makes sense! $\endgroup$ – martin Jun 18 '14 at 19:16
  • 1
    $\begingroup$ I wrote essentially the same answer (independently) and then carried the approximation one term further, where it disagrees with the series for li. $\endgroup$ – Charles Jun 18 '14 at 19:18
  • $\begingroup$ (+1, by the way -- good succinct explanation.) $\endgroup$ – Charles Jun 18 '14 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.