# Triple integrals 2 | Double and triple integrals | Multivariable Calculus | Khan Academy

In the last video, we had this rectangle, and we used a triple
integral to figure out it's volume.
And I know you were probably thinking, well, I could have
just used my basic geometry to multiply the height times
the width times the depth.
And that's true because this was a constant-valued function.
And then even once we evaluated, once we integrated
with respect to z, we ended up with a double integral, which
is exactly what you would have done in the last several videos
when we just learned the volume under a surface.
But then we added a twist at the end of the video.
We said, fine, you could have figured out the volume within
this rectangular domain, I guess, very straightforward
using things you already knew.
But what if our goal is not to figure out the volume?
Our goal was to figure out the mass of this volume, and even
more, the material that we're taking the volume of-- whether
it's a volume of gas or a volume of some solid-- that
its density is not constant.
So now the mass becomes kind of-- I don't know--
interesting to calculate.
And so, what we defined, we defined a density function.
And rho, this p looking thing with a curvy bottom-- that
gives us the density at any given point.
And at the end of the last video we said,
well, what is mass?
Mass is just density times volume.
You could view it another way.
Density is the same thing as mass divided by volume.
So the mass around a very, very small point, and we called that
d mass, the differential of the mass, is going equal the
density at that point, or the rough density at exactly that
point, times the volume differential around that point,
times the volume of this little small cube.
And then, as we saw it on the last video, if you're using
rectangular coordinates, this volume differential could just
be the x distance times the y distance times the z distance.
So, the density was that our density function is defined
to be x, y, and z, and we wanted to figure out the
mass of this volume.
And let's say that our x, y, and z coordinates-- their
values, let's say they're in meters and let's say this
density is in kilograms per meter cubed.
So our answer is going to be in kilograms if that was the case.
And those are kind of the traditional Si units.
So let's figure out the mass of this variably dense volume.
So all we do is we have the same integral up here.
So the differential of mass is going to be this value,
so let's write that down.
It is x-- I want to make sure I don't run out of space.
xyz times-- and I'm going to integrate with
respect to dz first.
But you could actually switch the order.
Maybe we'll do that in the next video.
We'll do dz first, then we'll do dy, then we'll do dx.
Once again, this is just the mass at any small
differential of volume.
And if we integrate with z first we said z goes from what?
The boundaries on z were 0 to 2.
The boundaries on y were 0 to 4.
And the boundaries on x, x went from 0 to 3.
And how do we evaluate this?
Well, what is the antiderivative-- we're
integrating with respect to z first.
So what's the antiderivative of xyz with respect to z?
Well, let's see.
This is just a constant so it'll be xyz squared over 2.
Right?
Yeah, that's right.
And then we'll evaluate that from 2 to 0.
And so you get-- I know I'm going to run out of space.
So you're going to get 2 squared, which is 4,
divided by 2, which is 2.
So it's 2xy minus 0.
So when you evaluate just this first we'll get 2xy, and
now you have the other two integrals left.
So I didn't write the other two integrals down.
Maybe I'll write it down.
So then you're left with two integrals.
You're left with dy and dx.
And y goes from 0 to 4 and x goes from 0 to 3.
I'm definitely going to run out of space.
And now you take the antiderivative of this
with respect to y.
So what's the antiderivative of this with respect to y?
Let me erase some stuff just so I don't get too messy.
I was given the very good suggestion of making it
scroll, but, unfortunately, I didn't make it scroll
enough this time.
So I can delete this stuff, I think.
Oops, I deleted some of that.
But you know what I deleted.
OK, so let's take the antiderivative
with respect to y.
I'll start it up here where I have space.
OK, so the antiderivative of 2xy with respect to y is y
squared over 2, 2's cancel out.
So you get xy squared.
And y goes from 0 to 4.
And then we still have the outer integral to do.
x goes from 0 to 3 dx.
And when y is equal to 4 you get 16x.
And then when y is 0 the whole thing is 0.
So you have 16x integrated from 0 to 3 dx.
And that is equal to what?
8x squared.
And you evaluate it from 0 to 3.
When it's 3, 8 times 9 is 72.
And 0 times 8 is 0.
So the mass of our figure-- the volume we figured out last
time was 24 meters cubed.
I erased it, but if you watched the last video
that's what we learned.
But it's mass is 72 kilograms.
And we did that by integrating this 3 variable density
function-- this function of 3 variables.
Or in three-dimensions you can view it as a
scalar field, right?
At any given point, there is a value, but not
really a direction.
And that value is a density.
But we integrated the scalar field in this volume.
So that's kind of the new skill we learned with
the triple integral.
And in the next video I'll show you how to set up more
complicated triple integrals.
But the real difficulty with triple integrals is-- and I
think you'll see that your calculus teacher will often do
this-- when you're doing triple integrals, unless you have a
very easy figure like this, the evaluation-- if you actually
wanted to analytically evaluate a triple integral that has more
complicated boundaries or more complicated for example,
a density function.
The integral gets very hairy, very fast.
And it's often very difficult or very time consuming to
evaluate it analytically just using your traditional
calculus skills.
So you'll see that on a lot of calculus exams when they start
doing the triple integral, they just want you to set it up.
They take your word for it that you've done so many integrals
so far that you could take the antiderivative.
And sometimes, if they really want to give you something more
difficult they'll just say, well, switch the order.
You know, this is the integral when we're dealing with
respect to z, then y, then x.
We want you to rewrite this integral when
you switch the order.
And we will do that in the next video.
See you soon.