# Is this u-substitution valid?

It is not necessary to take any example of any integral, so I'll just drop it: $$u=\sin x; \ \ \ du=\cos x dx$$ which my question is rather here:

Is it possible to do: (squaring both sides) $$u^2=\sin^2(x)=1-\cos^2(x)$$ $$\cos(x)=\sqrt{1-u^2}$$ is it? I don't think it's true for the simple fact that $$\sqrt{x^2}=|x|$$ and not just $$x$$ but my question earlier today talked about how domain can be somewhat dealt with the constant $$+C$$ as shown in my question:

My question about different domains on indefinite integrals

So I'm very curious on whether it would be valid or not

• If we restrict to an interval where $\cos(x) \geq 0$, then there's no issue, but what would you propose happens on any subinterval where $\cos(x) < 0$? Commented Dec 9, 2022 at 8:01

Of course squaring still yields a true identity, but as your comment regarding absolute value suggests (and as Brian Moehring made explicit in the comments) $$\cos x = \sqrt{1 - u^2}$$ cannot hold on any interval where $$\cos x < 0$$.
As an example, consider $$\int_0^\pi \sin x \cos^2 x \,dx .$$ The conventional substitution $$v = \cos x$$ quickly gives the value $$\frac{2}{3}$$.
On the other hand, taking $$u = \sin x$$, $$du = \cos x\, dx$$, and replacing $$\cos x \rightsquigarrow \sqrt{1 - u^2}$$ gives the incorrect value $$\int_0^0 u \sqrt{1 - u^2} \,du = 0 .$$
To avoid this error, we can first split our domain of integration into subintervals on which $$\cos x \geq 0$$ or $$\cos x \leq 0$$, say, $$[0, \frac{\pi}{2}]$$ and $$[\frac{\pi}{2}, \pi]$$, whereon we thus have $$\cos x = \sqrt{1 - u^2}$$ and $$\cos x = -\sqrt{1 - u^2}$$, respectively. Then, our original integral becomes \begin{align} \int_0^\pi \sin x \cos^2 x \,dx &= \int_0^\frac\pi2 \sin x \cos^2 x \,dx + \int_\frac\pi2^\pi \sin x \cos^2 x \,dx \\ &= \int_0^1 u \sqrt{1 - u^2} \,du + \int_1^0 u \left(-\sqrt{1 - u^2}\right) \,du \\ &= 2 \int_0^1 u \sqrt{1 - u^2} \,du \\ &=\frac23 . \end{align}