# Definite integral of $\int_{0}^{\pi}{\frac{dx}{1+\sin^2x}}$ with u-substitution?

Let $u = \tan x$, get $du=\frac{1}{\cos^2x}dx$. Then $$\int_{0}^{\pi}{\frac{dx}{1+\sin^2x}}=\int_{0}^{\pi}{\frac{\frac{1}{\cos^2x}dx}{\frac{1}{\cos^2x}+\frac{\sin^2x}{\cos^2x}}}=\int_{0}^{\pi}\frac{d(\tan x)}{(\tan^2x+1)+\tan^2x}=\int_0^0\frac{du}{2u^2+1}=0.$$

I know this is wrong, but why?

• Just a quick guess, but possibly due to $\tan(x)$ diverging at $\pi /2$? – Plopperzz Feb 18 '17 at 5:12

## 5 Answers

You are substituting $u=\tan(x)$ on the interval $x\in[0,\pi]$. Notice what $\tan(x)$ does in that interval. It has a discontinuity at $\pi/2.$

Thus it seems prudent to notice that the integrand is even about $\pi/2$ and take $$\int_0^\pi\frac{dx}{\sin^2(x)+1} = 2\int_0^{\pi/2}\frac{dx}{\sin^2(x)+1}$$

The antiderivative you'd get at the end if you powered through that last integral is $$\frac{1}{\sqrt{2}}\arctan(\sqrt{2}\tan(x))+C$$ so you'd get $$\frac{2}{\sqrt{2}}(\arctan(\infty)-\arctan(0)) = \frac{2}{\sqrt{2}}\frac{\pi}{2} = \frac{\pi}{\sqrt{2}}.$$

Note we could also tell something was fishy by the fact that our antiderivative at the end is not continuous at $\pi/2.$ The antiderivative of an integrable function is always continuous.

So... what is the antiderivative on $[0,\pi]$ (or on the whole real line for that matter)? (Or, I should really say, the function we subtract $F(b)-F(a)$ to get the definite integral)

We can write it (or a version of it, up to an arbitrary constant) as $$F(x) = \int_0^x \frac{dt}{\sin^2(t)+1}.$$ When the formal antiderivative jumps down by $\pi/\sqrt{2}$ at $x=\pi/2,$ we need to compensate by adding $\pi/\sqrt{2}$ to make the function continuous. This will happen again at $3\pi/2.$ So the antiderivative will be $$\int_0^x \frac{dt}{\sin^2(t)+1} = \frac{1}{\sqrt{2}}\arctan(\sqrt{2}\tan(x)) + C(x)$$

where $C(x)$ is a staircase function that is locally constant, and zero on the interval $(-\pi/2,\pi/2)$ but jumps up by $\pi/\sqrt{2}$ each time we hit an odd multiple of $\pi/2.$

Which brings us back around to your problem where the bounds were the same, so it looked like you should get zero. That was from $\tan(\pi) = \tan(0)$ which corresponds to the formal antiderivative also being the same at the endpoints. But we now know that we need to add in an extra $\pi/\sqrt{2}$ since $C(\pi) - C(0) = \pi/\sqrt{2}.$

$u=\tan x$ is not continuous on $x \in [0,\pi]$ so you have to be careful and split the integral into $x \in [0,\frac{\pi}{2})$ and the leftover piece before doing everything. That way you do not divide by $\cos (\frac{\pi}{2})=0$.

$$\int_{0}^{\pi}{\frac{dx}{1+\sin^2x}}=\int_{0}^{\frac{\pi}{2}}{\frac{dx}{1+\sin^2x}}+\int_{\frac{\pi}{2}}^{\pi}{\frac{dx}{1+\sin^2x}}=\int_{0}^{\frac{\pi}{2}}{\frac{dx}{1+\sin^2x}}+\int_{0}^{\frac{\pi}{2}}{\frac{dt}{1+\cos^2t}}$$ with $t=x-\dfrac{\pi}{2}$.

In the last step you can do one last substitution with $u = \frac{v}{\sqrt{2}}$, thus, $du = \frac{dv}{\sqrt{2}}$. You can use this to get $\frac{dv}{\sqrt{2}(v^2+1)}$ inside the integral, and that sounds to me like the antiderivative of an inverse trigonometric function, but I think you can finish it from there.

Like Ahmed S. Attaalla has correctly pointed out that $\tan x$ diverges at $\frac{\pi}{2}$, one way to deal with this problem is

$$\int_{0}^{\pi}{\frac{dx}{1+\sin^2x}}$$

$$=2\int_{0}^{\frac{\pi}{2}}{\frac{dx}{1+\sin^2x}}$$

$$=2\int_{0}^{\frac{\pi}{4}}{\frac{dx}{1+\sin^2x}} + 2\int_{\frac{\pi}{4}}^{\frac{\pi}{2}}{\frac{dx}{1+\sin^2x}}$$

Now, divide the first integral by $\cos^2 x$ and second by $\sin^2 x$ and you know the rest.