12

Been searching the net for awhile and everything just comes back about doing the definite integral. So just thought to ask here.

Title says it all. Is there a closed form solution for the indefinite integral $\int |x| dx$ ?

Wikkyd
  • 173
  • 4
    Define $|x|$ as a piecewise function and integrate each piece independently. Also search $sgn(x)$ and use it to convert your piecewise integral back to one equation. – Ahmed S. Attaalla Oct 06 '15 at 22:57
  • 3
    an antiderative of $f(x)=|x|$ is $F(x)=\frac 12 x |x| $ – WW1 Oct 06 '15 at 23:01

3 Answers3

14

Using integration by parts

$$\int |x|~dx=\int \mathrm{sgn}(x)x~dx=|x|x-\int |x| ~dx$$

since $\frac{d}{dx} |x|=\mathrm{sgn}(x)$ on non-zero sets. This yields

$$\int |x| ~dx = \frac{|x|x}{2}~.$$

Piwi
  • 1,020
9

You are looking for a function $f(x)$ so that $$\int_a^b |x|dx=f(b)-f(a).$$ This is what is meant by $\int |x|dx$. I propose that $f(x)=x|x|/2$ is such a function. Let us test it. If both $a$ and $b$ are both positive, then $$\int_a^b |x|dx=\int_a^b x\,dx=b^2/2-a^2/2=b|b|/2-a|a|/2=f(b)-f(a).$$ If $a$ and $b$ are both negative, then $$\int_a^b |x|dx=-\int_a^b x\,dx=-b^2/2-(-a^2/2)=b|b|/2-a|a|/2=f(b)-f(a).$$ Finally, if $a<0$ and $b>0$, we get $$\int_a^b |x|dx=-\int_a^0 x\,dx+\int_0^b x\,dx=b^2/2+a^2/2=b|b|/2-a|a|/2=f(b)-f(a).$$ Of course, we could have $b<0$ and $a>0$, but then we could switch the limits, and this reduces to the third case.

Thus, $f(x)=x|x|/2$ is an indefinite integral, or antiderivative of $|x|$.

Plutoro
  • 22,730
  • 3
  • 41
  • 71
0

You can use $\frac{d(|x|)}{dx}=\frac{x}{|x|}$ and $\int|x|dx = \int \frac{x}{|x|}xdx$.

$\int|x|dx = \int xd(|x|)$, using integration by parts $\int|x|dx = x|x| - \int|x|dx $

$2\int|x|dx = x|x|$

$\int|x|dx = \frac{x|x|}{2}$

$\frac{x}{|x|}$ is a better way to define the sign function.