Why does Wolfram|Alpha/Mathematica say that $\sqrt{\cos ^2(t)}=\cos (t)$ in the solution of this integral $\int \frac{x^2}{\sqrt{1-x^2}} \, dx$ In the integral in this video, Wolfram|Alpha and Wolfram Mathematica say that $\sqrt{\cos ^2(t)}=\cos (t)$, when the truth is $\sqrt{\cos ^2(t)}=\left| \cos (t)\right|$.
Why in this case it is using it?
 A: The substitution being made is $t = \arcsin x$ whose range is $(-\pi/2,\pi/2)$. Observe that $\cos t \ge 0$ for all $t$ in the range.
A: Straight to the point
You are correct. Technically $\sqrt{\cos^2  t} = |\cos t|$ instead of just $\cos t$. But for indefinite integrals, we don't really care.
So does this mean I can always do this?
When doing indefinite integrals, we tend not to care too much about the domain of $t$ we are working with, and just pick the 'easiest' branch, which in this case is the branch where $|\cos t| = \cos t$ or in other words wherever $\cos t \geq 0$.
Can you show me an example where it matters?
Choosing the branch is however needed if the question were a definite integral. For a concrete example, consider $$\int_{-\frac{1}{2}}^{0}{\dfrac{x^2}{\sqrt{1-x^2}}dx}$$ For the above, you would need to use a substitution $x=\sin t$ but for a specific domain of $t$ so that the transformation is one-to-one. The most natural domain to use is $t \in \left [ -\dfrac{\pi}{2}, \dfrac{\pi}{2} \right ]$ in which case $\cos t \geq 0$ so $\sqrt{\cos ^2 t} = \cos t$.
But suppose you decided to use $t \in \left [\dfrac{\pi}{2}, \dfrac{3\pi}{2} \right ]$. In that domain, $\cos t \leq 0$ and so $\sqrt{\cos^2 t} = - \cos t$
