Integration with absolute values

  • Thread starter Shannabel
  • Start date
  • #1
74
0

Homework Statement


if f(x)=abs(x-2) and g(x)=abs(x), then solve the integral from -1 to 3 of abs(f(x)-g(x))dx


Homework Equations





The Attempt at a Solution


resolved absolute values:
when x<0, abs(x-2)-abs(x) = -x-2+x = 2
when 0<x<1, abs(x-2)-abs(x) = (-x+2)-x = 2-2x
when 1<x<2, abs(x-2)-abs(x) = (-x+2)-x = 2-2x
when x>2, abs(x-2)-abs(x) = x-2-x = 2

so now i have
2dx(between 0 and -1)+(2-2x)dx(between 0 and 1)+(2-2x)dx(between 1 and 2)+2dx(between 2 and 3)
= 2x(from 0 to -1) + 2x-x^2(between 0 and 1)+ 2x-x^2(between 1 and 2) + 2x(from 2 to 3)
= -2 + (2-1) + (2-1) +2 = 2

I should have had 6 as my answer, so i'm guessing that the first integral should be 2 instead of -2, but i'm not sure why.. any ideas?
also, if f(x)-g(x) is the same between 0 and 1 and 1 and 2, why is it that when i solve just between 0 and 2 i get a different answer than when i solve the two separately?
 

Answers and Replies

  • #2
I like Serena
Homework Helper
6,577
176
Hi Shannabel! :smile:

Let's see.
I'm going to add some parentheses:

[tex]\int_{-1}^{3} |~ |x-2| - |x| ~| dx[/tex]
[tex]= \int_{-1}^{0} 2 dx + \int_{0}^{1} (2-2x) dx + \int_{1}^{2} (2x-2) dx + \int_{2}^{3} 2 dx[/tex]
[tex]= (2x) |_{-1}^0 + (2x - x^2) |_0^1 + (x^2 - 2x) |_1^2 + (2x) |_2^3[/tex]
[tex]= (0 - 2\cdot -1) + ((2\cdot 1 - 1^2) - 0) +( (2^2 - 2\cdot 2) - (1^2 - 1\cdot 2)) + (2\cdot 3 - 2 \cdot 2)[/tex]
[tex]= 2 + (2-1) + ((4-4)-(1-2)) + (6-4)[/tex]
[tex]= 2 + 1 + 1 + 2[/tex]
[tex]= 6[/tex]

I should have had 6 as my answer, so i'm guessing that the first integral should be 2 instead of -2, but i'm not sure why.. any ideas?
also, if f(x)-g(x) is the same between 0 and 1 and 1 and 2, why is it that when i solve just between 0 and 2 i get a different answer than when i solve the two separately?

As for these questions, can you redo calculating these, this time adding parentheses where they are appropriate?
 
Last edited:
  • #3
74
0
Hi Shannabel! :smile:

Let's see.
I'm going to add some parentheses:

[tex]\int_{-1}^{3} |~ |x-2| - |x| ~| dx[/tex]
[tex]= \int_{-1}^{0} 2 dx + \int_{0}^{1} (2-2x) dx + \int_{1}^{2} (2-2x) dx + \int_{2}^{3} 2 dx[/tex]
[tex]= (2x) |_{-1}^0 + (2x - x^2) |_0^1 + (2x - x^2) |_1^2 + (2x) |_2^3[/tex]
[tex]= (0 - 2\cdot -1) + ((2\cdot 1 - 1^2) - 0) +( (2\cdot 2 - 2^2)- (1\cdot 2 - 1^2)) + (2\cdot 3 - 2 \cdot 2)[/tex]
[tex]= 2 + (2-1) + ((4-2)-(2-1)) + (6-4)[/tex]
[tex]= 2 + 1 + 1 + 2[/tex]
[tex]= 6[/tex]



As for these questions, can you redo calculating these, this time adding parentheses where they are appropriate?

hi! :)

i still don't understand.. in your third step, why do you have (0-2*(-1)) instead of (0*2*(-1))?
 
  • #4
I like Serena
Homework Helper
6,577
176
hi! :)

i still don't understand.. in your third step, why do you have (0-2*(-1)) instead of (0*2*(-1))?

Why would you want to do a multiplication here?

To write it out more, it is:
[tex](2x)|_{-1}^{0} = ((2 \cdot 0) - (2 \cdot -1))[/tex]
This is how the result of an integral is calculated.

Btw, I made a mistake myself in my previous post! :surprised
I just edited it.
Note that your absolute value expressions are not quite right yet.
 
  • #5
74
0
Why would you want to do a multiplication here?

To write it out more, it is:
[tex](2x)|_{-1}^{0} = ((2 \cdot 0) - (2 \cdot -1))[/tex]
This is how the result of an integral is calculated.

Btw, I made a mistake myself in my previous post! :surprised
I just edited it.
Note that your absolute value expressions are not quite right yet.

oh! of course, silly me.

i don't understand why you get 2x-2 instead of 2-2x between 1 and 2?
 
  • #6
I like Serena
Homework Helper
6,577
176
oh! of course, silly me.

i don't understand why you get 2x-2 instead of 2-2x between 1 and 2?

In your problem statement you say you have to integrate abs(f(x)-g(x))dx.
So you still need to take the absolute value of 2-2x between 1 and 2...
Which values does it take in that interval?
 
  • #7
74
0
In your problem statement you say you have to integrate abs(f(x)-g(x))dx.
So you still need to take the absolute value of 2-2x between 1 and 2...
Which values does it take in that interval?

abs(x-2) is negative and abs(x) is positive, no?
 
  • #8
I like Serena
Homework Helper
6,577
176
abs(x-2) is negative and abs(x) is positive, no?

Hmmm, (x-2) is negative and (x) is positive.
Their absolute values are both positive. :wink:

But what is the sign of (abs(x-2) - abs(x))?
And consequently, what is the expression for abs(abs(x-2) - abs(x))?
 
  • #9
74
0
Hmmm, (x-2) is negative and (x) is positive.
Their absolute values are both positive. :wink:

But what is the sign of (abs(x-2) - abs(x))?
And consequently, what is the expression for abs(abs(x-2) - abs(x))?

it would all be negative..
so
-[(x-2)-(x)]
= -[2x+2]
= 2-2x

i'm confused!
 
  • #10
I like Serena
Homework Helper
6,577
176
it would all be negative..
so
-[(x-2)-(x)]
= -[2x+2]
= 2-2x

i'm confused!

Hmmm, if I evaluate that, I get:
-[(x-2)-(x)] = -[-2] = 2 :confused:

I think you dropped a minus sign somewhere. Can you correct that?
 
  • #11
74
0
Hmmm, if I evaluate that, I get:
-[(x-2)-(x)] = -[-2] = 2 :confused:

I think you dropped a minus sign somewhere. Can you correct that?

yes, you're right!
but i can't find the mistake that led me to that mistake..?
 
  • #12
I like Serena
Homework Helper
6,577
176
yes, you're right!
but i can't find the mistake that led me to that mistake..?

Well, you started by saying that (x-2) is negative for 1<x<2.
So its absolute value is -(x-2)......
 
  • #13
74
0
Well, you started by saying that (x-2) is negative for 1<x<2.
So its absolute value is -(x-2)......

but then i have -x+2 right?
and then because x is positive i end up with 2...
but you ended up with 2x-2?
 
  • #14
I like Serena
Homework Helper
6,577
176
but then i have -x+2 right?
and then because x is positive i end up with 2...
but you ended up with 2x-2?

Let's take a step back.
You (should have) had: -[-(x-2)-(x)] = ...
What do you get if you work that out?
 
  • #15
74
0
Let's take a step back.
You (should have) had: -[-(x-2)-(x)] = ...
What do you get if you work that out?

can you explain why the whole term is negative?
i don't think i understand resolving absolute values nearly as well as i thought i did..
 
  • #16
I like Serena
Homework Helper
6,577
176
can you explain why the whole term is negative?
i don't think i understand resolving absolute values nearly as well as i thought i did..

The thing to remember is that:
[tex]\textrm{abs}(x) = \left[ \begin{matrix}
(x), & \textrm{ if $x \ge 0$}\\
-(x), & \textrm{ if $x < 0$}
\end{matrix} \right.[/tex]

We have 1<x<2.

Let's start with abs(x-2)-abs(x)
Since (x-2) is negative, and (x) is positive, this is equal to [-(x-2)-(x)] = [2-2x]

Next step is abs(abs(x-2)-abs(x)).
This is equal to abs(2-2x), which we just derived.
Since 2-2x is negative, this is equal to -(2-2x).
 
  • #17
74
0
The thing to remember is that:
[tex]\textrm{abs}(x) = \left[ \begin{matrix}
(x), & \textrm{ if $x \ge 0$}\\
-(x), & \textrm{ if $x < 0$}
\end{matrix} \right.[/tex]

We have 1<x<2.

Let's start with abs(x-2)-abs(x)
Since (x-2) is negative, and (x) is positive, this is equal to [-(x-2)-(x)] = [2-2x]

Next step is abs(abs(x-2)-abs(x)).
This is equal to abs(2-2x), which we just derived.
Since 2-2x is negative, this is equal to -(2-2x).

i'm pretty sure i understand now :)
just one other thing.. i understand why i needed to resolve with x=0 and x=2 as boundaries, since they are both zeros.. but i don't understand why i needed to use x=1?
 
  • #18
I like Serena
Homework Helper
6,577
176
i'm pretty sure i understand now :)
just one other thing.. i understand why i needed to resolve with x=0 and x=2 as boundaries, since they are both zeros.. but i don't understand why i needed to use x=1?

Errr... at x=0 and x=2 the complete expression is not zero.
However, the form of the expression does change, since part of the expression is an absolute value of which the argument changes sign.

So what was the expression again for 0<x<1?
And what was the expression for 1<x<2?

You should see that these are different expressions, so they have to be integrated separately.
 
  • #19
74
0
Errr... at x=0 and x=2 the complete expression is not zero.
However, the form of the expression does change, since part of the expression is an absolute value of which the argument changes sign.

So what was the expression again for 0<x<1?
And what was the expression for 1<x<2?

You should see that these are different expressions, so they have to be integrated separately.

yes, but how should i have known at the beginning that the expression changes sign at x=1?
it makes sense to me that if (x-2)=0, then x=2 is a critical point and x=0 is a critical point, but i don't see where i should have got the 1?
 
  • #20
I like Serena
Homework Helper
6,577
176
yes, but how should i have known at the beginning that the expression changes sign at x=1?
it makes sense to me that if (x-2)=0, then x=2 is a critical point and x=0 is a critical point, but i don't see where i should have got the 1?

At the beginning you wouldn't know.
So you'd consider 0<x<2 as a first step and get the expression [abs(x-2)-abs(x)] = [2-2x].
But you still need to take the absolute value from this expression.
At what point does the expression [2-2x] change sign?
 
  • #21
74
0
At the beginning you wouldn't know.
So you'd consider 0<x<2 as a first step and get the expression [abs(x-2)-abs(x)] = [2-2x].
But you still need to take the absolute value from this expression.
At what point does the expression [2-2x] change sign?

i got it, thanks!: )
 
  • #22
SammyS
Staff Emeritus
Science Advisor
Homework Helper
Gold Member
11,368
1,035

Homework Statement


if f(x)=abs(x-2) and g(x)=abs(x), then solve the integral from -1 to 3 of abs(f(x)-g(x))dx

Homework Equations



The Attempt at a Solution


resolved absolute values:
when x<0, abs(x-2)-abs(x) = -x-2+x = 2   should be abs(x-2)-abs(x) = -(x-2)+x = 2

when 0<x<1, abs(x-2)-abs(x) = (-x+2)-x = 2-2x   These two could be written as one.
when 1<x<2, abs(x-2)-abs(x) = (-x+2)-x = 2-2x   These two could be written as one.  

when x>2, abs(x-2)-abs(x) = x-2-x = 2   should be abs(x-2)-abs(x) = x-2-x = 2
...

Here's the first part of your Original Post.

See corrections and/or comments in RED.
 
  • #23
74
0
The thing to remember is that:
[tex]\textrm{abs}(x) = \left[ \begin{matrix}
(x), & \textrm{ if $x \ge 0$}\\
-(x), & \textrm{ if $x < 0$}
\end{matrix} \right.[/tex]

We have 1<x<2.

Let's start with abs(x-2)-abs(x)
Since (x-2) is negative, and (x) is positive, this is equal to [-(x-2)-(x)] = [2-2x]

Next step is abs(abs(x-2)-abs(x)).
This is equal to abs(2-2x), which we just derived.
Since 2-2x is negative, this is equal to -(2-2x).

by this same logic, shouldn't i have
if x>2, abs(abs(x-2)-abs(x)) = -(abs(x-2-x)) = -(2)
since abs(x-2) and abs(x) are positive but abs(abs(x-2)-abs(x)) is negative?
i know it should be a positive 2 since that gets me to the right answer... but i don't see why?
 
  • #24
I like Serena
Homework Helper
6,577
176
by this same logic, shouldn't i have
if x>2, abs(abs(x-2)-abs(x)) = -(abs(x-2-x)) = -(2)
since abs(x-2) and abs(x) are positive but abs(abs(x-2)-abs(x)) is negative?
i know it should be a positive 2 since that gets me to the right answer... but i don't see why?

Can you calculate (x-2-x) again?
 
  • #25
74
0

Related Threads on Integration with absolute values

  • Last Post
Replies
4
Views
1K
Replies
3
Views
1K
Replies
3
Views
8K
  • Last Post
Replies
2
Views
10K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
3
Views
1K
  • Last Post
Replies
4
Views
2K
Replies
4
Views
2K
  • Last Post
Replies
15
Views
2K
Replies
7
Views
1K
Top