Why does $\displaystyle\int_{-\pi}^{\pi}\frac{\sec^2{x}}{2\tan^2{x}+1} dx$ evaluate to be $0$ even when the graph is always positive? 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?
 A: What happens here is that $\frac1{\sqrt2}\arctan\left(\sqrt2\tan(x)\right)$ is not an antiderivative of $\dfrac{\sec^2x}{2\tan^2(x)+1}$. It's undefined at $\pm\dfrac\pi2$. In particular, it has no derivative at those points.
An antiderivative of $\dfrac{\sec^2x}{2\tan^2(x)+1}$ is$$\begin{array}{rccc}F\colon&[-\pi,\pi]&\longrightarrow&\Bbb R\\&x&\mapsto&\begin{cases}\frac{\arctan\left(\sqrt2\tan(x)\right)}{\sqrt2}-\frac\pi{\sqrt2}&\text{ if }x<-\frac\pi2\\-\frac\pi{2\sqrt2}&\text{ if }x=\frac\pi2\\\frac{\arctan\left(\sqrt2\tan(x)\right)}{\sqrt2}&\text{ if }-\frac\pi2<x<\frac\pi2\\\frac\pi{2\sqrt2}&\text{ if }x=\frac\pi2\\\frac{\arctan\left(\sqrt2\tan(x)\right)}{\sqrt2}+\frac\pi{\sqrt2}&\text{ if }x>-\frac\pi2.\end{cases}\end{array}$$Therefore$$\int_{-\pi}^\pi\frac{\sec^2(x)}{2\tan^2(x)+1}\,\mathrm dx=F(\pi)-F(-\pi)=\sqrt2\pi.$$
You can see the graphs of both functions here:

A: You can apply FTC : $$\int_a^bf(x)dx = F(b)-F(a)$$
for $f(x)$ is defined and continuous for all $x\in[a, b]$
In your case, $\tan x$ is undefined at $x=\frac{\pi}{2}$ (also for $-\frac{\pi}{2}$).
This fact makes whole of your integrand also undefined at the same point,
So you can't apply the FTC.
A: All the other answers have already mentioned that your integrand will be undefined at $x=\pm\dfrac\pi2$,therefore I will try to give hints on how to proceed through this question.
As the function is even as $f(x)=f(-x)$, we can write:
$\displaystyle\int_{-\pi}^{\pi}\frac{\sec^2{x}}{2\tan^2{x}+1} dx=2\displaystyle\int_{0}^{\pi}\frac{\sec^2{x}}{2\tan^2{x}+1} dx$
We can also observe that $f(x)=\displaystyle\frac{\sec^2{x}}{2\tan^2{x}+1}$ is symmetric about $x=\pi/2 $ as $f(\dfrac\pi2-x)=f(\dfrac\pi2+x) $
Thus,$\displaystyle\int_{-\pi}^{\pi}\frac{\sec^2{x}}{2\tan^2{x}+1} dx=2\displaystyle\int_{0}^{\pi}\frac{\sec^2{x}}{2\tan^2{x}+1}=4\displaystyle\int_{0}^{\pi/2}\frac{\sec^2{x}}{2\tan^2{x}+1} dx$
Now, you can substitute $\tan x=t$ and proceed further as $\tan x$ is defined at every point in the interval $(0,\pi/2)$.
Hope this helps.
