Definite integral of absolute value function | AP Calculus AB | Khan Academy
So we have F of x being equal to the absolute value of x + 2, and we want to evaluate the definite integral from 4 to 0 of f of x dx. And like always, pause this video and see if you could 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? The key here is to—one way to approach it is to rewrite F of x without the absolute value. We can do that by rewriting it as a piecewise function. The way I'm going to do it, I'm going to think about intervals where whatever we take inside the absolute value is going to be positive, and other intervals where everything that we take inside the absolute value is going to be negative.
The point at which we change is where x + 2 is equal to 0, or x is equal to -2. So let's just think about the intervals: x is less than -2 and x is greater than or equal to -2. This could have been less than or equal, in which case this would have been greater. Either way, it would have been equal to this absolute value. This is a continuous function here.
When we do the easier case, when x is greater than or equal to -2, then x + 2 is going to be positive, or it's going to be greater than or equal to zero. So the absolute value of it is just going to be x + 2. It's going to be x + 2 when x is greater than or equal to -2.
What about when x is less than -2? Well, when x is less than -2, x + 2 is going to be negative, and if you take the absolute value of a negative number, you're going to take the opposite of it. So this is going to be -x + 2.
To really help grasp this, because 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 -2.
When we are less than -2 (when x is less than -2), my graph is going to look like this; it is going to look something—let's see what is—it’s going to look like that. When we are greater than -2, we do that in a different color. When we are greater than -2, it's going to look like this; it’s going to look like that.
Notice, this is in blue; we have the graph of x + 2. We could say this is the graph of y = x + 2. What we have in magenta right over here is the graph of -x + 2; it has a negative slope and we intercept the y-axis at -2. So it makes sense there are multiple ways that you could reason through this.
Now, once we break it up, we can break up the integral. We could say that what we wrote here, this is equal to the integral from -4 to -2 of f of x, which, in that case, is -x + 2. I just distributed the negative sign there dx, and then plus the definite integral going from -2 to 0 of x + 2 dx.
Just to make sure we know what we're doing here, this—if this is -4 right over here, this is zero. That first integral is going to give us this area right over here. What's the area under the curve of -x + 2, under that curve or under that line and above the x-axis? The second integral is going to give us this area right over here between x + 2 and the x-axis going from -2 to 0.
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. What’s the anti-derivative of -x? Well, that’s -x^2/2. Then we have the min, the -2, or so the anti-derivative is -2x. We're going to evaluate that at -2 and -4.
So that part is going to be what? -2*(-2)^2/2 - 2*(-2). So it’s -4/2 + 4, so that’s it evaluated at -2, and then minus if we evaluated it at -4, so minus. We’re going to have -(-4)^2 = 16/2 - 2*(-4). So that is +8.
What is that going to give us? So this is -2; this right over here is 8. So the second term right over here is just going to be equal to zero. Did I do that right? Yeah, the 16/2, it's negative and it's positive.
Okay, so this is just going to be zero, and this is -2 + 4, which is going to be equal to 2. So what we have here in magenta is equal to 2, and what we have here in blue, well, let’s see. This is the anti-derivative of -x^2/2 + 2x. We’re going to evaluate it at 0 and -2.
You evaluate this thing at zero, it’s just going to be zero, and from that you’re going to subtract -2*(-2)^2/2, which is 4/2, which is positive 2, and then +2*(-2) so min -(-4). So this is going to be, this is going to be the negative of -2, or positive 2.
So it’s 2 + 2, and that makes sense; what we have in magenta here is 2, and what we have over here is 2. There’s a symmetry here, there is a symmetry here.
So you add them all together, and you get our integral is going to be equal to 4. Once again, just as a reality check, you could say, look, the height here is 2, the width—the base here is 2. 2 * 2 * 1/2 is indeed equal to 2; same thing over here.
So that’s the more geometric argument for why that area is 2, that area is 2. Add them together, you get positive 4.