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

definite integralsintegration

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?

Best Answer

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:

enter image description here

Related Question