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

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.
