💼 Case: Consider the integral
$$ I=\int^\infin_{-\infin} \frac{1}{x^2+a^2} \,\text dx =\lim_{R\to \infin} \int^R_{-R} \frac{1}{x^2+a^2}\,\text dx $$
for $$ real $a>0$
We can solve this using the substitution $x=\tan \theta$
$$ \begin{aligned} I&=\lim_{R\to \infin} \left [ \frac{1}{a} \arctan \frac{x}{a} \right ] ^ R {-R} \\ &=\lim{R\to \infin} \frac{2}{a} \arctan \frac{R}{a}=\frac{2}{a}\frac{\pi}{2}=\frac{\pi}{a}
\end{aligned} $$
Solving using complex integration and residue theorem
$x=\real (z)$ so $\frac{1}{a^2 + z^2}\,\text dz = \frac{1}{a^2 + x^2}\,\text dx$ on the real axis, thus we can re-write it as
$$ \frac{1}{a^2+z^2} = \frac{1}{(z+ia)(z-ia)} $$
By using the following geometry we can write
$$ \begin{aligned} I_C&=\oint C \frac{1}{z^2+a^2}\,\text dz=I_1+I_2 \\ &= \int^R{-R} \frac{1}{z^2 +a^2} \,\text dz + \int^{-R}R \frac{1}{z^2 + a^2 } \,\text dz \\ I&=\lim{R\to \infin} I_1=\lim_{R\to \infin} [I_C- I_2] \end{aligned} $$
The result of the closed contour integral is
$$ \begin{aligned} I_C=\oint_C \frac{1}{z^2 + a^2 } \,\text dz &=2\pi\, \text{res}(ia) \\ &=2\pi i \lim_{z\to ia} \left [\frac{z-ia}{z^2+a^2} \right ] \\ &= 2\pi i \lim_{z\to ia} \left [ \frac{z-ia}{(z-ia)(z+ia)} \right ] \\ &=2\pi i \lim_{z\to ia} \left [ \frac{1}{z+ia} \right ] \\ &= \frac{\pi}{a} \end{aligned} $$
now we need to find $\lim_{R\to\infin}[I_C-I_2]$ using the estimation lemma we can write
$$ |I_2|=\left | \int^{-R}_R \frac{1}{z^2+a^2} \,\text dz \right | \le \frac{1}{R^2-a^2} \pi R $$
we see that as $R\to \infin$ then $I_2\to 0$ so
$$ I= \int^\infin_{-\infin} \frac{1}{x^2+a^2} \,\text dx=\lim_{R\to\infin}[I_C-I_2]=\lim_{R\to\infin}[I_C]=\frac{\pi}{a} $$
💼 Case: consider an integral of the form where $k>0$, $k\in \R$ and $\lim_{z\to\infin} f(z) =0$
$$ I=\int^\infin_{-\infin} f(x) e^{ikx} \, \text dx $$
Also assume $f(z)$ is meromorphic in the upper half plane, its only singularities are isolates poles
💃 Example: Take $f(x)=\frac 1{1+x^2}$
For real $k>0$ we write
$$ \oint\frac{e^{ikz}}{1+z^2} \,\text dz = I_1 + I_2 \qquad I=\lim_{R\to \infin} I_1 $$
To evaluate $I_2$ we use the lemma
$$ \left | \int_{I_2}\frac{e^{ikz}}{1+z^2}\,\text dz \right | \le \int_{I_2}\left | \frac{e^{ikz}}{1+z^2}\right | |\,\text dz | \le \underbrace{\int^\pi_0 \frac{e^{-kR\sin\theta}}{R^2-1}|i|R\left | e^{i\theta} \right |\,\text d\theta}_{\text{when }R\to \infin \quad =0} $$
Evaluate the closed contour integral
$$ \oint_C\frac{e^{ikz}}{1+z^2} \,\text dz = \oint _C \frac{e^{ikz}}{(z-i)(z+i)}\,\text dz $$
The pole at $z=i$ is enclosed by the contour, the residue is
$$ \text{res}(i) = \left ( \frac{e^{ikz}}{z+i} \right )_{z=i} =\frac{e^{-k}}{2i} $$
thus the result of the integral is
$$ I=\lim_{R\to\infin}(\pi e^{-k}-I_2)=\pi e^{-k} $$
If $k$ was negative we would have closed the contour in the lower half and obtained $I=\pi e^k$
💼 Case: consider
$$ I=\int^{2\pi}_0 \frac{1}{5+4\cos(\theta)}\,\text d\theta $$
To convert it to complex we use
$$ \boxed{z=e^{i\theta} \quad \text dz=ie^{i\theta}\,\text d\theta \quad \text d\theta =\frac{\text dz}{iz} \qquad \cos\theta=\frac 12 \left ( z + \frac{1}{z} \right ) \quad \sin\theta=\frac 1 {2i} \left ( z-\frac{1}{z} \right )} $$
Applying these we get
$$ \begin{aligned} I=\oint_C \frac{1}{5+2(z+\frac 1z)}\frac{\text dz}{iz}=\frac{1}{2i} \oint_C \frac{1}{(z+\frac{1}{2})(z+2)}\,\text dz
\end{aligned} $$