<s>[INST] find $\int_0^\infty \frac{|\cos (\pi x)|}{4x^2 - 1} dx$ 
Find (with proof) $\displaystyle\int_0^\infty \frac{|\cos (\pi x)|}{4x^2 - 1}dx$

It's actually not even clear that the integral converges. If there were only sines/cosines in the integral, a standard technique would be to use the trigonometric identity $\sin \theta = \frac{2t}{1+t^2}$, $\cos \theta = \frac{1-t^2}{1+t^2}$, $t = \tan(\theta/2)$. I know that $\frac{2}{4x^2-1} = \frac{1}{2x-1} -\frac{1}{2x+1}$, so maybe one could plug this into the given integral to obtain an integral that's easier to evaluate?

Edit: from a comment, I think it would be useful to note that $\cos (\pi x) \leq 0$ iff $(2k+1/2)\pi \leq \pi x \leq (2k + 3/2)\pi\iff(2k + 1/2)\leq x\leq 2k+3/2$ (for some integer $k$) and $\cos(\pi x) \ge 0$ iff $(2k - 1/2) \leq  x \leq (2k+1/2)$ (for some integer $k$). So we can split the integral according to these ranges. Then it might be useful to apply integration by parts. Let $a\in \mathbb{R}$. Then
$$\begin{align}\int \frac{\cos(ax)}{4x^2-1}dx &= \frac{1}2\left(\int \frac{\cos(a x)}{2x-1}dx - \int \frac{\cos(a x)}{2x+1}dx\right)\\
\\
&= \frac{1}2\left(\frac{1}2 \ln(2x-1)\cos (ax) +\frac{1}2a \int \sin(ax)\ln(2x-1)dx\right) \\
\\&-\frac{1}2\left(\frac{1}2 \ln(2x+1)\cos (ax) +\frac{1}2a \int \sin(ax)\ln(2x+1)dx\right)\end{align}$$

but I'm not sure how to simplify the result.

For the bounty, I'm looking for formal proofs. In particular, I'd like to see justifications for interchanging an integral and a sum. One can freely interchange an integral and a sum if the terms are nonnegative (as $\sum \int f_n = \int \sum f_n$ for nonnegative Lebesgue measurable functions $f_n$ and the Lebesgue integral equals the Riemann integral for Riemann integrable functions).


Also I'd like to see justifications for why $$\int_0^\infty \frac{\cos^2(\pi (2m+1) x)}{4x^2 - 1}dx = 0 = \int_0^\infty \frac{\sin^2(\pi (2m+1)x)}{4x^2-1} dx,$$ where $m$ is any nonnegative integer.

 [/INST] Since others addressed the first part of the question, I will look at the second part
$$\int_0^\infty \dfrac{\cos^2(\pi (2m+1) x)}{4x^2 - 1}dx = 0 = \int_0^\infty \dfrac{\sin^2(\pi (2m+1)x)}{4x^2-1} dx$$
To confirm or deny this statement let is consider the following integrals
$$\int_0^\infty \dfrac{\cos^2(b x)}{1+a^2x^2}dx=\frac{\pi}{4a}\left(1+e^{-\frac{2b}{a}}\right)$$
$$\int_0^\infty \dfrac{\sin^2(b x)}{1+a^2x^2}dx=\frac{\pi}{4a}\left(1-e^{-\frac{2b}{a}}\right)$$
$a$ and $b$ are parameters
Now, replace $a$ with $ia$ where $i$ is the imaginary unit.
After separating real and imaginary parts we get formal equalities
$$\int_0^\infty \dfrac{\cos^2(b x)}{1-a^2x^2}dx=\frac{\pi}{4a}\sin \left( \frac{2b}{a}\right)-i\frac{\pi}{4a}\left[\cos \left( \frac{2b}{a}\right)+1\right]$$
$$\int_0^\infty \dfrac{\sin^2(b x)}{1-a^2x^2}dx=-\frac{\pi}{4a}\sin \left( \frac{2b}{a}\right)+i\frac{\pi}{4a}\left[\cos \left( \frac{2b}{a}\right)-1\right]$$
Obviously, if the imaginary part is different from zero then the integrals diverge or are undefined.
But they have so called the Cauchy Principal Value wich is given by the real part
$$PV\int_0^\infty \dfrac{\cos^2(b x)}{1-a^2x^2}dx=\frac{\pi}{4a}\sin \left( \frac{2b}{a}\right)$$
$$PV\int_0^\infty \dfrac{\sin^2(b x)}{1-a^2x^2}dx=-\frac{\pi}{4a}\sin \left( \frac{2b}{a}\right)$$
where $PV$ indicates the Cauchy Principal Value.
If we take $a=2$ then in order for these expressions to be zero $b$ must take values $$b=\pi m$$
where $m$ is an integer, positive or negative.
So the equality on the top of this post is correct. These integrals converge to zero.
If the imaginary part in an expression above is zero then we have a convergent integral. For example if we take $\frac{2b}{a}=\pi$ then
$$\int_0^\infty \dfrac{\cos^2(\frac{a \pi}{2}x)}{1-a^2x^2}dx=0$$
This is really convergent integral.
</s>