Integral by residue Hi guys :) Can anyone help me with this
$$
\int_0^\infty \frac{1-\cos(x)}{x^2} \ dx = \frac{\pi}{2}
$$
I have to solve it by residues but i am having a problem 'cause when i integrate with a semicircle around 0 i do not know how to show that $$\int_\pi^0 \frac{(1-\cos(\epsilon e^{i\theta}))}{(\epsilon e^{i\theta})^2}\epsilon i e^{i\theta} \ d\theta=-\pi$$
cause if i do that i would have $$2\int_0^\infty \frac{1-\cos(x)}{x^2} \ dx -\pi= 0$$
thanks :]
 A: Well, the function under the integral is symmetric so you can write it like:
$$\int_0^\infty \frac{1-\cos(x)}{x^2}dx=\frac{1}{2}\int_{-\infty}^\infty \frac{1-\cos(x)}{x^2}dx.$$
And then apply Jordan's lemma.
 So $$\frac{1}{2}\int_{-\infty}^\infty \frac{1-\cos(x)}{x^2}dx=\frac{1}{2}\operatorname{Re}\int_{-\infty}^\infty \frac{1-e^{ix}}{x^2}dx$$
A: No need to use a semicircle:
$$
\begin{align}
\int_0^\infty \frac{1-\cos x}{x^2}\mathrm dx
&=
\frac12\int_{-\infty}^\infty \frac{1-\cos x}{x^2}\mathrm dx
\\
&=
\frac12\Re\int_{-\infty}^\infty \frac{1-\mathrm e^{\mathrm ix}}{x^2}\mathrm dx
\\
&=
\frac12\Re\int_{-\infty}^\infty \frac{1-\mathrm e^{\mathrm ix}+\mathrm ix/(1+x^2)}{x^2}\mathrm dx\;.
\end{align}
$$
Now you can integrate over the entire real axis and close the contour in the upper half plane, enclosing the pole at $x=\mathrm i$.
A: Since $|\cos(z)|$ is large when $|\text{Im}(z)|$ is large, you don't want to integrate this directly around your semicircle.  Instead of $\cos(z)$, use $\exp(iz)$.  Now $\dfrac{1-\exp(iz)}{z^2}$ has a pole at $0$, so exclude that using a small semicircle inside your large semicircle.  There should be no singularities inside your contour, so Cauchy's theorem 
can be used, but you'll want to do the integral over the small semicircle, e.g. using a Laurent series. 
A: I think you'll get plenty of hints/answers and I know that I can get downvoted for this but the straightforward integration will give you the correct answer, too, and in this case it is not that hard.
So this is not an answer on you question but:
$$\int_0^\infty \frac{1-\cos(x)}{x^2}dx=2\int_0^\infty \frac{\sin\left(\frac{x}{2}\right)^2}{x^2}dx$$
or setting $\frac{x}{2}=y$
$$\int_0^\infty \frac{1-\cos(x)}{x^2}dx=\int_0^\infty \left(\frac{\sin(y)}{y}\right)^2dy$$
The latter integral is is easily done:
$$\int \left(\frac{\sin(y) }{y}\right)^2 \, dy=\text{Si}(2 y)-\frac{\sin(y)^2}{y}$$
Put the limits and remember that $\text{Si}(0)=0, \ \text{Si}(\infty)=\frac{\pi }{2}$
So you will have:
$$\int_0^\infty \frac{1-\cos(x)}{x^2}dx=\frac{\pi }{2}$$
