Evaluate the integral $\int_0^{\pi} \frac{dx}{a^2\sin^2{x}+b^2\cos^2{x}}$ where $ab\neq 0$ I’ve got some problems evaluating the integral $\int_0^{\pi} \frac{dx}{a^2\sin^2{x}+b^2\cos^2{x}}$. I’ve found a solution in my textbook as follows: 
The integral 
$\int \frac{dx}{a^2\sin^2{x}+b^2\cos^2{x}}=\frac{1}{ab}\arctan(\frac{a}{b}\tan{x})+C$
Hence by Newton-Leibniz Formulas, $\int_0^{\pi} \frac{dx}{a^2\sin^2{x}+b^2\cos^2{x}}= \frac{1}{ab}\arctan(\frac{a}{b}\tan{x})|_0^{\pi}=0$. 
But it doesn’t make sense. $F(x)=\frac{1}{ab}\arctan(\frac{a}{b}\tan{x})$ is not continuous where $x=\frac{\pi}{2}$.
Am I right? Or how to evaluate this integral?
And a Cauchy’s example. 
$\int_0^{\frac{3\pi}{4}} \frac{\sin{x}}{1+\cos^2{x}} dx=\arctan(\sec{x})|_0^{\frac{3\pi}{4}}=-\arctan\sqrt{2}-\frac{\pi}{4}.$
The second $=$ is wrong because $\arctan(\sec{x})$ is not continuous where $x=\frac{\pi}{2}$ so that we cannot use Newton-Leibniz formula. 
Am I right???

The integrand is $\pi$-periodic and even around $0$.  Therefore, 
$$\begin{align}
\int_0^\pi \frac{1}{a^2\sin^2(x)+b^2\cos^2(x)}\,dx&=2\int_0^{\pi/2}\frac{1}{a^2\sin^2(x)+b^2\cos^2(x)}\,dx\\\\
&=2\int_0^{\pi/2}\frac{\sec^2(x)}{a^2\tan^2(x)+b^2}\,dx\\\\
&=2\int_0^\infty \frac{1}{a^2u^2+b^2}\,du
\end{align}$$
Can you finish now?
