# Thread: Can't manage to solve this equation with Lambert W function

1. ## Can't manage to solve this equation with Lambert W function

Hi dear forumers !

I have some trouble solving for n in this equation :
$\displaystyle p=\frac{\left ( 1-a^2 \right )^{(n-1)/2}}{a\sqrt{2\pi n }}$

I know the solution involves the Lambert W function (inverse of n*e^n). However I can't get n to be isolated on one side .

$\displaystyle pa\sqrt{2\pi n }=\left ( 1-a^2 \right )^{(n-1)/2}$
$\displaystyle p^2a^22\pi n=\left ( 1-a^2 \right )^{(n-1)}$
$\displaystyle \ln \left ( p^2a^22\pi n \right )=(n-1)\ln\left ( 1-a^2 \right )$
$\displaystyle \ln \left ( p^2a^22\pi \right )=(n-1)\ln\left ( 1-a^2 \right )-\ln(n)$
$\displaystyle \ln \left ( p^2a^22\pi \right )+\ln\left ( 1-a^2 \right )=n\ln\left ( 1-a^2 \right )-\ln(n)$

From there I am stuck. Thank you very much for your help !

2. ## Re: Can't manage to solve this equation with Lambert W function

$n = \Large -\frac{W\left(\frac{\log \left(1-a^2\right)}{2 \pi (a-1) a^2 (a+1) p^2}\right)}{\log \left(1-a^2\right)}$

3. ## Re: Can't manage to solve this equation with Lambert W function

Thank you romsek ; in fact I found the same answer by solving with wolfram alpha. Do you have the steps for this ?
I am very interested in the steps to get there for personal satisfaction and advancing my math knowledge !

4. ## Re: Can't manage to solve this equation with Lambert W function

Originally Posted by Jo37
Thank you romsek ; in fact I found the same answer by solving with wolfram alpha. Do you have the steps for this ?
I am very interested in the steps to get there for personal satisfaction and advancing my math knowledge !
sorry I don't feel like grinding through all that algebra.

5. ## Re: Can't manage to solve this equation with Lambert W function

The problem is of the form $$p = \frac {C^{\frac n 2}}{D n^\frac 1 2}$$ for constants $C$ and $D$. Rewrite it as
$$Dp = n^{-\frac 1 2}C^{\frac n 2}$$ Now raise both sides to the $-2$ power:
$$(Dp)^{-2} = nC^{-n} =n e^{-n \ln C}$$Multiply both sides by $-\ln C$:
$$-(Dp)^{-2}\ln C = -n \ln Ce^{-n \ln C}$$The right side is now in the form $xe^x$ so you can write$$-n \ln C = W(-(Dp)^{-2}\ln C)$$This you can easily solve for $n$. Put in the constants and simplify. (And correct any mistakes you see).