Prove that $\int_0^\infty \frac{1+2\cos x+x\sin x}{1+2x\sin x +x^2}dx=\frac{\pi}{1+\Omega}$ where $\Omega e^\Omega=1$ Whilst reading this Math SE post, I saw that the OP mentioned the integral
$$\int_0^\infty \frac{1+2\cos x+x\sin x}{1+2x\sin x +x^2}dx=\frac{\pi}{1+\Omega}$$
where $\Omega$ is the unique solution to the equation
$$xe^x=1$$
However, the question was about how to approximate the integral numerically. This is not a duplicate question; I would like to know how to exactly prove the above equality without approximation. Does anybody know how to do this?
Thanks!
 A: The integral identity is true.
We will evaluate the integral $$I=\int_0^\infty\frac{1+2\cos x+x\sin x}{1+2x\sin x+x^2}\,dx$$ by taking a semicircular contour on the upper-half plane. As the integrand is even, it follows from the residue theorem that $$\left(\int_{-R}^R+\int_{\gamma_R}\right)f(z)=2\pi i\sum_{f(z^*)=0\\\Im z^*>0\\|z^*|<R}\operatorname{Res}(f(z),z^*)$$ where $\gamma_R$ is the anti-clockwise circular path from $\theta=0$ to $\pi$, and $$f(z)=\frac{1+2\cos z+z\sin z}{1+2z\sin z+z^2}=\frac{1+2\cos z+z\sin z}{(iz+e^{iz})(iz-e^{-iz})}.$$ The only values of $z^*$ meeting the three criteria under the summation are $iW_0(1)$, $-iW_k(1)$ and $-iW_{-k}(1)$ for all integers $k>0$ such that $|W_k(1)|<R$. It is useful to note that $W_k$ and $W_{-k}$ are complex conjugates.
To evaluate these residues, we take the limit of $(z-z^*)f(z)$ as $z\to z^*$, writing cosine and sine as complex exponentials, then making extensive use of the identity $e^{W_k(1)}=1/W_k(1)$. This yields \begin{align}\operatorname{Res}(f(z),iW_0(1))&=\frac1{2i}\left(1+\frac1{1+W_0(1)}\right)\\\operatorname{Res}(f(z),-iW_k(1))&=-\frac1{2i}\left(1+\frac1{1+W_k(1)}\right),\quad\forall|k|>0.\end{align} Therefore, the result from the residue theorem reads $$2I+\lim_{R\to+\infty}\int_0^\pi f(Re^{i\theta})iRe^{i\theta}\,d\theta=\pi+\frac\pi{1+W_0(1)}-\pi\lim_{R\to+\infty}\sum_{0<|k|<\max K\\|W_K(1)|<R}\left(1+\frac1{1+W_k(1)}\right),$$ where the divergent limits are interpreted as $R$ increasing at the same rate on both sides. Now we focus on the arc contribution \begin{align}f(Re^{i\theta})&=\frac{1+e^{iRe^{i\theta}}+e^{-iRe^{i\theta}}+Re^{i\theta}\frac{e^{iRe^{i\theta}}-e^{-iRe^{i\theta}}}{2i}}{1-iRe^{i\theta}(e^{iRe^{i\theta}}-e^{-iRe^{i\theta}})+R^2e^{2i\theta}}.\end{align} Since $e^{iRe^{i\theta}}\to0$, the only term that survives on the numerator is $(1-Re^{i\theta}/(2i))e^{-iRe^{i\theta}}$ as it dominates all the other terms as $R\to+\infty$. Likewise, the denominator only remains as $iRe^{i\theta}e^{-iRe^{i\theta}}+R^2e^{2i\theta}$ so \begin{align}\lim_{R\to+\infty}\int_0^\pi f(Re^{i\theta})iRe^{i\theta}\,d\theta&=\lim_{R\to+\infty}\int_0^\pi\frac{Re^{i\theta}(i-Re^{i\theta}/2)e^{-iRe^{i\theta}}}{iRe^{i\theta}e^{-iRe^{i\theta}}+R^2e^{2i\theta}}\,d\theta\\&=\lim_{R\to+\infty}\int_0^\pi\frac{i-Re^{i\theta}/2}{i+Re^{iRe^{i\theta}}e^{i\theta}}\,d\theta\\&\stackrel{(*)}=\lim_{R\to+\infty}\int_{-\pi}^\pi\frac{i-Re^{i\theta}/2}{i+Re^{iRe^{i\theta}}e^{i\theta}}\,d\theta\\&=\lim_{R\to+\infty}\oint_{|z|=R}\frac{i-z/2}{i+ze^{iz}}\,\frac{dz}{iz}\\&=\lim_{R\to+\infty}\frac12\oint_{|z|=R}\frac{2i-z}{z(ize^{iz}-1)}\,dz\\&=\small\pi i\left(-2i+i\left(1+\frac1{1+W_0(1)}\right)+\lim_{R\to+\infty}\sum_{0<|k|<\max K\\|W_K(1)|<R}i\left(1+\frac1{1+W_k(1)}\right)\right)\\&=\pi-\frac\pi{1+W_0(1)}-\pi\lim_{R\to+\infty}\sum_{0<|k|<\max K\\|W_K(1)|<R}\left(1+\frac1{1+W_k(1)}\right)\end{align} where $(*)$ follows since \begin{align}\lim_{R\to+\infty}\int_{-\pi}^0\frac{i-Re^{i\theta}/2}{i+Re^{iRe^{i\theta}}e^{i\theta}}\,d\theta&=\lim_{R\to+\infty}\int_0^\pi\frac{ie^{i\theta}-R/2}{ie^{i\theta}+Re^{iRe^{-i\theta}}}\,d\theta\to0\end{align} as the denominator exponentially increases on the order of $Re^R$. We finally obtain $$2I-\frac\pi{1+W_0(1)}=\frac\pi{1+W_0(1)}\implies I=\frac\pi{1+W_0(1)}$$ as desired.
