Evaluating $\int_{0}^{2\pi}\frac{1}{\cos^2(\theta)+1}\, d\theta$ What would be the values of this definite Integral?
$$\int_{0}^{2\pi}\frac{1}{\cos^2(\theta)+1}\, d\theta$$
So, I have solved this definite integral using the substitution method, taking $u=\tan(\theta)$.
After some simplification, the solution to the definite integral I get is follows:
$$\frac{1}{\sqrt{2}} \, \tan^{-1}\left(\frac{\tan{\theta}}{\sqrt{2}}\right) \Biggr|_{0}^{2\pi}$$
Whenever I am evaluating the above result at the limits of the integration I am getting an answer of $0$.
My simplification,
$$=\frac{1}{\sqrt{2}} \, \left[ \tan^{-1}\left(\frac{\tan{2\pi}}{\sqrt{2}}\right) - \tan^{-1}\left(\frac{\tan{0}}{\sqrt{2}}\right) \right]$$
$$=\frac{1}{\sqrt{2}} \, \big[ \tan^{-1}(0) - \tan^{-1}(0) \big]$$
$$=\frac{1}{\sqrt{2}} \, \big[ 0-0]$$
$$=0$$
However, using Mathematical/Integral calculator, the value of this Integral is
$$2\pi$$
I am probably doing something very silly, as I can't figure out what I am doing wrong. Any help would be appreciated. Thanks!

Here is an alternate way with contour integration:
$$\begin{aligned}
 J= \int_{0}^{2\pi}  \frac{d\theta}{\cos^2 \theta+1} &=
\oint_{|z|=1} \frac{\frac{dz}{iz}}{ \left[ \frac{(z+z^{-1})^2}{4}+1 \right]}\\
 &=  \frac{4}{i}\oint \frac{ z \, dz}{  z^4 + 6 z^2 +1 }\\
\end{aligned}$$
Take the integral in the positive (counter-clockwise) direction.
There are four roots to the denominator of the integrand:
$$z_k \in \left\{ \mp i \sqrt{3 \mp 2\sqrt{2}} \right\}, \quad k=1,\cdots,4 $$
The roots inside the circle are
$z_1 =  - i \sqrt{3 - 2\sqrt{2}} $ and $z_2 =  i \sqrt{3 - 2\sqrt{2}} $.
$$J=2\pi i \cdot \frac{4}{i} \left[ \text{Res}_{z=z_1} \frac{z}{z^4+6z^2+1}+\text{Res}_{z=z_2} \frac{z}{z^4+6z^2+1}\right]
= 8\pi \left[\frac{1}{8\sqrt{2}}+ \frac{1}{8\sqrt{2}} \right]=\sqrt{2}\pi.$$
Even easier is to recognize that the substitution $w=z^2$ inside the integral leads to
$$J=\frac{4}{i} \oint_{|w|=1} \frac{dw}{w^2+6w+1}$$
We either have to wind around the circle twice in the $w$-plane or  multiply by $2$ so that the constant out in front is again ${4}/{i}$.
and so
$$J=8\pi \text{ Res}_{z=2\sqrt{2}-3} \, \frac{1}{w^2+6w+1}=8\pi\cdot \frac{1}{4\sqrt{2}}=\sqrt{2}\pi.$$
