# Indefinite integral of absolute value

When I looked up about absolute value on Wikipedia, I found that the antiderivative of $|x|$ is $\frac12 x|x|+C$. I am able to find the derivative of $|x|$ by treating the function as $\sqrt{x^2}$, but I am not able to integrate it.

When I put $\int_{-4}^{-1}|x|\,dx$ into Symbolab, the online calculator did not break the integral into piecewise function but calculate the indefinite integral first before using $F(b) - F(a)$. When I view the steps it used, it said:

If $\int f(x)\,dx = F(x)$ then $$\int \sqrt{(f(x))^2)}\,dx = \frac{\sqrt{f(x)^2}}{f(x)}$$ multiplied to $F(x)$ which becomes $\frac{\sqrt{x^2}}{x}$ multiplied to $\int x\,dx$

• Forget online calculators and think. The function has basically two different expressions on two intervals, treat them separately. – Did Dec 4 '14 at 6:52
• But unlike $\int (1/x)\,dx$, the constant in this case should be the same for the two parts. – GEdgar Dec 4 '14 at 15:08

The function ${\rm abs}$ is continuous on all of ${\mathbb R}$, hence should have primitives $F$ defined on all of ${\mathbb R}$. Given that ${\rm abs}$ is "special" at $x=0$ we should look for the primitive obtained by integrating from $0$ to $x$. In this way we obtain $$F(x)=\int_0^x |t|\>dt=\int_0^x t\>dt={x^2\over2}\qquad(x\geq0)$$ and $$F(x)=\int_0^x |t|\>dt=\int_0^x (-t)\>dt=-{x^2\over2}\qquad(x\leq0)\ .$$ The two partial results can be condensed into the single formula $$F(x)={x\>|x|\over 2}\qquad(-\infty<x<\infty)\ ,$$ and adding an arbitrary constant $C$ gives the general primitive of ${\rm abs}$.

• Why can't we just write $|x|^2/2$ as the integral and integrate directly with the given limits, instead of writing two expressions and breaking up the limits? – Mr Reality Sep 26 '18 at 18:31
• @MrReality: Because it is wrong. One has $|x|^2/2=x^2/2$, and the derivative of this is $x$, not $|x|$. – Christian Blatter Sep 26 '18 at 18:47

Here is my derivation for this,

$$\int |x|dx= \int \sqrt {x^2} dx = I$$

By integration by parts we know that,

$$\int u(x)v(x)\,dx=u(x)\int v(x) \ dx-\int u'(x) \left [ \int v(x) \ dx \right ]dx$$ This is just a extension of the product rule in diffrentiation. Check out the wiki page.

So taking $u(x) = |x|$ and $v(x) =1$,

$$I = \int |x| \times 1 \ \ dx = |x| \int 1\ dx - \int \left [ \frac{d(|x|) }{dx}\int 1 \ dx \right ]dx$$

Now we can differentiate the absolute value of $x$ using chain rule,

$$\frac{d(|x|) }{dx} = \frac{d(\sqrt {x^2}) }{dx} = \frac{1}{2\sqrt{x^2}} (2x)= \frac{x}{\sqrt{x^2}}$$

Trivially we can say $\int 1 \ dx = x$.

Substituting this in $I$,

$$I = |x|x \ - \ \int\frac{x}{\sqrt{x^2}} \ x \ dx$$

$$I = |x|x \ - \ \int\frac{x^2}{\sqrt{x^2}} \ dx$$

Because both $x^2$ and $\sqrt{x^2}$ are positive, we can rewrite this as,

$$I = |x|x \ - \ \int{\sqrt{x^2}} \ dx =|x|x \ - I$$

So as we have the same integral in the RHS, we take it to the LHS.

$$2I = |x|x$$

So we can conclude,

$$I(x) = \frac{x|x|}{2}$$

Try this out for yourself the area under the $|x|$ curve from $x=a$ to $x=b$ can be expressed as $I(b) - I(a)$.

The antiderivative of $|x|$ is a function $g(x)$ such that $g'(x) = |x|$. Note that for any value of $C$, $g(x) + C$ can also be such an antiderivative. So we add a Constant of integration.

SIDE NOTE :

In case the integration by parts formula I gave above is confusing, consider

$$\frac{d(a(x) \ b(x)) }{dx} = a'(x) \ b(x) + a(x) \ b'(x)$$

Integrating both sides,

$$\int \frac{d(a(x) \ b(x)) }{dx} = a(x) \ b(x) = \int a'(x) \ b(x) + \int a(x) \ b'(x)$$

If we substitute $a(x) = u(x)$ and $b'(x) = v(x)$, so $b(x) = \int v(x)$ and $a'(x) = u'(x)$

$$u(x)\int v(x) = \int u'(x) \left [ \int v(x) \ dx \right ]dx + \int u(x) \ v(x)$$

Thus we get the formula for integration by parts shown above.

enter image description here

∫|x|dx=∫〖√(x^2 ) dx〗=

=x√(x^2 )-∫〖x/√(x^2 ) dx〗

Then:

∫〖√(x^2 ) dx〗=x√(x^2 )-∫〖√(x^2 ) dx〗

∫〖√(x^2 ) dx〗=x√(x^2 )-∫〖√(x^2 ) dx〗

Then:

2∫〖√(x^2 ) dx〗=x√(x^2 )=x|x|

Finally we will have:

  ∫〖√(x^2 ) dx〗=x|x|/2


I can not put the formula correctly, If you guide how to do the job I will provide the answer in a better view

• This seems like it could be a good contribution. If you want to learn how to format your answer correctly, you could go here for a tutorial and tips. Otherwise, perhaps some other user will come along and format it for you, but this is an old question and already answered. – 6005 Aug 11 '16 at 5:18
• Please see how to use latex commands for a better format. – Babai Aug 11 '16 at 5:44

$\int_{-4}^{-1}|x|~dx$

$=[x|x|]_{-4}^{-1}-\int_{-4}^{-1}x~d(|x|)$

$=15-\int_{-4}^{-1}x\times\dfrac{|x|}{x}dx$

$=15-\int_{-4}^{-1}|x|~dx$

$\therefore2\int_{-4}^{-1}|x|~dx=15$

$\int_{-4}^{-1}|x|~dx=\dfrac{15}{2}$

• How do you justify the first equality? It's not immediately clear that the expression in the second line even makes sense. – Michael Albanese Dec 8 '14 at 16:59
• Looks like integration by parts, but i'm not sure this is justified here. For this integral specifically, replace $abs(x)$ with $-x$ since $x$ lies in negative numbers only. – JacksonFitzsimmons Jan 13 '16 at 12:25
• The calculation works (even if you replace bounds with $-4$ to $1$, so there must be some way to justify the $d(|x|)$. While I have seen this sort of notation before, I'm not familiar with the justification. And mathSE questions (1, 2) haven't really done justice to it. – 6005 Aug 11 '16 at 5:40