\documentclass[a4paper]{article}
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage{listings}
\begin{document}
\title{Solving $2^x=x^{32}$}
\author{Amit Yaron}
\date{Jan 3, 2025}
\maketitle
\begin{abstract}
Here's one equation that can be solved using the Lambert W function.
The Lambert W function is the formal way to write a solution.
But even when you use that function, you can still find an exact solution
using some intuition. In this article, I will show how to solve the equation.
\end{abstract}
\section{The Lambert W Function}
The Lambert W function is defined as follows:
\[
 x=ye^y\Rightarrow y=W_n(x)
\]
for some integer value $n$. \\
$W_n$ is called a branch of the Lambert W function. \\
Now, let us derive $y=xe^x$ to find how many real solutions there are for
a given $y$:
\[
 y=xe^x\Rightarrow y'=(x+1)e^x
\]
Thus,
\[
 y'=0\Rightarrow x=-1
\]
It is a minimum point.
And the minimum value of $y$ is $-e^{-1}$\\
Now,
\[
 x>0\Rightarrow xe^x>0\\
\]
and
\[
 x<0\Rightarrow xe^x<0\\
\]
And it can easily be found that if $e^{-1}<xe^x<0$ there are 2 distinct
real solutions.
\subsection{branches}
When there are two distinct real solution:\\
$W_0$ is the branch returning results greater than -1\\
$W_{-1}$ is the branch returning results smaller than -1
\section{The Equation}
Our equation is:
\[
 x^{32}=2^{x}
\]
And 32 is an even number, so $x^{32}=(-x)^{32}$\\
Let us split into 2 cases:
\subsection{Positive $x$:}
Let us take logs from both sides:
\begin{align*}
 &x^{32}=2^x\Rightarrow\\
 \Rightarrow &\ln(x^{32})=\ln(2^x)\Rightarrow\\
 \Rightarrow &32\ln(x)=x\ln(2)\Rightarrow\\
 \Rightarrow &32\ln(x)x^{-1}=\ln(2)\Rightarrow\\
 \Rightarrow &\ln(x)x^{-1}=\dfrac{\ln(2)}{32}\Rightarrow\\
 \Rightarrow &-\ln(x)x^{-1}=-\dfrac{\ln(2)}{32}\Rightarrow\\
 \Rightarrow &-\ln(x)e{-\ln(x)}=-\dfrac{\ln(2)}{32}\Rightarrow\\
 \Rightarrow &-\ln(x)=W(-\dfrac{\ln(2)}{32})
\end{align*}
Now,
\begin{align*}
 -\dfrac{\ln(2)}{32}&=-\dfrac{8\ln(2)}{8\cdot32}\\
 &=-\dfrac{\ln(2^8)}{256}\\
 &=-\dfrac{\ln(256)}{256}\\
 &=\ln(256^{-1})256^{-1}\\
 &=\ln(256^{-1})e^{\ln(256^{-1})}
\end{align*}
So, we have one solution, which is:
\[ \ln(x^{-1})=-\ln(x)=256^{-1}\Rightarrow x^{-1}=256^{-1}\Rightarrow x=256
\]
And
\[
 \ln(256^{-1})\approx-5.545
\]
So, $W_{-1}$ returned that value.\\
The other solution is:
\begin{align*}
 &\ln(x^{-1})=-\ln(x)=W_0\big(-\dfrac{\ln(2)}{32}\big)\Rightarrow\\
 \Rightarrow &x^{-1}=e^{W_0\big(-\dfrac{\ln(2)}{32}\big)}\Rightarrow\\
 \Rightarrow &x=e^{-W_0\big(-\dfrac{\ln(2)}{32}\big)}
\end{align*}
The following Python script approximates it:
\begin{lstlisting}
import numpy as np

def nr_approx(func,derivative,start_x):
   x=start_x
   while(True):
       new_x=x-func(x)/derivative(x)
       if np.abs(x-new_x)<1e-14:
           break
       x=new_x
   return new_x

f=lambda x: x*np.e**x+np.log(2)/32
d=lambda x: (x+1)*np.e**x

y=nr_approx(f,d,0)
x=np.e**-y
print("x=%f"%x)
\end{lstlisting}

The solution found is:
\[
x\approx1.022393
\]
\subsection{Negative $x$:}
\[
(-x)^{32}=2^x
\]
Let us take logs from both sides:
\begin{align*}
 & 32\ln(-x)=x\ln(2)\Rightarrow\\
 \Rightarrow &32\ln(-x)x^{-1}=\ln(2)\Rightarrow\\
 \Rightarrow &\ln(-x)x^{-1}=\dfrac{\ln(2)}{32}\Rightarrow\\
 \Rightarrow -&\ln(-x)x^{-1}=-\dfrac{\ln(2)}{32}\Rightarrow\\
 \Rightarrow &\ln(-x^{-1})x^{-1}=-\dfrac{\ln(2)}{32}\Rightarrow\\
 \Rightarrow &-\ln(-x^{-1})x^{-1}=\dfrac{\ln(2)}{32}\Rightarrow\\
 \Rightarrow &\ln(-x^{-1})\cdot-x^{-1}=\dfrac{\ln(2)}{32}\Rightarrow\\
 \Rightarrow &\ln(-x^{-1})(-1)^{-1}x^{-1}=\dfrac{\ln(2)}{32}\Rightarrow\\
 \Rightarrow &\ln(-x^{-1})(-x)^{-1}=\dfrac{\ln(2)}{32}\Rightarrow\\
 \Rightarrow &\ln(-x^{-1})e^{\ln(-x^{-1})}=\dfrac{\ln(2)}{32}\Rightarrow\\
 \Rightarrow &\ln(-x^{-1})=W_n\big(\dfrac{\ln(2)}{32}\big)\Rightarrow\\
 \Rightarrow &-x^{-1}=e^{W_n\big(\dfrac{\ln(2)}{32}\big)}\Rightarrow\\
 \Rightarrow &x^{-1}=-e^{W_n\big(\dfrac{\ln(2)}{32}\big)}\Rightarrow\\
 \Rightarrow &x=-e^{-W_n\big(\dfrac{\ln(2)}{32}\big)}
\end{align*}
Now, because $\dfrac{\ln(2)}{32}>0$, we only take $W_0$ of that argument.
The following Python script approximates $x$:
\begin{lstlisting}
import numpy as np

def nr_approx(func,derivative,start_x):
   x=start_x
   while(True):
       new_x=x-func(x)/derivative(x)
       if np.abs(x-new_x)<1e-14:
           break
       x=new_x
   return new_x

f=lambda x: x*np.e**x-np.log(2)/32
d=lambda x: (x+1)*np.e**x

y=nr_approx(f,d,0)
x=-np.e**-y
print("x=%f"%x)
\end{lstlisting}

The solution found is:
\[
 x\approx-0.979017
\]
\end{document}