# Thread: 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):

$\displaystyle \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):

$\displaystyle \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 $\displaystyle r$ goes to $\displaystyle 0$ as $\displaystyle r\to \infty$ by Jordan's lemma or something like that since that's not the main concern of the problem.

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

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

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

We now get $\displaystyle \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 $\displaystyle \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 $\displaystyle r$ goes to $\displaystyle 0$ as $\displaystyle 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 $\displaystyle e^x-x+\pi i+1=0$.
Note $\displaystyle z=W(z)e^{W(z)}\implies e^{W(z)} = \frac{z}{W(z)}\implies e^{-W(z)} = \frac{W(z)}{z}$.
Consider $\displaystyle -W(e)$
Now $\displaystyle e^{-W(e)}+W(e)+\pi i+1 = \frac{W(e)}{e}+W(e)+\pi i+1$
Therefore we want our $\displaystyle e^x$ term to get a "$\displaystyle \cdot e$" and change sign to cancel out the $\displaystyle W(e)$'s. Doing this though luckily can cancel out $\displaystyle \pi i$ and $\displaystyle 1$ too!
Thus our solution to solve this equation is $\displaystyle x=-W(e)+\pi i+1$.
Observe $\displaystyle W(e) = 1\implies x=\pi i$
Should we not be solving $\displaystyle 1-z+e^z=\pm \pi i$? In either case, I get for the solution $\displaystyle z=1\pm \pi i-W(e)$ but $\displaystyle 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 $\displaystyle 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 $\displaystyle \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 $\displaystyle \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 $\displaystyle C_R$ be the the semi-circle of radius $\displaystyle R$ centered at the origin.

$\displaystyle \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 $\displaystyle R\to\infty$.

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

In either case, I get for the solution $\displaystyle z=1\pm \pi i-W(e)$ but $\displaystyle 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 $\displaystyle 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 $\displaystyle W(e)$??

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

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

$\displaystyle \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 $\displaystyle R\to\infty$.

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

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

$\displaystyle \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 $\displaystyle \gamma=Re^{it}$ for $\displaystyle 0\leq t \leq \pi$ then $\displaystyle \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
$\displaystyle |\pi^2+(1-z+e^2)^2|\geq |\pi^2-|1-z+e^z|^2|,$
and so
$\displaystyle \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 $\displaystyle |1-z+e^z|\geq |1-|z-e^z||$ and so
$\displaystyle \text{Min}\left(|1-z+e^z)\right)=\begin{cases} O(1) \\ O(|z-e^z|) \end{cases}$
and

\displaystyle \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 $\displaystyle \gamma$, we have three cases:

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

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

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

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

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

so that

$\displaystyle \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 $\displaystyle 1+\pi i-W(n,e)$ and the blue are $\displaystyle 1-\pi i-W(n,e)$ where $\displaystyle 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 $\displaystyle \pi i$ in the upper half-circle contour.