If I want to evaluate the integral of real functions like $$\int_0^\infty f(x)\cos(ax) dx$$ where $a$ is a real constant, why can't I simply do contour integration by using the complex function $f(z)cos(az)dz$?
My Attempt
I know using Euler's formula that $\cos ax = e^{iax} - i\sin(ax)$ and based on other examples with integrals of this form, it seems like the correct corresponding complex function to solve is:
$\oint_C f(z)e^{iaz} = \pi iRe \Big\{ f(z)e^{iaz} \Big\}$, where C is the quarter circle contour. If this is true, I don't quite understand why.
Since all I know about $f(x)$ is that it's a rational function, I also don't know if $\int_0^\infty f(x)\cos(ax) dx = \frac{1}{2}\int_{-\infty}^\infty f(x)\cos(ax) dx $
I haven't covered Fourier Series yet and am working to solve this by using Residues.
Thanks!