# What is the integral of |x| ?

1. Aug 10, 2011

### agentredlum

The question is in the title.

This is not a homework question, just curiousity on my part.

2. Aug 10, 2011

### HallsofIvy

If x< 0, then |x|= -x and its integral is $-x^2/2+ C$

If $x\ge 0$, then |x| x and its integral is $x^2/2+ C$

Last edited by a moderator: Aug 10, 2011
3. Aug 10, 2011

### disregardthat

or |x|x/2 + C

4. Aug 10, 2011

### ReaverKS

How? I thought the whole purpose of the absolute value stemmed back to distances along a number line, therefore you couldn't get a negative value out of the absolute value of a number or a function?

5. Aug 10, 2011

### Citan Uzuki

If x<0, then -x>0.

6. Aug 10, 2011

### BloodyFrozen

7. Aug 10, 2011

### Bohrok

$$\int|x| dx = \frac{1}{2}x|x| + c$$If you write |x| as √(x2) and use integration by parts, you can find the integral.

8. Aug 10, 2011

### agentredlum

I know HallsofIvy figured it out because calculations were shown, but did the rest of you look it up?

HallsofIvy, can you combine your 2 solutions into a single solution to get wiki answer?

I know wiki mentions integration by parts, but did anyone use a simpler way to get the answer? It doesn't have to be rigorous, it just has to work. Don't worry about rigor, just functionality.

What is the integral of |x^3| ?

What is the integral of |x^n| for odd n?

EDIT* There is nothing wrong (IMHO) with looking up the answer, but there is nothing wrong with working it out for yourself.

9. Aug 10, 2011

### Bohrok

I never knew wikipedia showed how to integrate it; just noticed it right now. I personally did it once because I wanted to derive it myself, and for higher odd powers of x such as |x3| and there is a pattern.$$\int|x^3|dx = \frac{1}{4}x^3|x| + c, \int|x^5|dx = \frac{1}{6}x^5|x| + c, \text{etc.}$$So in general,$$\int|x^n|dx = \frac{1}{n + 1}x^n|x| + c \text{ for odd n}$$

10. Aug 10, 2011

### agentredlum

Oh, this is interesting. Is there any difference to the answer if you represent it as |x^n|x/(n+1) + c for odd n ?

Well done in deriving it for yourself.

11. Aug 10, 2011

### Mute

When you have an absolute value, you just split it into cases:

If $x > 0,~|x^n| = x^n$, so the integral is $x^{n+1}/(n+1)$.

If $x < 0,~|x^n| = - x^n$, so the integral is $-x^{n+1}/(n+1)$.

(for n odd, of course)
This can be written as a single results using the "sign function", $\mbox{sgn}(x)$, which returns the sign of x. Hence, the integral may be written

$$\mbox{sgn}(x) \frac{x^{n+1}}{n+1}.$$

For x not zero, the sign function is equivalent to |x|/x or x/|x| (as is hopefully obvious after thinking about it for a second), so you can insert the first form there to get the results people have been throwing around.

Note that since the sign function to an even power is always 1, you can always insert sign functions of even powers to shift around the exponents, so you can write the integral as

$$\frac{|x|^ax^b}{n+1},$$
where a + b = n+1, and a and b are odd numbers.

12. Aug 10, 2011

### Bohrok

No difference; it's the same way as how I have it. I should also add positive to the restriction on n: for positive odd n.

13. Aug 10, 2011

### agentredlum

Of course, right you are. I haven't explored what happens when n is negative. It is interesting to me that the integrals we are considering, |x^n|, for positive odd n, to get the answer you just write it down, multiply by x, divide by the total number of factors of x and add a 'c'. Integration by parts is not necessary. It makes me wonder if there are other functions out there that work simply like this, besides the normal x^n without absolute value symbol.

What is the integral of |x^3 + x| ?

Last edited: Aug 11, 2011
14. Aug 11, 2011

### Bohrok

I thought this would be difficult and involve integration by parts, but it turned out quite simple actually:
|x3 + x| = |x(x2 + 1)| = |x||x2 + 1| = |x|(x2 + 1) = |x|x2 + |x| = |x3| + |x|, using the facts that x2 + 1 = |x2 + 1| and x2 = |x2| since the former in each case is never negative, and |ab| = |a||b|, so
∫|x3 + x| dx = ∫|x3| dx + ∫|x| dx
Once you integrate those, you can combine them and make the result look more condensed.

If you had |x3 - x|, that would be a different story!

Last edited: Aug 11, 2011
15. Aug 11, 2011

### agentredlum

It's very nice how you turned this problem into something we have a shortcut for already!

So the integral of |x^3 + x| is |x^3|x/4 + |x|x/2 + C

I like your algebra manipulation of absolute value so let me use it too. Disregard the C for now...

(|x^3| + 2|x|)x/4 common denominator 4 and factor out x...now work inside the parenthesis...

|x|(|x^2| + 2)x/4 for the same reasons you gave above...

|x^2| + 2 = |x^2 + 2|

|x||x^2 + 2| = |x^3 + 2x|

|x^3 + 2x|x/4 again for same reasoning as you above... now 1/4 = 1/|4| so you can insert 1/4 into the parenthesis without fear, so you get finally...

|x^3/4 + x/2|x + C

Now if you compare this answer to the question...what is integral of |x^3 + x|, you write it down, divide x^3 by 4 inside absolute value (n + 1 for n = 3), divide x by 2 inside absolute value (n + 1 for n = 1), multiply the whole thing by x and add C

Putting it all together...

integral of |x^3 + x| = |x^3/4 + x/2|x + C

I think the shortcut is obvious now in this case and should work for any integral of |ax^3 + bx| where both a,b are non negative.

I'm still working on integral of |x^3 - x| and trying to make it co-operate with the shortcut, any ideas?

16. Aug 11, 2011

### disregardthat

Split the integral as such:

$$\int^t_{1} |x||x^2-1| dx = \int^t_{1} |x|(x^2-1) dx$$ for t >= 1,

$$\int^t_{-1} |x||x^2-1| dx = \int^t_{-1} |x|(x^2-1) dx$$ for t <= -1

$$\int^t_{0} |x||x^2-1| dx = \int^t_{0} |x|(1-x^2) dx$$ for -1 < t < 1

These three integrals are solved by the method above. For each domain, scale by a constant to get an answer on the form F(x) + C, but it is not necessary.

17. Aug 11, 2011

### agentredlum

Thank you. This is all very nice and important but right now i'm working on my own calculations using pencil and notebook. My PS3 browser does not decode LaTeX so its very hard sometimes to decode it using my brain. Can you solve all 3 integrals above and combine them into a single expression that gives the correct area of |x^3 - x| between the curve and the x-axis from x= -5 to x= 3 for example?

Let me give an simple example. The integral of x from x= -5 to x= 5 gives zero. I'm interested in the integral as AREA between 2 curves.

When you take the absolute value of a function it has 2 important graphical effects for my interests concerning area.

1) Portions below the x-axis are reflected by symmetry to portions above the x-axis with area unchanged.

2) Portions above the x-axis remain unchanged

This can be helpful when you have a function with portions below the x-axis. If one is interested in AREA then you don't have to find roots, split up the integral, use symmetry, etc. Just integrate it's absolute value. If you can find the integral then a single expression will give you the right answer for the area.

Now, I realise integrating |f(x)| is harder than integrating f(x) unless shortcuts can be found and we have shown in previous post's that at least some shortcuts exist. The question interesting to me is can the shortcuts be extended to include more general cases. Any ideas?

This can be helpful, for example, if you are writing a computer program designed to calculate areas. If the program recognises a particular expression as lending itself to the shortcut, then it doesn't have to do integration by parts or some other more exotic method.

Or consider it as a contest between bohrok, who knows the shortcut, and someone who doesn't know the shortcut. The question is find integral of |x^n| for positive odd n. Bohrok gets the answer in 1523 milliseconds, the other person not nearly as fast

Last edited: Aug 11, 2011
18. Aug 11, 2011

### Bohrok

19. Aug 11, 2011

### agentredlum

OH...MY...GOD you have no idea how much i want to thank you for that link. For months i've been hearing about wolfram alpha but i thought it was a computer program like Maple or Mathematica. I didn't know it was on the net, and my PS3 browser decodes it!!!!!

If i was in your neighborhood right now, i'd buy you a beer, i'd buy you 2 beers!.

As far as integral of |x^3 - x| my shortcuts are not working unless i made a mistake.

As for integral of |x^3| wolfram gave answer involving sgn(x) but you and i both know we don't need that. Haaaaaaaa.... Haaaa!

Humanity strikes back against the machines.

20. Aug 12, 2011

### agentredlum

According to wolframalpha...sqrt(abs(x)) has the same graph as abs(sqrt(x)) but that can't be right since domains are different

The first one has domain all real x

The second one has domain all rea NON-NEGATIVE x

What is going on here?

http://www.wolframalpha.com/input/?...,abs(x^(1/2))&asynchronous=false&equal=Submit

In the input interpretation it makes the correct interpretation but in the plots it doesn't.

Last edited: Aug 12, 2011
21. Aug 19, 2011

### Bohrok

Sometimes WA gives results like that which don't make sense. I've tried getting graphs of functions where I tried to limit the domain to nonnegative numbers by using the square root but it would use negatives too...

I've still had no luck in finding ∫|x3 - x| dx. I think it's great that WA found the integral in a "closed form" in the link I gave without breaking it up into different cases with different intervals, but it doesn't show the steps. Not even a time out, just "step-by-step results unavailable." It just seems impossible since the integral doesn't look very similar to |x3 - x|, yet differentiating it and then a lot of simplifying gives you |x3 - x| back.

22. Aug 19, 2011

### disregardthat

If you follow the method of breaking the integral up into the three parts as shown you will get an antiderivative F(x) = f(x) + 1/2 when x >= 1, -f(x) when -1<x<1, and f(x)-1/2 when x <= -1, where f(x) = |x|x(x^2-2)/4.

23. Aug 20, 2011

### Hurkyl

Staff Emeritus
Maybe it decided to consider them as complex functions, in which case they are (identical) functions whose domain is the entire complex plane.

24. Aug 20, 2011

### asw

The trick is that sgn(A) = |A|/A for A≠0.

$\displaystyle\int|x^3-x|\;\mathrm{d}x=\mathrm{sgn}(x^3-x)\int x^3-x\;\mathrm{d}x=\mathrm{sgn}(x^3-x).[\tfrac14x^4-\tfrac12x^2]$
$\displaystyle =\frac{x^2(x^2-2)}{4}\cdot\frac{|x^3-x|}{x^3-x}=\frac{x(x^2-2)}{4}\cdot\frac{\sqrt{x^2(x^2-1)^2}}{x^2-1}$

25. Aug 21, 2011

### agentredlum

Look at the radical in the answer, it simplifies by definition to |x^3-x|

http://www.wolframalpha.com/input/?i=integrate+sqrt((x^3-x)^2)&asynchronous=false&equal=Submit

It was pretty clever of you the way you used parenthesis to trick WA into giving an answer easier to work with.

So there is still hope that a pattern may be found.

Last edited: Aug 21, 2011