<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] $$I=\int_0^{\frac{1}2} \frac{\cos(\pi x)}{4x^2-1}dx-\int_{\frac{1}2}^{\frac{3}2} \frac{\cos(\pi x)}{4x^2-1}dx+\int_{\frac{3}2}^{\frac{5}2} \frac{\cos(\pi x)}{4x^2-1}dx-\int_{\frac{5}2}^{\frac{7}2} \frac{\cos(\pi x)}{4x^2-1}dx+\cdots$$
Look at the first term:
$$\int_0^{\frac{1}2} \frac{\cos(\pi x)}{4x^2-1}dx=\frac{1}{2}\int_0^{\frac{1}2} \frac{\cos(\pi x)}{2x-1}-\frac{\cos(\pi x)}{2x+1}dx=\frac{1}2\int_{-\frac{1}2}^{\frac{1}2} \frac{\cos(\pi x)}{2x-1}dx$$
Similarly, the second term:
$$-\int_{\frac{1}2}^{\frac{3}2} \frac{\cos(\pi x)}{4x^2-1}dx=-\frac{1}2\int_{-\frac{3}2}^{-\frac{1}2} \frac{\cos(\pi x)}{2x-1}dx-\frac{1}2\int_{\frac{1}2}^{\frac{3}2} \frac{\cos(\pi x)}{2x-1}dx$$
So we can write the integral as:
$$I=\frac{1}2\sum_{k=-\infty}^\infty(-1)^k\int_{k-\frac{1}2}^{k+\frac{1}2}\frac{\cos(\pi x)}{2x-1}dx$$
Let $z=\pi x-k\pi+\frac{\pi}2$
$$I=\frac{1}4\int_{0}^{\pi}\sum_{k=-\infty}^\infty\frac{\sin(z)}{z+(k-1)\pi}dz=\frac{1}4\int_{0}^{\pi}\sin(z)\cot(z)dz=0$$
</s>