Residues at singularities I have the following question:  Show that the integral
$$\int_{-\infty}^{+\infty}\frac{\cos\pi x}{2x-1}dx = -\frac\pi2$$
Clearly there is a singularity at $z=1/2$ but I think this is a removable singularity so it has $0$ residue. Is this right or have I missed another singularity? If I am right, could someone help me to proceed with this question please because I'm not sure how to.
Thanks
 A: Consider
$$\oint_C dz \frac{e^{i \pi z}}{2 z-1}$$
where $C$ is a semicircle of radius $R$ in the upper half plane, with a small semicircular deformation of radius $\epsilon$ centered at $z=1/2$ in the upper half plane.  Then this contour integral is equal to
$$\int_{-R}^{1/2-\epsilon} dx \frac{e^{i \pi x}}{2 x-1} + i \epsilon \int_{\pi}^0 d\phi \, e^{i \phi} \frac{e^{i \pi (1/2+\epsilon e^{i \phi})}}{2 \epsilon e^{i \phi}}\\ +  \int_{1/2+\epsilon}^R dx \frac{e^{i \pi x}}{2 x-1}+ i R \int_0^{\pi} d\theta \, e^{i \theta} \frac{e^{i \pi R e^{i \theta}}}{2 R e^{i \theta}-1}$$
In the limit as $R \to\infty$, the fourth integral vanishes by Jordan's lemma.  As $\epsilon \to 0$, the second integral takes the value $\pi/2$.  Because there are no poles within the contour, the contour integral is zero.  Thus we have
$$PV \int_{-\infty}^{\infty} dx \frac{e^{i \pi x}}{2 x-1} = -\frac{\pi}{2}$$
where $PV$ denotes a Cauchy principal value.  Equating real and imaginary parts, we get
$$\int_{-\infty}^{\infty} dx \frac{\cos{\pi x}}{2 x-1} = -\frac{\pi}{2}$$
as was to be shown.
A: I think that you're really familiar with :
$$\int_{0}^{\infty}\dfrac{sinx}{x}=\dfrac{\pi}{2}$$
So $$I=\int_{-\infty}^{+\infty}\dfrac{cos(\pi x)}{2x-1}dt=\dfrac{1}{2}\int_{-\infty}^{+\infty}\dfrac{cos(\pi(\frac{t+1}{2}) )}{t}dt=\dfrac{1}{2}\int_{-\infty}^{+\infty}\dfrac{cos(\dfrac{\pi t}{2}+\dfrac{\pi}{2}) }{t}dt$$
$$=-\dfrac{1}{2}\int_{-\infty}^{+\infty}\dfrac{sin(\frac{\pi t}{2} )}{t}dt=-\dfrac{1}{2}\int_{-\infty}^{+\infty}\dfrac{sin(u)}{u}du=-\dfrac{1}{2}.2.\int_{0}^{+\infty}\dfrac{sin(u)}{u}du$$
$$=-\int_{0}^{+\infty}\dfrac{sin(u)}{u}du=-\dfrac{\pi}{2}$$
A: You are right, the function
$$f(z) = \frac{\cos \pi z}{2z-1}$$
is entire. However, to evaluate the integral, one considers a different function,
$$g(z) = \frac{e^{i\pi z}}{2z-1},$$
which has a pole in $z = \frac12$. We then have
$$\int_{-\infty}^\infty f(x)\,dx = \operatorname{Re} \int_{-\infty}^\infty g(x)\,dx.$$
The reason to use $g$ instead of $f$ is that directly, the Cauchy integral theorem and residue theorem only allow us to evaluate integrals over closed contours, and to evaluate an integral over the real line, we must know the limit behaviour of the integral over the auxiliary path closing the contour. If the integrand decays fast enough, we know that the integral over the auxiliary part tends to $0$. But $f(z)$ doesn't decay, since $\cos \pi z$ grows exponentially for $\lvert \operatorname{Im} z\rvert \to \infty$. So we replace it with a closely related function that decays fast, $e^{i\pi z} \to 0$ for $\operatorname{Im} z \to +\infty$, and that guarantees that the integral over the auxiliary part of the contour (in the upper half plane) tends to $0$, so we can use the residue theorem to evaluate that integral.
Since the pole lies on the real line, we have
$$\int_{-\infty}^\infty g(x)\,dx = \pi i \operatorname{Res}\left(g(z); \frac12\right),$$
only half of the residue counts.
A: You are correct that $\frac{\cos(\pi x)}{2x-1}$ is entire (i.e. has no singularities). However, if you try to use this function with the Residue Theorem on either of the usual arbitrarily large "D" shaped contours, you will see that $\frac{\cos(\pi x)}{2x-1}$ blows up on the semi-circular part of the contour.
We can over come this problem as follows. First note that by using the contour
$$
[-R,R]\cup\color{#C0C0C0}{[R,R{-}i]}\cup[R{-}i,-R{-}i]\cup\color{#C0C0C0}{[-R{-}i,-R]}
$$
we get
$$
\int_{-\infty}^\infty\frac{\cos(\pi x)}{2x-1}\,\mathrm{d}x
=\int_{-i-\infty}^{-i+\infty}\frac{\cos(\pi x)}{2x-1}\,\mathrm{d}x
$$
since the integrand vanishes on the gray portions of the contour as $R\to\infty$.
Next, break up $\cos(x)$ and use the contours
$$
\begin{align}
U&=[-R{-}i,R{-}i]\cup Re^{[0,\pi i]}{-}i\\
L&=[-R{-}i,R{-}i]\cup Re^{[0,-\pi i]}{-}i
\end{align}
$$
to get
$$
\begin{align}
\int_{-i-\infty}^{-i+\infty}\frac{\cos(\pi x)}{2x-1}\,\mathrm{d}x
&=\frac12\int_{-i-\infty}^{-i+\infty}\frac{e^{i\pi x}+e^{-i\pi x}}{2x-1}\,\mathrm{d}x\\
&=\frac12\int_U\frac{e^{i\pi x}}{2x-1}\,\mathrm{d}x
+\frac12\int_L\frac{e^{-i\pi x}}{2x-1}\,\mathrm{d}x\\
&=\frac12(2\pi i)\frac i2+0\\
&=-\frac\pi2
\end{align}
$$
since $\frac{e^{i\pi x}}{2x-1}$ has a pole at $x=\frac12$ with residue $\frac i2$ inside $U$ and $\frac{e^{-i\pi x}}{2x-1}$ has no pole inside $L$.
Note that $\frac{e^{i\pi x}}{2x-1}$ vanishes quickly on the circular part of $U$ and $\frac{e^{-i\pi x}}{2x-1}$ vanishes quickly on the circular part of $L$.
A: The other 4 answers to this problem are very good and have slightly different approaches, but they all rely on residue calculus. It is possible to do this without residue calculus by being clever and differentiating with respect to a parameter.
Note that $\dfrac{\cos \pi x}{2x - 1}$ is even around the point $x = \frac12$, i.e. that $\displaystyle \int_{-\infty}^\infty \dfrac{\cos \pi x}{2x - 1} dx = 2 \int_{-\infty}^{1/2} \dfrac{\cos \pi x}{2x - 1} dx$. So we will only look at this last integral. First, we center this integral in a reasonable way, very similar to SnowAngel6147.
Substituting $x \mapsto \frac12 - x$, and then later $x \mapsto x/\pi$, yields 
$$ - 2\int_\infty^{0}\frac{\cos(\frac{\pi}2 - \pi x)}{-2x}dx = \int_0^\infty \sin\pi x \frac{dx}{x} = \int_0^\infty \frac{\sin x}{x} dx.$$
(Aside: You may wonder why I like to write $dx/x$. It is because that measure is both inversion and scaling invariant, and is sort of the trivial example of a Haar Measure).
To evaluate this integral, we introduce the related 
$$I(a) = \int_0^\infty \frac{\sin x}{x} e^{-ax} dx,$$
so that we would like to evaluate $I(0)$. Differentiate with respect to $a$ (which is justified because we have exponential decay and the dominated convergence theorem) to get
$$I'(a) = -\int_0^\infty \sin x e^{-ax} dx = \left.-\frac{e^{-ax}(\cos x + a\sin x)}{1 + a^2}\right|_0^\infty = -\frac{1}{1+a^2}.$$
Integrating, we see that $I(a) = -\arctan(a) + C$ for some $C$. What is $C$? Notice that $\displaystyle \lim_{a \to \infty} I(a) = 0$ (dominated convergence again), so that $\displaystyle \lim_{a \to \infty} -\arctan(a) + C = 0$. This means that $C = \frac{\pi}{2}$.
And finally, we want $I(0)$, which is just $C$. Thus $I(0) = \dfrac{\pi}{2}$, and we have the answer.
