# How to compute the following real integrals using the residue theorem?

How to compute the following real integrals using the residue theorem:

$$\int_{-\infty}^{\infty} \frac{1}{(x^2+p^2)(x^2+q^2)} dx$$ $$\int_{0}^{2\pi} \frac{sin^2(\theta)}{5+4cos(\theta)} d\theta$$

Where for the first integral we have $p>q>0$. I was fine with calculating complex integrals using the residue theorem, however I am having trouble with these real integrals. As I understand it, for the second problem I can express $cos(\theta)$ as $$\cos\theta=\frac{1}{2}\left(e^{i\theta}+e^{-i\theta}\right)$$ However I do not see why this helps in the computation if I was to substitute this in.

As for the first problem I am unsure how to tackle the problem.

Thanks for any help

If $p$ and $q$ are two different positive real numbers then: $$\int_{\mathbb{R}}\frac{dz}{(z^2+p^2)(z^2+q^2)}=2\pi i \sum_{\xi\in\{ip,iq\}}\operatorname{Res}\left(\frac{1}{(z^2+p^2)(z^2+q^2)},z=\xi\right)\tag{1}$$ so: $$\int_{\mathbb{R}}\frac{dz}{(z^2+p^2)(z^2+q^2)} = \frac{\pi}{pq(p+q)}.\tag{2}$$ About the second integral, $$\int_{0}^{2\pi}\frac{\sin^2\theta}{5+4\cos\theta}\,d\theta = 2\int_{0}^{\pi}\frac{\sin^2(2\theta)}{5+4\cos(2\theta)}\,d\theta = 8\int_{0}^{\pi}\frac{\sin^2\theta \cos^2\theta}{1+8\cos^2\theta}\,d\theta$$ hence by replacing $\theta$ with $\arctan t$ we have: $$\int_{0}^{2\pi}\frac{\sin^2\theta}{5+4\cos\theta}\,d\theta = 16\int_{0}^{\pi/2}\frac{\sin^2\theta \cos^2\theta}{1+8\cos^2\theta}\,d\theta = 16\int_{0}^{+\infty}\frac{t^2\,dt}{(1+t^2)^2(9+t^2)}$$ and the last integral can be approached like the first one, leading to: $$\int_{0}^{2\pi}\frac{\sin^2\theta}{5+4\cos\theta}\,d\theta = \frac{\pi}{4}.\tag{3}$$