$$P.V.\int_{-\infty}^\infty \frac{\cos 3x}{x^2+4}dx=\operatorname{Re} P.V.\int_{-\infty}^\infty \frac{e^{i3x}}{x^2+4}dx$$
P.V.=(principal value)
I need help understanding why this "trick" works and when it is applicable.
I know that: $$P.V.\int_{-\infty}^\infty \frac{\cos 3x}{x^2+4}dx=P.V.\frac{1}{2}\int_{-\infty}^\infty \frac{e^{i3x}}{x^2+4}dx+P.V.\frac{1}{2}\int_{-\infty}^\infty \frac{e^{-i3x}}{x^2+4}dx$$
You just use the euler identity $$ e^{zi}=\cos(z)+\sin(z)i. $$ If $z\in\mathbb R$, you get $\sin(z),\cos(z)\in\mathbb R$ and $Re(e^{zi})=\cos(z)$.