2

How can I find an approximation value for the value of $n$ for which $$n \log(n)=100\,000$$ or each numeric value?

Travis Willse
  • 108,056
Taban
  • 283
  • At each numeric value of what? Are you changing the $100,000$? Are you changing the base of the logarithm? Assuming $\log_{10}()$, it looks like $n = 22933$ is the closest integer. – Mike Pierce Oct 05 '15 at 05:43
  • Claude's answer seems pretty precise here. In case you were looking for a more elementary answer, you could use first order approximation. Find some n that gets close, find the derivative at that n, and then assume that the function behaves like a line with slope equal to the derivative. Adjust your n accordingly. – nivekgnay Oct 05 '15 at 06:20
  • 1
    Possible duplicate of http://math.stackexchange.com/questions/1301343/how-to-find-the-inverse-of-n-log-n – Erick Wong Oct 07 '15 at 07:41

3 Answers3

5

The solution of equation $$x \log(x)=a$$ is given in terms of Lambert function $$x=\frac{a}{W(a)}$$ In the Wikipedia page, you will find quite simple formulas for the approximation of Lambert function.

For example, for very large values of $a$ $$W(a) \approx L_1-L_2+\frac{L_2}{L_1}+\frac{L_2(L_2-2)}{2L_1^2}+\cdots$$ where $L_1=\log(a)$ and $L_2=\log(L_1)$.

For the case of $a=100000$, $L_1=11.5129$, $L_2=2.44347$ and the above formula would give $$W(100000)\approx 9.28337$$ so $x\approx10772.0$ while the exact solution would be $x\approx10770.6$. Adding more terms would improve the result.

Another way would be to consider $$f(x)=x\log(x)-a$$ $$f'(x)=1+\log(x)$$ and use Newton method which, starting from a guess $x_0$ will update it according to $$x_{k+1}=x_k-\frac{f(x_k)}{f'(x_k)}$$ which would write $$x_{k+1}=\frac{a+x_k}{\log (x_k)+1}$$ Let us consider again the case where $a=100000$ and let us be very lazy starting with $x_0=1$. Then the successive iterates of Newton method will be $$x_1=100001.$$ $$x_2=15983.5$$ $$x_3=10860.6$$ $$x_4=10770.6$$ which is the solution for six significant figures.

For sure, starting with a better estimate such as $$x_0=\frac{a}{\log(a)}$$ will make Newton method converging in less iterations as shown below $$x_0=8685.89$$ $$x_1=10793.6$$ $$x_2=10770.6$$

Edit

Using values $10^3 \leq a \leq 10^7$, I found, using a simple linear regression, than a good approximation is given by $$\log(x)=0.933231 \log(a)-1.52287$$ which will give as estimate $x_0=10110.7$.

3

Just for fun, if you don't want to use calculus, you can get it within a range of $5000$: since $\log(10000) = 4$, we see that $25000$ is too big. Since $\log(100000) = 5$, we see that $20000$ is too small.

hunter
  • 32,629
3

Recall that the Lambert $W$ function (sometimes called the product logarithm) satisfies (but is not quite characterized by) $$W(x) \exp W(x) = x.$$ With a little work we can show that the inverse of $$L(x) := x \log x$$ is $$L^{-1}(y) = \frac{y}{W(y)} .$$

On the other hand, using that $W(e) = 1$ leads quickly to the cheap bounds $$\log y - \log \log y < W(y) < \log y - \log \log y - \log\left(1 - \frac{\log \log y}{\log y}\right)$$ for $x > e$ (see this post by Antonio Vargas for a nice derivation). It's not too hard to show that the difference between these bounds is bounded above by $-\log\left(1 - \frac{1}{e}\right) < \frac{1}{2}$ for all $y > e$, and so even for modestly large $y$ (namely, $y$ such that $\log y - \log \log y \gg \frac{1}{2}$) we have $W(y) \approx \log y - \log \log y .$ Thus, we can approximate $L^{-1}(y)$ as $$L^{-1}(y) \approx \frac{y}{\log y - \log \log y},$$ and hence the solution to $$n \log n = 10^5$$ as $$\color{#bf0000}{\boxed{L^{-1}(10^5) \approx \frac{10^5}{\log(10^5) - \log \log (10^5)} \approx 11026}}.$$

The above derivativon also gives that (for $M > e$) the relative error of the approximate solution to $n \log n = M$ produced with this method is bounded above by $$\frac{1}{2 (\log M - \log \log M)},$$ so in our case ($M = 10^5$) our approximation is guaranteed an error of $< 6\%$. Indeed, the actual solution is $\approx 10770$, which gives an error of $< 3\%$, and which in turn is not too bad considering the ease of deriving the above bounds.

With only a little more trouble, one can derive sharper bounds on $W(x)$, and hence better estimates for $L$.

Travis Willse
  • 108,056