A little integration paradox The following integral can be obtained using the online Wolfram integrator: 
$$\int \frac{dx}{1+\cos^2 x} = \frac{\tan^{-1}(\frac{\tan x}{\sqrt{2}})}{\sqrt{2}}$$
Now assume we are performing this integration between $0$ and $2\pi$. Hence the result of the integration is zero.
On the other hand when looking at the integrand, $\displaystyle \frac{1}{1+\cos^2 x}$, we see that it is a periodic function that is never negative. The fact that it is never negative guarantees that the result of the integration will never be zero (i.e., intuitively there is a positive area under the curve).
What is going on here?

If $\tan(y)=a\tan(x)$, then $\tan(y-x)=\frac{(a-1)\tan(x)}{1+a\tan^2(x)}$, and therefore,
$$
y=x+\tan^{-1}\left(\frac{(a-1)\tan(x)}{1+a\tan^2(x)}\right)\tag{1}
$$
Since $\left|\frac{(a-1)\tan(x)}{1+a\tan^2(x)}\right|\le\frac{\left|a-1\right|}{2\sqrt{a}}$, $(1)$ is a nice continuous function of $x$.
In this question, $a=\frac1{\sqrt2}$, so we get
$$
\int\frac{\mathrm{d}x}{1+\cos^2(x)}=\frac{x-\tan^{-1}\left(\frac{(\sqrt2-1)\tan(x)}{\sqrt2+\tan^2(x)}\right)}{\sqrt2}\tag{2}
$$
