When I evaluate $\displaystyle\int_{-\pi}^{\pi}\frac{\sec^2{x}}{2\tan^2{x}+1} dx$ for some reason I get $0$ instead of the actual answer of $\frac{\pi}{\sqrt{2}}$. Here's my working:
$\displaystyle\int_{-\pi}^{\pi}\frac{\sec^2{x}}{2\tan^2{x}+1} dx=\frac{1}{\sqrt{2}}\int_{-\pi}^{\pi}\frac{\sqrt{2}\sec^2{x}}{(\sqrt{2}\tan{x})^2+1}dx$, which is clearly the arctan integral form therefore:
$=\displaystyle \frac{1}{\sqrt{2}}\left[\arctan{(\sqrt{2}\tan{x})}\right]^\pi_{-\pi}$
$=\displaystyle \frac{1}{\sqrt{2}}\left[\arctan{(\sqrt{2}\times0)}-\arctan{(\sqrt{2}\times0)}\right]=0$
Why is this happening? I have been taught to be careful of definite integrals when integrating over discontinuities but $\displaystyle\frac{\sec^2{x}}{2\tan^2{x}+1}$ is a smooth wave like curve always above the $x$-axis. So why this evaluation fails is beyond what I know, can someone clear up what the problem is and offer a way of evaluating around it?