<s>[INST] Change of variable in integrals I am trying to solve a definite integral of a positive function, but I keep getting 0.

 [/INST] On using $ \int^a_{-a} f(x) dx = 2 \int^a_0 f(x) dx$ and $ \int^{2a}_0 f(x) dx = \int^a_0 f(x) dx + \int^a_0 f(2a - x) dx$
$$I = \int^{\pi}_{-\pi} \dfrac{1}{1 + \sin^2 (x)} dx = 4 \int^{\pi /2}_0 \dfrac{1}{1 + \sin^2 (x) } dx $$
Multiply, both denominator and numerator by $\sec^2 (x)$ , Use $\sec^2 (x) = \tan^2 (x) + 1$, and substitute $\sqrt{2} \tan x = u$, Following integral would be obtained
$$ I = 2 \sqrt{2} \int^{\infty}_0  \dfrac{du}{1 + u^2} = 2 \sqrt{2} \cfrac{\pi}{2} = \sqrt{2} \pi $$
The problem with your substition is that, you've took $du = \cos(x) dx = \color{red} {+}  \sqrt{1 - \sin^2 x} dx $, but the right way is $du = \cos(x) dx = \color{red} {\pm}  \sqrt{1 - \sin^2 x} dx $ and then substitute the required limits.
</s>