Cauchy's Residue Theorem to find an integral

I want to calculate $$\int_{-\infty}^\infty \frac{cos(\pi x)}{2x-1}dx$$ using Cauchy's Residue Theorem.

First, since $$\frac{cos(\pi x)}{2x-1} = Re(\frac{e^{i\pi x}}{2x-1})$$, I can simply compute real part of the integral $$\int_{-\infty}^\infty \frac{e^{i\pi x}}{2x-1}dx$$. So I will use the positively oriented curve $$\Gamma$$ consisting of the interval $$[-R, R]$$ and the upper semicircle $$\gamma^+(0, R)$$ to integrate. The integrand has a simple pole at $$x = \frac{1}{2}$$. Using the formula for residues at simple poles, the residue at $$x=\frac{1}{2}$$ is $$\frac{e^{i\pi x}}{2}|_{x=2} = \frac{e^{\frac{i\pi}{2} }}{2}$$. So by Cauchy's Residue Theorem, $$\int_{-\infty}^\infty \frac{e^{i\pi x}}{2x-1}dx$$ = $$Re(\int_\Gamma \frac{e^{i\pi x}}{2x-1}dx$$) = Re($$2\pi i \frac{(cos(\frac{\pi}{2})+i sin(\frac{\pi}{2})}{2})$$ = $$-\pi$$.

But when I put this integral in a calculator, I get the result $$\frac{-\pi}{2}$$. Where have I gone wrong? Where do I get this half from? If the method I used cannot be applied, how can I calculate this integral in a similar way?

• Note that you're using Residue Theorem out of the hypothesis. You are integrating over a contour that contains a pole of your function and thus the theorem doesn't apply. Nov 19, 2021 at 12:59
• You have a pole which lies exactly on the contour you defined. The function is not defined on the contour.
– Mark
Nov 19, 2021 at 13:00
• Oh, I see... Am I still able to compute the integral in a similar way? Nov 19, 2021 at 13:02
• Pretty sure it's a removable singularity, though, since $\lim_{x\to\frac12} \cos(\pi x)/(2x-1) = -\pi/2$. Nov 19, 2021 at 13:02
• Also note that under the substitution $y = x - \frac{1}{2}$, this integral becomes $$-\frac{1}{2} \int_{-\infty}^\infty \frac{\sin(\pi y)}{y}\, dy.$$So if you know how to do the sinc integral, the same technique could be applied here. Nov 19, 2021 at 13:10

When you switch your integrand to $$e^{i \pi x}/(2x-1)$$, you introduced a pole at $$x = \frac{1}{2}$$. This means that you need to pick a contour that avoids this point; you can't just run over it.
The standard technique for situations like this is to use a contour that yields the Cauchy principal value of the integral instead. This consists of the contour you used, but with a small semicircle of radius $$\epsilon$$ centered at the pole. This portion of the contour will have a non-zero contribution to the integral, which is (usually) easy to find in the limit $$\epsilon \to 0$$; and in this same limit, the portion of the integral over the real axis becomes the principal value of the integral. Finally, we can take the real part of the principal value to get the original integral we wanted.