<s>[INST] Integrate $\frac{x^2}{\sqrt{16-x^2}}$ using trig substitution During our integration of the following integral, using $x = 4 \sin \theta$ 
$$\int \frac{x^2}{\sqrt{16-x^2}} dx$$
We eventually come to the following point:
$$\int \frac{16 {\sin ^2 \theta} }{4 \sqrt{\cos ^2 \theta}} dx$$
At this point, we say that $\sqrt{\cos ^2 \theta} = \cos \theta$ and then complete the integral 
But doesn't $\sqrt{\cos ^2 \theta} = |\cos \theta|$
What is going on?
 [/INST] Let $$\displaystyle I = \int\frac{x^2}{\sqrt{16-x^2}}dx\;,$$ Let $x=4\sin \phi\;,$ Then $dx = 4\cos \phi d\phi$
So Integral $$\displaystyle I = \int\frac{16\sin^2 \phi}{4|\cos \phi|}\cdot 4\cos \phi d\phi = \pm 8\int 2\sin^2 \phi d \phi$$
Now Using $\bullet\; 2\sin^2 \phi = 1-\cos 2\phi$ and $\bullet\; \sin 2\phi = 2\sin \phi\cdot \cos \phi.$
so we get $$\displaystyle I = \pm 8\int (1-\cos 2\phi)d\phi = \pm 8\left[\phi-\frac{\sin 2\phi}{2}\right]+\mathcal{C} = \pm 8\left[\phi-\sin \phi \cdot \cos \phi\right]+\mathcal{C}$$
So we get $$\displaystyle I =\pm 8\left[\sin^{-1}\left(\frac{x}{4}\right)-\frac{x\sqrt{16-x^2}}{16}\right]+\mathcal{C} $$
</s>