Main content

## Integral Calculus (2017 edition)

### Course: Integral Calculus (2017 edition) > Unit 5

Lesson 2: Definite integrals of piecewise functions# Definite integral of absolute value function

Sal evaluates the definite integral of f(x)=|x+2| between -4 and 0.

## Want to join the conversation?

- Can't I just calculate the integral of x+2 and then take the absolute value of the result?(7 votes)
- The problem you run into when you take the absolute value of final result is that you are still getting different values before you calculate the end result.

You can evaluate this yourself by taking the definite integral from

of`[-2, 2]`

and you will see that your end result (whether or not you take the absolute value of it) will give you`(x+2) dx`

for the area. This makes sense because the x-intercept of`8`

is`x+2`

, and then it ascends linearly with a slope of`-2`

.`1`

Basically you're not evaluating the absolute value of the area of the function you're integrating, you're trying to find the area of the absolute value function.

In summary, taking the absolute value of the definite integral is not a helpful way of evaluating this type of problem. The only way I can think of it to be useful in applied math is if you were trying to get the magnitude of the area of a graph, which may be useful in some cases.(15 votes)

- The piecewise function we get as the anti-derivative here is something like { -(x^2)/2 -2x if x <= -2; (x^2)/2 + 2x if x > -2 }. Does anyone have an explanation/intuition for why you can take the antiderivative of something and get a function that's not differentiable or continuous? It seems like it works and makes sense graphically (from the video), But it feels unintuitive that we can take the antiderivative and end up with something that we can't then take the derivative of.(2 votes)
- We
*can't*take an antiderivative and get something nondifferentiable. So this tells you that the antiderivative you found is incorrect.

You didn't include the +C when you took the antiderivatives of the piecewise function. Because we know the function is continuous and differentiable, we can use this to constrain the possible values of these constants.

If we plug x=-2 into the antiderivative pieces, we get 2+C₁ and -2+C₂, for some constants C₁, C₂. We want these to be equal (since we want the pieces of the function to agree at -2), so setting them equal tells us C₂=C₁+4.

So your pieces should be -x²/2 -2x+C and x²/2 +2x+C+4.(4 votes)

- why not rewrite the expression as √((x+2)^2)?(3 votes)
- Is there any way to take the integral of an absolute value expression without turning it into a piecewise function?(1 vote)
- The absolute value function
*is*a piecewise function. You can only avoid this if the argument is strictly positive or strictly negative.(4 votes)

- Hi, does it matter if we set the intervals of the piecewise function as

-(x+2) for x = less than or equal to -2 and x+2 for x = greater than -2? or do the intervals have to be specifically set the way that Sal wrote it?(2 votes) - The anti-derivative for when x<-2 is [-(x^2)/2-2x], did I make a mistake or is it correct that this function can yield a negative value at certain intervals (as x^2 is always positive, -x^2 is always negative and it's value exponentially becomes more and more negative as compared to 2x which only increases linearly)?

How can a negative net area possibly be correct when the whole of the function is above the x-axis?

If my interpretation is wrong, then where does my intuition break down?

Thanks for reading & answering(2 votes)- I think you should try graphing this function again because it is definitely not entirely above the x-axis. However, you are correct in that net area cannot be negative if a function is always positive.(1 vote)

- Can't you say that the integral of |x| is just

(|x|x^2)/2x(1 vote) - Why did we choose -2 as our value for the piece-wise function?(1 vote)
- You get -2 by setting the f(x) equal to 0 (while ignoring the absolute value sign)(1 vote)

## Video transcript

- [Voiceover] So we
have f of x being equal to the absolute value of x plus two. And we wanna evaluate
the definite integral from negative four to zero of f of x, dx. And like always, pause this video and see if you can work through this. Now when you first do this you might stumble around a little bit, because how do you take the anti-derivative of an absolute value function? And the key here is to,
one way to approach it is to rewrite f of x
without the absolute value and we can do that by rewriting it as a piecewise function. And the way I'm gonna
do it, I'm gonna think about intervals where whatever we take inside the absolute value's
going to be positive and other intervals where everything that we take inside the absolute value is going to be negative. And the point at which we change is where x plus two is equal to zero or x is equal to negative two. So let's just think about the intervals x is less than negative
two and x is greater than or equal to negative two. And this could have been less than or equal, in which case this
would have been greater than, either way it would
have been equal to this absolute vale, this is a
continuous function here. And so when, let's do the easier case. When x is greater than
or equal to negative two then x plus two is going to be positive, or it's going to be greater than or equal to zero, and so
the absolute value of it is just going to be x plus two. So it's going to be x plus two when x is greater than
or equal to negative two. And what about when x is
less than negative two? Well when x is less than negative two, x plus two is going to be negative, and then if you take the absolute value of a negative number you're gonna take the opposite of it. So this is going to be
negative x plus two. And to really help grok
this, 'cause frankly this is the hardest part
of what we're doing, and really this is more
algebra than calculus. Let me draw the absolute value function to make this clear. So that is my x-axis, that is my y-axis and let's say we're here at negative two. And so when we are less
than the negative two, when x is less than negative two my graph is going to look like this. It is going to look something, it's gonna look like that. And when we are greater than negative two, do that in a different
color, when we are greater than negative two it's
going to look like this. It's going to look like that. And so notice this is in blue we have, this is the graph x plus two, we can say this is a graph of y equals x plus two. And what we have in
magenta right over here, this is the graph of negative x minus two. It has a negative slope and we intercept the y-axis at negative two. So it makes sense. There's multiple ways that
you could reason through this. Now once we break it up then we can break up the integral. We could say that what we wrote here, this is equal to the integral from negative four to
two, sorry negative four to negative two of f of
x, which is in that case it's going to be negative x minus two, I just distributed the
negative sign there. Dx, and then plus the definite integral going from negative two to zero of x plus two, dx. And just to make sure we know what we're doin' here,
if this is negative four right over here, this is
zero, that first integral is gonna give us this
area right over here. What's the area under the
curve negative x minus two, under that curve or under that
line and above the x-axis. And the second integral
is gonna give us this area right over here between x plus two and the x-axis going from
negative two to zero. And so let's evaluate each of these and you might even be able
to just evaluate these with a little bit of triangle areas, but let's just do this
analytically or algebraically. And so what's the
anti-derivative of negative x? Well that's negative x-squared over two, and then we have the negative two, so this is gonna be the anti-derivative is negative two x, we're
gonna evaluate that at negative two and negative four. And so that part is going to be what? Negative two squared, so it's the negative of negative two squared. So it's negative four over two
minus two times negative two. So plus four. So that's it evaluated at negative two. And then minus, if we
evaluate it at negative four. So we're gonna have minus
negative four squared is 16 over two, minus
two times negative four. So that is plus eight. So what is that going to give us? So this is negative two,
this right over here is negative eight, so the
second term right over here is just going to be equal to zero. Did I do that right? Yeah, the 16 over two, it's
negative and this is positive. Okay, so this is just going to be zero. And this is negative two plus four which is going to be equal to two. So what we have here in
magenta is equal to two. And what we have here in the blue, well let's see, this
is the anti-derivative of x-squared over two, plus two x, gonna evaluate it at
zero and negative two. You evaluate this thing at zero, it's just gonna be zero and from that you're going to subtract
negative two squared over two. That is positive four over two which is positive two. And then plus two times negative two. So minus four. And so this is going to be the negative of negative two, or positive two. So it's two plus two. And that makes sense that what we have in magenta here is two
and what we have over here is two, there's the symmetry here. There is a symmetry here. And so you add 'em all together and you get our integral is
going to be equal to four. And once again, just as a reality check you could say, look,
the height here is two, the width, the base here is two. Two times two times one-half
is indeed equal to two. Same thing over here. So that's the more geometric argument for why that area's two, that area is two, add 'em together you get positive four.