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.

 A: Rewrite the integral as a telescope series
\begin{align}
&\int_0^\infty \dfrac{|\cos (\pi x)|}{4x^2 - 1}\,dx \\
=& \ \frac12 \sum_{k=0}^\infty\int_{k }^{k+1} \left( \frac{ |\cos {\pi x}|}{2x-1} -\frac{ |\cos {\pi x}|}{2x+1} \right) \overset{x=k+y}{dx }\\
 =& \ \frac12 \sum_{k=0}^\infty \bigg( \int_{0}^{1}  \frac{ |\cos {\pi y}|}{2y+2k-1} dy-\int_0^1 \frac{ |\cos {\pi y}|}{2y+2k+1} {dy  }\bigg)\\
 =& \ \frac12\int_{0}^{1} \frac{ |\cos {\pi y}|}{2y-1} \ dy\overset{2y\to t}= \frac14\int_{-1}^{1} \frac{ |\sin {\frac{\pi t}2}|}{t}\ dt=0\\
\end{align}
where the last integral vanishes due to odd integrand.
A: For starters, Fourier series give
$$ \left|\cos(\pi x)\right| = \frac{2}{\pi}+\frac{4}{\pi}\sum_{n\geq 1}\frac{(-1)^{n+1}}{(2n-1)(2n+1)}\cos(2\pi n x)=1+\frac{8}{\pi}\sum_{n\geq 1}\frac{(-1)^n}{(2n-1)(2n+1)}\sin^2(\pi n x) $$
and if $n$ is odd then $\int_{0}^{+\infty}\frac{\sin^2(\pi n x)}{4x^2-1}\,dx = 0$, so the answer is given by
$$ \int_{0}^{+\infty}\frac{1}{4x^2-1}\left(1- \frac{8}{\pi}\sum_{m\geq 0}\frac{\sin^2((2m+1)x)}{(4m+1)(4m+3)}\right)\,dx = \frac{8}{\pi}\int_{0}^{+\infty}\frac{1}{4x^2-1}\sum_{m\geq 0}\frac{\cos^2((2m+1)x)}{(4m+1)(4m+3)}\,dx. $$
Since $\int_{0}^{+\infty}\frac{\cos^2((2m+1)x)}{4x^2-1}\,dx $ also equals zero, the value of the integral is zero.
A: $$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$$
A: 
I was writing my answer and the other answers came up. So I just solved for the undefinite case.

Well, we are trying to solve:
$$\mathcal{I}\left(x\right):=\int\frac{\left|\cos\left(\pi x\right)\right|}{4x^2-1}\space\text{d}x\tag1$$
Assume positive factors and add correction factors, so we can write:
$$\mathcal{I}\left(x\right)=\frac{\cos\left(\pi x\right)}{\left|\cos\left(\pi x\right)\right|}\int\frac{\cos\left(\text{n}x\right)}{4x^2-1}\space\text{d}x\tag2$$
Perform partial fraction decomposition:
$$\mathcal{I}\left(x\right)=\frac{1}{2}\cdot\frac{\cos\left(\pi x\right)}{\left|\cos\left(\pi x\right)\right|}\cdot\left(\int\frac{\cos\left(\pi x\right)}{2x-1}\space\text{d}x-\int\frac{\cos\left(\pi x\right)}{2x+1}\space\text{d}x\right)\tag3$$
Make two substitutions for the first integral $\text{u}=2x\pm1$ and $\text{v}=\frac{\pi\text{u}}{2}$, so we end up with:
$$\int\frac{\cos\left(\pi x\right)}{2x\pm1}\space\text{d}x=\pm\frac{1}{2}\int\frac{1}{\text{u}}\cdot\sin\left(\frac{\pi\text{u}}{2}\right)\space\text{du}=\pm\frac{1}{2}\int\frac{\sin\left(\text{v}\right)}{\text{v}}\space\text{du}=\text{C}\pm\frac{1}{2}\cdot\text{Si}\left(\text{v}\right)\tag4$$
So, we get:
$$\mathcal{I}\left(x\right)=-\frac{1}{4}\cdot\frac{\cos\left(\pi x\right)}{\left|\cos\left(\pi x\right)\right|}\cdot\left(\text{Si}\left(\frac{\pi\left(2x-1\right)}{2}\right)+\text{Si}\left(\frac{\pi\left(2x+1\right)}{2}\right)\right)+\text{C}\tag5$$
A: $$
I=\int^{\infty}_{0}\frac{|\cos(\pi x)|}{4x^2-1}dx.
$$
Set
$$
I(\epsilon):=\int^{1/2-\epsilon}_{0}\frac{|\cos(\pi x)|}{4x^2-1}dx+\int^{\infty}_{1/2+\epsilon}\frac{|\cos(\pi x)|}{4x^2-1}dx.
$$
and
$$
I_1(\epsilon)=\int^{1/2-\epsilon}_{0}\frac{|\cos(\pi x)|}{4x^2-1}dx=\frac{1}{4}\int^{1/2-\epsilon}_{0}\frac{|\cos(\pi x)|}{x-\frac{1}{2}}dx-\frac{1}{4}\int^{1/2-\epsilon}_{0}\frac{|\cos(\pi x)|}{x+\frac{1}{2}}=
$$
$$
=\frac{1}{4}\int^{1/2-\epsilon}_{0}\frac{\cos(\pi x)}{x-\frac{1}{2}}dx-\frac{1}{4}\int^{1/2-\epsilon}_{0}\frac{\cos(\pi x)}{x+\frac{1}{2}}dx=\frac{1}{4}\left(Si\left(\pi \epsilon\right)-Si\left(\pi-\epsilon\right)\right),
$$
where $Si(x)$ is the sine integral (see here) defined as
$$
Si(z)=\int^{z}_{0}\frac{\sin(t)}{t}dt
$$
and it is an entire function. By known arguments one can show
$$
\lim_{\epsilon\rightarrow 0^{+}}\left(Si(\pi \epsilon)-Si(\pi-\epsilon)\right)=-Si(\pi).
$$
Hence
$$
I_1=\lim_{\epsilon\rightarrow 0^{+}}I_1(\epsilon)=-\frac{Si(\pi)}{4}
$$
Also
$$
I_2(\epsilon)=\int^{\infty}_{1/2+\epsilon}\frac{\cos(\pi x)}{4x^2-1}dx
$$
and
$$
I_2=\lim_{\epsilon\rightarrow 0^{+}}I_2(\epsilon)=\int^{\infty}_{1/2}\frac{|\cos(\pi t)|}{4t^2-1}dt=4^{-1}\int^{\infty}_{0}\frac{|\sin(\pi t)|}{t(t+1)}.
$$
Obviously this last integral is uniformly convergent and if we split the path of integration to avoid the absolute values, we get
$$
I_2=4^{-1}\lim_{M\rightarrow+\infty}\sum^{M}_{k=0}(-1)^k\int^{k+1}_{k}\frac{\sin(\pi t)}{t(t+1)}dt=
$$
$$
=\frac{1}{4}\lim_{M\rightarrow+\infty}\left(Si(\pi)-Si(M+1)+Si(M+2)\right)=
$$
$$
=\frac{Si(\pi)}{4}.
$$
Hence
$$
I=\int^{\infty}_{0}\frac{|\cos(\pi x)|}{4x^2-1}dx=0.
$$
A: 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.
