# Why must $r$ be put in modulus for $\int^{\infty}_0\frac{1-\cos(rx)}{x^2}dx=\frac{\pi}{2}|r|$?

Here's the question: Prove that $$\int^{\infty}_0\frac{1-\cos(rx)}{x^2}~\mathrm dx=\frac{\pi}{2}|r|·$$

When I finished my working, I got $$\frac{\pi}{2}r$$

Why is the $$r$$ put in modulus? Is it because the graph lies entirely above the x axis?

• Did you assume $r\geq 0$ in your working? Nov 10 '18 at 3:18
• The integral expression is visibly even in $r$. As for where the absolute value comes up in your derivation, that depends on your method, I suppose. Nov 10 '18 at 3:21
• Nope I didn't assume r greater than 0 as I thought there wasn't any need to do so Nov 10 '18 at 3:24
• Notice that for any real number $a$, $\cos(a) = \cos(-a)$. In particular, it suffices to solve the problem in the case $r \geq 0$. Nov 10 '18 at 3:49
• Note: the integrand is positive, so you could you get a negative answer? Nov 10 '18 at 13:55

Integrating by part: $$\int_0^{+\infty} \frac {1-\cos(rx)}{x^2}\, \mathrm dx = \int_{+\infty}^0 (1 - \cos(rx)) \mathrm d \frac 1 x =\left. \frac {1-\cos(rx)}x \right\vert_{+\infty}^0 - r\int_{+\infty}^0 \frac {\sin(rx)}x\, \mathrm dx = r \int_0^{+\infty} \frac {\sin(rx)}x \,\mathrm dx.$$ Now $$\DeclareMathOperator\sgn{sgn} \int_0^{+\infty} \frac {\sin(rx)}x \,\mathrm dx =\int_0^{+\infty} \frac {\sin(rx)}{rx}\,\mathrm d(rx)= \begin{cases}\displaystyle \int_0^{+\infty} \frac {\sin u}u\, \mathrm du, & r > 0,\\ 0, & r=0,\\ \displaystyle \int_{-\infty}^0 \frac {\sin u}u\, \mathrm du, & r < 0, \end{cases} = \sgn r \cdot \int_0^{+\infty} \frac {\sin u}u\, \mathrm du = \sgn r \cdot \frac \pi 2,$$ hence the integral equals $$r \sgn r \cdot \frac \pi 2 = \frac \pi 2 \vert r \vert.$$
The implicit assumption could be $$r>0$$ when dealing the integral $$\int_0^{+\infty} \sin(rx)\,\mathrm dx /x$$.
The other answers explain how you get $$|r|$$ in your answer, but here’s why it should happen:
Notice that $$1-\cos(rx) \geq 0$$ for all $$x$$, regardless of what $$r$$ is. Integrating a nonnegative function over any interval should give you a nonnegative value.