Do we consider functions positive in indefinite integrals?

In integrals like $\int \sqrt{x^{2}} d x$ where we have to take the radicand out of the radical, we have to put first $\int|x| d x$ but here I'm stuck : is $|x|$ = $+x$ or $-x$? Photomath gives the answer as $\frac{x^{2}}{2}$ so they considered $|x|$ as $+x$, but why? And what about a random function of the same type as above where I have to take the radicand out of the radical, what should I do then with the absolute value? Do I leave it as it is or should I assume that the function is positive and continue?


Solution 1:

No, we have to split the cases. $|x|$ is essentially the piece-wise function defined by

$$ |x| = \begin{cases}x & x\ge 0\\-x&x<0\end{cases}$$

We want to find an anti-derivative $F$ such that $F'(x) = f(x) = |x|$. To do this, we split the cases into $x\ge 0$ and $x<0$ separately to obtain

$$F(x) = \begin{cases}x^2/2&x\ge 0 \\ -x^2/2 &x<0\end{cases}$$