Lambert W function example

I need to solve a function for $x$

$k+\frac{1}{2}=-\log{x}+\frac{x^2}{2}$

I know the solution(s) should be expressed using Lambert W function because the above function can also be expressed as

$2^{k+1/2}=\frac{1}{x}e^{(\ln{\sqrt{2}})x^2}$

however, I cannot proceed any further.

• $\log$ is base two, right? – Simply Beautiful Art Mar 17 '17 at 17:35
• $\log$ is base 2. However I realize my mistake. I will edit the second line. – C.Koca Mar 17 '17 at 17:41

By log rules, we have

$$2^{-\log_2(x)+\frac{x^2}2}=\frac{2^{\frac{x^2}2}}{2^{\log_2(x)}}=\frac1x2^{\frac{x^2}2}=2^{k+\frac12}$$

Multiply both sides by $x$ and square both sides:

$$2^{x^2}=x^22^{2k+1}$$

Let $u=x^2$ to simplify:

$$2^u=u2^{2k+1}$$

Divide both sides by $2^{u+2k+1}$ and multiply both sides by $-\ln(2)$.

$$-\ln(2)2^{-2k-1}=-\ln(2)u2^{-u}=-\ln(2)ue^{-\ln(2)u}$$

Take the $W$ of both sides to get

$$W(-\ln(2)2^{-2k-1})=-\ln(2)u$$

$$u=\frac{W(-\ln(2)2^{-2k-1})}{-\ln(2)}$$

So finally,

$$x=+\sqrt{\frac{W(-\ln(2)2^{-2k-1})}{-\ln(2)}}$$