Integration with $\int_0^\infty \frac{\cos (ax)}{x^2}dx$ I am trying to integrate $$\int_0^\infty \frac{\cos (ax)}{x^2}dx$$
I get $$-a\operatorname{Si}(ax)-\frac{\cos(ax)}{x}+C$$ as indefinite integral and when I put limits, I understand how to get $-\frac{{\pi}a}{2}$ for the Sine integral. But I don't understand how to put limits for the second term, it seems to me that term goes to infinity. Any help?
Edit:
Sorry for not being clear,
I am trying to integrate this integral $$D_1=\frac4\pi\int_0^\infty\frac{d\lambda}{\lambda^2}\sin\lambda q_1\sin\lambda q_2\sin\lambda q_3\sin\lambda q_4,\tag{25}$$
which I converted to sum of cosines
$$\sum\ \eta_1\eta_2\eta_3\eta_4\frac{\cos ((\eta_1q_1+\eta_2q_2+\eta_3q_3+\eta_4q_4)\lambda)}{16}, \eta_{1,2,3,4}= \pm1$$
I am supposed to get these results,

*

*For $q_1+q_2>q_3+q_4$ and $q_1+q_4>q_2+q_3$, $$D_1=\frac12(q_2+q_3+q_4-q_1)\tag{30}$$

*For $q_1+q_2>q_3+q_4$ and $q_1+q_4<q_2+q_3$, $$D_1=q_4\tag{33}$$
I am trying to reproduce calculations given in the Appendix A of this paper.
 A: Since the arguments of your cosines sum to zero, as NHL points out your problem amounts to evaluating $\int_0^{\infty}\frac{\cos(a x)-1}{x^2}\,dx$, $a\in\mathbb{R}$. This can be done with integration by parts (let $dv=x^{-2}\,dx$) and, using $\int_0^{\infty}\frac{\sin(a x)}{x}\,dx=\frac{\pi}{2}$ for $a>0$, each subintegral evaluates to $-\frac{\pi}{2}|a|$. Thus,
$$
D_1=\frac{1}{4} \bigg(-\left| q_1+q_2-q_3-q_4\right| -\left|
   q_1-q_2+q_3-q_4\right| +\left| q_1+q_2+q_3-q_4\right| -\left|
   q_1-q_2-q_3+q_4\right| +\left| q_1+q_2-q_3+q_4\right| +\left|
   q_1-q_2+q_3+q_4\right| +\left| -q_1+q_2+q_3+q_4\right| -\left|
   q_1+q_2+q_3+q_4\right| \bigg)
$$
In particular, if you can impose conditions on the $q_i$, you can simplify this expression accordingly.
A: Whilst the specified integral does not converge, the following does:
$$I(a)=\int_0^\infty\frac{\cos(ax)-1}{x^2}dx$$
$$I'(a)=-\int_0^\infty\frac{\sin(ax)}{x}dx$$
now make the substitution:
$$u=ax\Rightarrow dx=\frac{du}a$$
and you will see that:
$$I'(a)=-\int_0^\infty\frac{\sin(x)}{x}dx$$
and this is called the Dirichlet integral so we know its value:
$$I'(a)=-\frac\pi2$$
Now we can integrate to get:
$$I(a)=-\frac\pi2 a+C$$
now since we know that $I(0)=0$ we can say $C=0$ which finally gives us:
$$\int_0^\infty\frac{\cos(ax)-1}{x^2}dx=-\frac{\pi a}{2}$$
