# Math Help - Integral involving Lambert W-function

1. ## Integral involving Lambert W-function

(This is a challenge. I already know how to solve it.)

This is an integral Mathematica can't solve (exactly):

$\int_{-\infty}^{\infty} \frac{dx}{\pi^2+(1-x+e^x)^2}$

Explain how to solve this integral using the Lambert-W function and obtain the exact numeric answer (not in terms of the W function) Mathematica can't compute.

2. Originally Posted by shawsend
(This is a challenge. I already know how to solve it.)

This is an integral Mathematica can't solve (exactly):

$\int_{-\infty}^{\infty} \frac{dx}{\pi^2+(1-x+e^x)^2}$

Explain how to solve this integral using the Lambert-W function and obtain the exact numeric answer (not in terms of the W function) Mathematica can't compute.
This is a contour integration problem, so I preemptively say that the integral along the semi-circle of radius $r$ goes to $0$ as $r\to \infty$ by Jordan's lemma or something like that since that's not the main concern of the problem.

So $\int_{-\infty}^{\infty} \frac{dx}{\pi^2+(1-x+e^x)^2} = 2\pi i \text{Res}(f,c)$ where $c$ is the singularity inside our contour.

$\text{Res}(f,c) = \lim_{z\to c}(z-c)f(z)$, where $f(z) = \frac{1}{\pi^2+(1-z+e^z)^2}$ and $1-c+e^c=-\pi i$.

So let's solve $e^x-x+\pi i+1=0$.
Note $z=W(z)e^{W(z)}\implies e^{W(z)} = \frac{z}{W(z)}\implies e^{-W(z)} = \frac{W(z)}{z}$.
Consider $-W(e)$
Now $e^{-W(e)}+W(e)+\pi i+1 = \frac{W(e)}{e}+W(e)+\pi i+1$
Therefore we want our $e^x$ term to get a " $\cdot e$" and change sign to cancel out the $W(e)$'s. Doing this though luckily can cancel out $\pi i$ and $1$ too!
Thus our solution to solve this equation is $x=-W(e)+\pi i+1$.
Observe $W(e) = 1\implies x=\pi i$

We now get $\text{Res}(f,c) = \lim_{z\to \pi i}(z-\pi i)f(z) = \frac{1}{4\pi i}$ by L'Hopital's rule.

Therefore $\int_{-\infty}^{\infty} \frac{dx}{\pi^2+(1-x+e^x)^2} = \frac{2\pi i}{4\pi i} = \frac{1}{2}$.

3. Hi Chip, I have some constructive comments:

Originally Posted by chiph588@
This is a contour integration problem, so I preemptively say that the integral along the semi-circle of radius $r$ goes to $0$ as $r\to \infty$ by Jordan's lemma or something like that since that's not the main concern of the problem.
Showing that goes to zero is an important part of this problem especially if you don't already know what the answer is.

So let's solve $e^x-x+\pi i+1=0$.
Note $z=W(z)e^{W(z)}\implies e^{W(z)} = \frac{z}{W(z)}\implies e^{-W(z)} = \frac{W(z)}{z}$.
Consider $-W(e)$
Now $e^{-W(e)}+W(e)+\pi i+1 = \frac{W(e)}{e}+W(e)+\pi i+1$
Therefore we want our $e^x$ term to get a " $\cdot e$" and change sign to cancel out the $W(e)$'s. Doing this though luckily can cancel out $\pi i$ and $1$ too!
Thus our solution to solve this equation is $x=-W(e)+\pi i+1$.
Observe $W(e) = 1\implies x=\pi i$
Should we not be solving $1-z+e^z=\pm \pi i$? In either case, I get for the solution $z=1\pm \pi i-W(e)$ but $W(e)$ is multi-valued and so there are an infinite number of solutions and therefore an infinite number of (isolated) poles of the integrand which is evident from the equation $1-z+e^z=k$ and since the left side is entire and non-polynomial, it reaches k infinitely often. Which ones are inside the contour and how do they affect the solution?

We now get $\text{Res}(f,c) = \lim_{z\to \pi i}(z-\pi i)f(z) = \frac{1}{4\pi i}$ by L'Hopital's rule.
That shows the point $\pi i$ is a simple pole but what are the orders of the other poles?

4. Originally Posted by shawsend
Hi Chip, I have some constructive comments:

Showing that goes to zero is an important part of this problem especially if you don't already know what the answer is.
You're absolutely correct... I was just to lazy to tex the answer .

Let $C_R$ be the the semi-circle of radius $R$ centered at the origin.

$\left|\int_{C_R} \frac{dz}{\pi^2+(1-z+e^z)^2}\right| \leq \frac{2\pi R}{e^{2R}-R^2+1-\pi^2} \to 0$ as $R\to\infty$.

But apparently there are an infinite amount of poles? If this is the case we need to choose $C_R$ carefully such that it never lies on a pole.
Should we not be solving $1-z+e^z=\pm \pi i$?
I originally solved this equation, but since I thought $W(e)\equiv 1$ this meant the other solution was $z=-\pi i$ which is outside of our contour. So I decided to omit this solution.

In either case, I get for the solution $z=1\pm \pi i-W(e)$ but $W(e)$ is multi-valued and so there are an infinite number of solutions and therefore an infinite number of (isolated) poles of the integrand which is evident from the equation $1-z+e^z=k$ and since the left side is entire and non-polynomial, it reaches k infinitely often. Which ones are inside the contour and how do they affect the solution?
What are the other values of $W(e)$??

5. Originally Posted by chiph588@
You're absolutely correct... I was just to lazy to tex the answer .

Let $C_R$ be the the semi-circle of radius $R$ centered at the origin.

$\left|\int_{C_R} \frac{dz}{\pi^2+(1-z+e^z)^2}\right| \leq \frac{2\pi R}{e^{2R}-R^2+1-\pi^2} \to 0$ as $R\to\infty$.

What are the other values of $W(e)$??
I don't think that inequality is correct as I can just numerically compute the integral for say $R=10$ and get:

$\left|\int_{\gamma}\frac{dz}{\pi^2+(1-z+e^z)^2}\right|\approx 0.13$

$\frac{2\pi R}{e^{2R}-R^2+1-\pi^2}\approx 10^{-7}$

This is how I proved the integral is zero over the half-circle contour. I'm sure others can prove it more simply.

Spoiler:

Let $\gamma=Re^{it}$ for $0\leq t \leq \pi$ then $\left|\int_{\gamma}\frac{dz}{\pi^2+(1-z+e^z)^2}\right|\leq \int_{\gamma}\frac{|dz|}{|\pi^2+(1-z+e^z)^2|}\leq \frac{\pi R}{\text{Min}(|\pi^2+(1-z+e^z)^2|,\gamma)}.$

First note
$
|\pi^2+(1-z+e^2)^2|\geq |\pi^2-|1-z+e^z|^2|,
$

and so
$\text{Min}\left(|\pi^2+(1-z+e^z)^2|,\gamma\right)=\begin{cases} O(\pi^2) \\
O(|1-z+e^z|^2)
\end{cases}
$

Now $|1-z+e^z|\geq |1-|z-e^z||$ and so
$\text{Min}\left(|1-z+e^z)\right)=\begin{cases} O(1) \\
O(|z-e^z|)
\end{cases}
$

and


\begin{aligned}
|z-e^z|&\geq |R-|e^{R(cos(t)+i\sin(t))}|| \\
&\geq |R-e^{R\cos(t)}|
\end{aligned}

So that over $\gamma$, we have three cases:

(1) For $0, $e^{R\cos(t)}>2R$ for sufficiently large R and

$\text{Min}(|R-e^{R\cos(t)}|,0

(2) $\text{Min}(|R-e^{R\cos(t)}|,\pi/2)=O(R)$

(3) $\text{Min}(|R-e^{R\cos(t)}|,\pi/2|1-R|=O(R)$

And therefore $\text{Min}(|\pi^2+(1-z+e^z)^2|,\gamma)=O(R^2)$ for large $R$.

so that

$\lim_{R\to\infty}\int_{\gamma}\frac{dz}{(\pi^2+(1-z+e^z)^2}=0$.

Also, you asked about the other poles. The plot below shows some of them. The red points are $1+\pi i-W(n,e)$ and the blue are $1-\pi i-W(n,e)$ where $n$ is the branch number of the Lambert-W function. The trend goes without bounds. However, we can show that the residue sum over each vertical blue and red pair is zero and therefore, we are left with the single red pole at $\pi i$ in the upper half-circle contour.