How to solve $\int_{0}^{\frac{π}{2}} \frac{dx}{4\sin^2(x) +5\cos^2(x)} $ $?$ I apply the substitutions:
$$t=\tan(x), \sin(x)=\frac{t}{\sqrt{1+t^2}}, \cos(x)=\frac{1}{\sqrt{1+t^2}}\ \&\ dx=\frac{dt}{1+t^2}$$
(using $t=\tan(x)$ you can draw a right angled triangle to find the other substitutions)
So we get:
$$\int_{0}^{\frac{π}{2}} \frac{1}{\frac{4t^2}{1+t^2}+\frac{5}{1+t^2}}\frac{dt}{1+t^2}=\frac{1}{4}\int_{0}^{\frac{π}{2}} \frac{1}{t^2+\Big(\frac{\sqrt{5}}{2}\Big)^2} dt$$
This is in a standard integral form, thus:
$$\frac{1}{4}\cdot\frac{2}{\sqrt{5}}\tan^{-1}\Bigg(\frac{2t}{\sqrt{5}}\Bigg)=\frac{1}{2\sqrt{5}}\tan^{-1}\Bigg(\frac{2\tan(x)}{\sqrt{5}}\Bigg)$$
this is from $0$ to $π/2$.
But I can't substitute for $π/2$, because $\tan(x)$ is undefined for $π/2$. If I input this integral into Mathcad I get $\frac{π\sqrt{5}}{20}$. How can I get the right answer out of this? Thanks in advance!

Suppose we seek to evaluate
$$\int_0^{\pi/2} \frac{1}{4\sin^2(x)+5\cos^2(x)} dx
= \frac{1}{4} \int_0^{2\pi} \frac{1}{4\sin^2(x)+5\cos^2(x)} dx.$$
Introduce $z=\exp(ix)$ so that $dz=iz \; dx$ to get
$$\frac{1}{4}\int_{|z|=1}
\frac{1}{4(z-1/z)^2/(-4)+5(z+1/z)^2/4} \frac{dz}{iz}
\\ = \int_{|z|=1}
\frac{1}{-4(z-1/z)^2+5(z+1/z)^2} \frac{dz}{iz}
\\ = \int_{|z|=1}
\frac{z^2}{-4(z^2-1)^2+5(z^2+1)^2} \frac{dz}{iz}
\\ = \frac{1}{i} \int_{|z|=1}
\frac{z}{-4(z^2-1)^2+5(z^2+1)^2} \; dz
\\ = \frac{1}{i} \int_{|z|=1}
\frac{z}{z^4 + 18z^2 + 1} \; dz.$$
We have $$z^4 + 18z^2 + 1 = (z^2+9)^2 - 80$$
so we get for the poles
$$\rho_{1,2,3,4} = \pm\sqrt{\pm\sqrt{80} -9}.$$
Now have by inspection that only the two poles
$$\rho_{1,2} = \pm\sqrt{\sqrt{80} -9}$$
contribute being inside the unit circle and we get for the integral
$$\frac{1}{i} 2\pi i
(\mathrm{Res}(f(z); z=\rho_1)
+ \mathrm{Res}(f(z); z=\rho_2))$$
where we have set
$$f(z) = \frac{z}{z^4 + 18z^2 + 1}.$$
These residues are
$$\left.\frac{z}{4z^3+36z}\right|_{z=\rho_{1,2}}
= \left.\frac{1}{4z^2+36}\right|_{z=\rho_{1,2}}
= \frac{1}{4}\left.\frac{1}{z^2+9}\right|_{z=\rho_{1,2}}.$$
By definition of $\rho_{1,2}$ we have $\rho_{1,2}^2 + 9
= \sqrt{80}$ so we finally obtain
$$\frac{1}{i} 2\pi i \times 2\times\frac{1}{4} \frac{1}{\sqrt{80}}
= \pi \frac{1}{\sqrt{80}}
= \frac{\pi}{4\sqrt{5}}.$$
