Inverse of $f(x) = \frac{x}{\log(x)}$

655 Views Asked by At

$\pi(x)$ is defined as number of primes less than or equal to x. Gauss showed that $\pi(x) \approx \frac{x}{log(x)}$. I want to calculate the inverse of that approximation because I want to estimate how far should I sieve in order to get the number of primes that I want. Here are the steps that I took.

$$\begin{align}y &= \frac{x}{\log(x)}\\ x &= y \log(x) \\ e^x&=e^{y\log(x)} \\ e^x &= (e^{\log(x)})^y \\ e^x &= x^y\end{align}$$

I am stuck at this point. How can I calculate $y$ in terms of $x$?

2

There are 2 best solutions below

10
On

Resorting to Lambert's $W$ is a little overkill.

With $$x=y\ln y,$$ we have

$$\frac x{\log x}=\frac{y\ln y}{\ln(y\ln y)}=\frac{y\ln y}{\ln y+\ln\ln y}\approx y.$$

Given that the distribution is anyway approximate, this can be a sufficient approximation of the inverse. Or you can use it as a starting value for Newton's iterations (use few of them anyway).

0
On

To be clear about what is hinted at in the comments, $$ f^{-1}(y) = -y\,W(-\tfrac{1}{y}) $$ where $W$ is the Lambert-$W$ function. (You can verify this in Mathematica.) If you wanted an asymptotic expansion check the wiki article and plug one in.