Let p(x) be some polynomial function. Now, we have an integral of the form :
$$I=\int_{-\infty}^{\infty} \frac{\cos(x)}{p(x)}dx$$
What is usually done is that, we define this integral as :
$$I'=\int_{-\infty}^{\infty} \frac{e^{iz}}{p(z)}dz$$
Then we use the residue theorem, to integrate over the upper half of the complex plane. This gets separated into two integrals, over the curve and over the real axis. We can show that as $R\rightarrow\infty$, the integral over the curve vanishes, and we are left with just the integral over the real axis.
Then we use the fact that $\cos(x)$ is just the real part of $e^{ix}$. So, comparing the real parts of the solution, we find the answer to our initial problem.
My question is, why do we need to take $e^{iz}$ in the first place ? Is there some reason why we can't work with $\cos(x)$ directly?
Moreover, depending on how we proceed, we can get different values of the residue.
Consider the function $$f(z)=\frac{\cos(z)}{z^2}$$
Expanding using a taylor series, we can see, the $z^-1$ term doesn't exist, and so the residue is $0$. Similarly, if I use the exponential, then I can use the following formula : $$Re(z=0)=\frac{1}{1!}\frac{d}{dz}(z-0)^2\frac{e^{iz}}{z^2}|_{z=0} = i$$
Hence, depending on what function I use, I'd get different values of the residue.
The same thing happens for the function : $$f(z)=\frac{\cos(z)}{z^2}$$
I get the residue $\frac{\cosh(1)}{2i}$ or $\frac{1}{2ei}$ depending on whether I take the exponential or keep my cosine function.
So, why do we replace trigonometric functions with complex exponentials in these problems ?
I think this has something to do with the integral over the curve as $R\rightarrow\infty$. Any help in understanding this would be highly appreciated.
Just for fun, I will try a trigonometric integral without using complex exponential. In the process we will see why we can keep the trigonometric function -- or, why we can't, depending on the function.
$I(a) = \int_0^{\pi/2}(\tan x)^a dx,-1<a<1.$
We construct the function $f(z)=(\tan z)^a$ with branch cuts where the tangent is negative and then draw a contour with seven parts that avoid these cuts:
I) horizontal segment from $\epsilon+0i$ to $(\pi/2-\epsilon)+0i$
II) arc from $(\pi/2-\epsilon)+0i$ to $\pi/2+\epsilon i$
III) vertical segment from $\pi/2+\epsilon i$ to $\pi/2+M i$
IV) horizontal segment from $\pi/2+M i$ to $-\pi/2+M i$
V) vertical segment from $-\pi/2+M i$ to $-\pi/2+\epsilon i$
VI) horizontal segment from $-\pi/2+\epsilon i$ to $0+\epsilon i$
VII) arc from $0+\epsilon i$ to $\epsilon+0i$
In these definitions $\epsilon$ is a positive number that approaches $0$ and $M$ is a positive number that increases without bound.
We then have the following contributions, which sum to $0$ because the function has no singularities inside the contour:
I) tends to $I(a)$ as $\epsilon\to0$
II) converges to $0$ by comparison with $\epsilon^{1-a}$ (from the length times the magnitude of the function) with $a<1$
III,V) cancel out due to the periodicity of the tangent function and the opposite path directions
IV) tends to $(-\pi)(i^a)=(-\pi)[\cos(\pi a/2)+i\sin(\pi a/2)]$ as $M\to\infty$ from the limiting value if the tangent function $=i$.
VI) tends to $(-1)^aI(a)=[\cos(\pi a)+i\sin(\pi a)]I(a)$ from the odd function relation $\tan(-z)=-\tan z$
VII) converges to $0$ by comparison with $\epsilon^{1+a}$ (from the length times the magnitude of the function) with $a>-1$
Summing the nonzero, noncancelling contributions IV, I, VII to zero gives
$\pi[\cos(\pi a/2)+i\sin(\pi a/2)]=I(a)[1+\cos(\pi a)+i\sin (\pi a)]$
$=I(a)[2\cos(\pi a/2)][\cos(\pi a/2)+i\sin(\pi a/2)]$
Thus
$I(a)=(\pi/2)\sec(\pi a/2).$
Yup, we got the integral without resorting to complex exponentials in this case. And it is well defined in the expected range $-1<a<1$.
A key reason we were able to use the trigonometric function directly in this calculation is the function remained bounded in the range where the integration path tends to infinity; the tangent function converges to $i$ with a positive imaginary part or to $-i$ with a negative imaginary part. With sines and cosines, however, the trigonometric function becomes unbounded at infinity instead. So, to keep the contour integral under control with sines and cosines we resort to complex exponentials which (if we are lucky and choose the exponential skillfully) will remain bounded.