Integration of $\int_0^{\pi/2}\frac{d\theta}{a^2+b^2\cos^2(\theta)}$ gives results such that $\tan(\pi/2)$ comes which is "undefined". How to proceed? Integrating the below equation:
$$\int_{0}^{\pi/2}\frac{d\theta}{a^2+b^2\cos^2(\theta)}$$
gives,
$$\frac{1}{\left| a \right|\sqrt{a^2+b^2}}\left[\arctan\left(\frac{   a\tan(\theta)}{\sqrt{a^2+b^2}}\right)\right]_{0}^{\pi/2}$$
This portion $\arctan\!\Big(\frac{a\tan(\pi/2)}{\sqrt{a^2+b^2}}\Big)$ gives $\tan(\pi/2)$ which is "undefined", so how can we proceed with the following resulted equation as below: [This is the answer mentioned in the book to be proven as the result]
$$\frac{\pi}{2\left| a \right|\sqrt{a^2+b^2}}$$

Assume that $a>0$. You have\begin{align}\int_0^{\pi/2}\frac1{a^2+b^2\cos^2\theta}\,\mathrm d\theta&=\int_0^{\pi/2}\frac{\sec^2\theta}{a^2\sec^2\theta+b^2}\,\mathrm d\theta\\&=\frac1a\int_0^{\pi/2}\frac{a\sec^2\theta}{a^2\tan^2(\theta)+a^2+b^2}.\end{align}Now, if you do $x=a\tan\theta$ and $\mathrm dx=a\sec^2(\theta)\,\mathrm d\theta$, your integral becomes$$\frac1a\int_0^\infty\frac1{x^2+a^2+b^2}\,\mathrm dx=\frac\pi{2a\sqrt{a^2+b^2}}=\frac\pi{2|a|\sqrt{a^2+b^2}},$$since$$\int\frac1{x^2+a^2+b^2}\,\mathrm dx=\frac1{\sqrt{a^2+b^2}}\arctan\left(\frac x{\sqrt{a^2+b^2}}\right).$$And if $a<0$, then\begin{align}\int_0^{\pi/2}\frac1{a^2+b^2\cos^2\theta}\,\mathrm d\theta&=\int_0^{\pi/2}\frac1{(-a)^2+b^2\cos^2\theta}\,\mathrm d\theta\\&=\frac\pi{2(-a)\sqrt{a^2+b^2}}\\&=\frac\pi{2|a|\sqrt{a^2+b^2}}.\end{align}
