Fundamental Theorem of Calculus Confusion regarding atan According to this site,
$$ \int \frac{1}{a^2 \cos^2(x) + b^2 \sin^2(x)} \,dx =\frac{1}{ab} \arctan\left(\frac{b}{a} \tan(x)\right)$$
Thus,
$$ \int_0^{\pi} \frac{1}{a^2 \cos^2(x) + b^2 \sin^2(x)} \, dx =\frac{1}{ab} \arctan\left(\frac{b}{a} \tan(\pi)\right)-\frac{1}{ab} \arctan\left(\frac{b}{a} \tan(0)\right)=0-0=0$$
But in fact value of integral is not zero.
What am I doing wrong?

This very integral, with a little manipulation, is referenced in the Jeffrey paper so the nice form in that paper can be attained by observing that $\tan^{-1}(\tan x)$ has the same discontinuities as the original integral, so we may hope to cancel them out by setting
$$\frac1{ab}\tan^{-1}\left(\frac{b}a\tan x\right)=\frac1{ab}\left\{x+\tan^{-1}\left(\frac{b}a\tan x\right)-\tan^{-1}(\tan x)\right\}$$ Now,
$$\begin{align}\tan^{-1}\left(\frac{b}a\tan x\right)-\tan^{-1}(\tan x) & =\tan^{-1}\left(\frac{\frac{b}a\tan x-\tan x}{1+\frac{b}a\tan^2x}\right) \\ & =\tan^{-1}\left(\frac{(b-a)\sin2x}{(a+b)-(b-a)\cos2x}\right) \end{align}$$ after a little algebra, so
$$\int\frac1{a^2\cos^2x+b^2\sin^2x}dx=\frac1{ab}\left\{x+\tan^{-1}\left(\frac{(b-a)\sin2x}{(a+b)-(b-a)\cos2x}\right)\right\}+C$$ removes all discontinuities and even checks by differentiation.
