Evaluating definite integral - Let's say we want to evaluate $$ \int_0^{2\pi} \frac{1}{a^2\cos^2x+b^2\sin^2x}dx$$
With substitution, one obtains $$ \frac{1}{ab} \arctan\left(\frac ba \tan x\right) $$
as antiderivate. For more details on how to do this, see this question.
Now my question is, why do I receive $0$ if I insert $0$ and $2\pi$ as integration bounds ? This obviously can't be true since the integrand is always positive. 
What do I oversee ? 
 A: A substitution in a integral is allowed as soon as the substitution is given by a bijective and differentiable function. In our case, if the integration range is $(0,2\pi)$ we cannot simply replace $x$ by $\arctan t$ and $dx$ by $\frac{dt}{1+t^2}$, but we have to split the integration range, then apply such substitution on the integrals we get that way:
$$ \int_{0}^{2\pi}\frac{dx}{a^2\cos^2(x)+b^2\sin^2(x)}\\=2\int_{0}^{\pi/2}\frac{dx}{a^2\cos^2(x)+b^2\sin^2(x)}+2\int_{0}^{\pi/2}\frac{dx}{a^2\sin^2(x)+b^2\cos^2(x)}\\=2\int_{0}^{+\infty}\left(\frac{1}{a^2 t^2+b^2}+\frac{1}{a^2+b^2 t^2}\right)\,dt=\color{red}{\frac{2\pi}{ab}}. $$
A: Arctan is only true from $-\frac{\pi}{2}$ to $\frac{\pi}{2}$ (I.e the domain of arctan)
A: Notice, the property of the definite integral $\int_{0}^{2a}f(x)\ dx=2\int_{0}^{a}f(x)\ dx\ \ \ \  \ \  \forall \ \ \ f(2a-x)=f(x)$
$$\int_{0}^{2\pi} \frac{1}{a^2\cos^2 x+b^2\sin^2 x}\ dx$$$$=2\int_{0}^{\pi} \frac{1}{a^2\cos^2 x+b^2\sin^2 x}\ dx$$ $$=4\int_{0}^{\pi/2} \frac{1}{a^2\cos^2 x+b^2\sin^2 x}\ dx$$
$$=\frac{4}{b^2}\int_{0}^{\pi/2} \frac{\sec^2 x}{\left(\frac{a}{b}\right)^2+\tan^2 x}\ dx$$$$=\frac{4}{b^2}\int_{0}^{\pi/2} \frac{d(\tan x)}{\left(\frac{a}{b}\right)^2+\tan^2 x}$$
$$=\frac{4}{b^2}\frac{b}{a}\left(\tan^{-1}\left(\frac{bx}{a}\right)\right)_{0}^{\pi/2}=\frac{4}{ab}\tan^{-1}\left(\frac{\pi b}{2a}\right)$$
