Should I ignore ± sign when integrating square roots? I was solving the following integral:
$$
\int \:\frac{x^2}{\sqrt{x^2+4}}dx
$$
$$
u=\sqrt{x^2+4}
$$
$$
\:du=\frac{2x}{2\sqrt{x^2+4}}dx=\frac{x}{u}dx
$$
$$
\int \:\frac{x^2}{\sqrt{x^2+4}}dx=\int \:\frac{x^2}{u}dx=\int \:xdu
$$
Now I only need to find what x means in terms of u:
$$
u^2=x^2+4,\:u^2-4=x^2
$$$$
x=\pm \sqrt{u^2-4}
$$
But now I have a problem, which is the plus minus sign, so my integral would be:
$$
\int \pm \sqrt{u^2-4}du
$$
To avoid this problem, I decided to use integration by parts instead:
$$
\int xdu\:=\:xu-\int \:udx\:=
$$
$$
x\sqrt{x^2+4}-\int \:\sqrt{x^2+4}dx
$$
But it looks like both equations yielded the same result and the plus minus sign was unnecessary.




$$\int \pm \sqrt{u^2-4}du$$
$$x\sqrt{x^2+4}-\int \:\sqrt{x^2+4}dx$$




$$u=2sect,\:t=arcsec\left(\frac{u}{2}\right),\:du=2sec\left(t\right)tan\left(t\right)dt$$
$$x=2tan\left(t\right),\:t=arctan\left(\frac{x}{2}\right),\:dx=2sec^2tdt$$


$$\int \:\sqrt{u^2-4}du=\int \:2tan\left(t\right)\cdot 2sec\left(t\right)tan\left(t\right)dt=$$
$$x\sqrt{x^2+4}-\int \:\sqrt{x^2+4}dx=\:x\sqrt{x^2+4}-\int \:2sec\left(t\right)\cdot 2sec^2tdt=$$


$$4\int \:sec\left(t\right)tan^2\left(t\right)dt=4\int \:\:sec\left(t\right)\left(sec^2\left(t\right)-1\right)dt=$$
$$\:x\sqrt{x^2+4}-4\int \:sec^3tdt$$


$$4\int \:\:sec^3tdt-4\int \:sec\left(t\right)dt$$
$$\int \:sec^3tdt=\frac{1}{2}\sec \:\left(t\right)\tan \:\left(t\right)+\frac{1}{2}\ln \:\left|\tan \:\left(t\right)+\sec \:\left(t\right)\right|+C$$


$$=4\left(\frac{1}{2}\sec \:\:\left(t\right)\tan \:\:\left(t\right)+\frac{1}{2}\ln \:\:\left|\tan \:\:\left(t\right)+\sec \:\:\left(t\right)\right|-ln\left|\tan \:\:\:\left(t\right)+\sec \:\:\:\left(t\right)\right|\right)$$
$$=x\sqrt{x^2+4}-4\left[\frac{1}{2}\sec \left(t\right)\tan \left(t\right)+\frac{1}{2}\ln \left|\tan \left(t\right)+\sec \left(t\right)\right|\right]$$


$$=2\sec \left(t\right)\tan \left(t\right)-2\ln \left|\tan \:\:\left(t\right)+\sec \:\:\left(t\right)\right|$$
$$=x\sqrt{x^2+4}-2\sec \left(t\right)\tan \left(t\right)-2\ln \left|\tan \left(t\right)+\sec \left(t\right)\right|$$


$$=2\sec \left(sec^{-1}\left(\frac{u}{2}\right)\right)\tan \left(sec^{-1}\left(\frac{u}{2}\right)\right)-2\ln \left|\tan \:\:\left(sec^{-1}\left(\frac{u}{2}\right)\right)+\sec \:\:\left(sec^{-1}\left(\frac{u}{2}\right)\right)\right|$$
$$=x\sqrt{x^2+4}-2\sec \left(tan^{-1}\left(\frac{x}{2}\right)\right)\tan \left(tan^{-1}\left(\frac{x}{2}\right)\right)-2\ln \left|\tan \left(tan^{-1}\left(\frac{x}{2}\right)\right)+\sec \left(tan^{-1}\left(\frac{x}{2}\right)\right)\right|$$


$$sec=\frac{h}{a}=\frac{u}{2},\:o=\sqrt{u^2-2^2},\:tan=\frac{o}{a}=\frac{\sqrt{u^2-4}}{2}$$
$$tan=\frac{o}{a}=\frac{x}{2},\:h=\sqrt{x^2+2^2},\:sec=\frac{h}{a}=\frac{\sqrt{x^2+4}}{2}$$


$$=2\left(\frac{u}{2}\right)\frac{\sqrt{u^2-4}}{2}-2\ln \left(\left|\frac{\sqrt{u^2-4}}{2}+\frac{u}{2}\right|\right)$$
$$=x\sqrt{x^2+4}-2\frac{\sqrt{x^2+4}}{2}\left(\frac{x}{2}\right)-2\ln \:\left|\frac{x}{2}+\frac{\sqrt{x^2+4}}{2}\right|$$


$$=\frac{\sqrt{x^{2}+4}\sqrt{\left(\sqrt{x^{2}+4}\right)^{2}-4}}{2}-2\ln\left(\left|\frac{\sqrt{\left(\sqrt{x^{2}+4}\right)^{2}-4}}{2}+\frac{\sqrt{x^{2}+4}}{2}\right|\right)$$
$$=\frac{2x\sqrt{x^2+4}}{2}-\frac{x\sqrt{x^2+4}}{2}-2\ln \:\left|\frac{x}{2}+\frac{\sqrt{x^2+4}}{2}\right|$$


$$=\frac{x\sqrt{x^{2}+4}}{2}-2\ln\left|\frac{x+\sqrt{x^{2}+4}}{2}\right|$$
$$=\frac{x\sqrt{x^2+4}}{2}-2\ln \:\left|\frac{x+\sqrt{x^2+4}}{2}\right|$$





So, since both of them yield the exact same answer after simplification, I wonder if we can always assume that square roots are positive and omit the plus minus sign, or was my logic actually right that I should always try to avoid substitutions with plus minus square roots?
As you can see by the graph it seems to work for both positive and negative x. My only suspicion is that in cases where it is not possible to simplify the formations such as fractional angles. Then maybe we could be getting it wrong... for example when answer is like this...  $$sin\left(\frac{1}{8}cos^{-1}x\right)$$
 A: What the $\pm$ sign in $x=\pm \sqrt{u^2-4}$ implies is that you have a choice of how to make the substitution of $u$ for $x.$ You need this choice to be available in order that your evaluation of the integral can be valid for all values of $x.$
If we suppose that $x$ can have either positive or negative values, then there is an error in the last step of your evaluation of $\int \sqrt{u^2 - 4}\,\mathrm du.$
In fact,
$$
\sqrt{\left(\sqrt{x^2+4}\right)^2 - 4} = \sqrt{x^2} = \lvert x\rvert,
$$
not simply $x$ as you appear to have assumed in your work. So what you should have at the bottom of the left-hand column in your work is
$$
\frac{\lvert x\rvert\sqrt{x^2+4}}{2} - 2\ln\left\lvert\frac{\lvert x\rvert + \sqrt{x^2+4}}{2}\right\rvert,
$$
At first glance, this looks different from what you get at the bottom of the right-hand column. And it is different. You will find that if you plug in a negative value of $x,$ the expression in the left-hand column has a value exactly opposite the value in the right-hand column; that is, when $x < 0,$
\begin{multline}
\frac{\lvert x\rvert\sqrt{x^2+4}}{2} - 2\ln\left\lvert\frac{\lvert x\rvert + \sqrt{x^2+4}}{2}\right\rvert \\
= \frac{(-x)\sqrt{x^2+4}}{2} - 2\ln\left\lvert\frac{-x + \sqrt{x^2+4}}{2}\right\rvert \\
= -\left(\frac{x\sqrt{x^2+4}}{2} - 2\ln\left\lvert\frac{x + \sqrt{x^2+4}}{2}\right\rvert\right).
\end{multline}
The fact that
$$ \frac{(-x)\sqrt{x^2+4}}{2} = - \left(\frac{x\sqrt{x^2+4}}{2}\right) $$
is obvious; the fact that
$$
 \ln\left\lvert\frac{-x + \sqrt{x^2+4}}{2}\right\rvert
= -\ln\left\lvert\frac{x + \sqrt{x^2+4}}{2}\right\rvert
$$
is less obvious, but it might be a little less surprising if you realize that
$$
\ln\left\lvert\frac{x + \sqrt{x^2+4}}{2}\right\rvert
= \ln\left(\frac{x + \sqrt{x^2+4}}{2}\right)
 = \sinh^{-1}\left(\frac x2\right).
$$
Now you might think this is a disaster: the results agree for non-negative $x,$ but for all negative values of $x$ we have violent disagreement.
But this is where the $\pm$ sign saves you.
In fact, what you showed in the left-hand column is the result of the substitution
$x=\sqrt{u^2-4},$ $u=\sqrt{x^2+4},$
which results from choosing the $+$ part of the $\pm$ sign.
But if $x$ is negative that is not a valid substitution, because there is no real number $u$ that makes $\sqrt{u^2-4}$ negative.
For negative values of $x$ you can use $x=-\sqrt{u^2-4},$ $u=\sqrt{x^2+4}.$
That means you need to evaluate $\int -\sqrt{u^2 - 4}\,\mathrm du.$
Fortunately this is just $-\int \sqrt{u^2 - 4}\,\mathrm du$
and you have already evaluated $\int \sqrt{u^2 - 4}\,\mathrm du,$
so all you need to do is to take your result for $\int \sqrt{u^2 - 4}\,\mathrm du$
and reverse its sign.
And that makes it exactly equal to the result in the right-hand column
in the case where $x$ is negative.
Therefore you have the same results from both methods for non-negative $x$ and also for negative $x.$
But only if you acknowledge both the positive and negative square roots of
$u^2 - 4$ and use the correct root in every case.
