If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Triple integrals in spherical coordinates

How to perform a triple integral when your function and bounds are expressed in spherical coordinates.

Background

Different authors have different conventions on variable names for spherical coordinates. For this article, I will use the following convention. (In each description the "radial line" is the line between the point we are giving coordinates to and the origin).
  • r indicates the length of the radial line.
  • θ the angle around the z-axis. Specifically, if you project the radial line onto the xy-plane, θ is the angle that line makes with the x-axis.
  • ϕ the angle between the radial line and the z-axis.
The following two are not strictly required, but they might help as warm up and practice for this topic.

What we're building to

  • When you are performing a triple integral, if you choose to describe the function and the bounds of your region using spherical coordinates, (r,ϕ,θ), the tiny volume dV should be expanded as follows:
Rf(r,ϕ,θ)dV=Rf(r,ϕ,θ)(dr)(rdϕ)(rsin(ϕ)dθ)=Rf(r,ϕ,θ)r2sin(ϕ)dθdϕdr
The key term to remember (or re-derive) is r2sin(ϕ)
  • Converting to spherical coordinates can make triple integrals much easier to work out when the region you are integrating over has some spherical symmetry.

Dissecting tiny volumes in spherical coordinates

As discussed in the introduction to triple integrals, when you are integrating over a three-dimensional region R, it helps to imagine breaking it up into infinitely many infinitely small pieces, each with volume dV.
When you were working in cartesian coordinates, these tiny pieces were thought of as rectangular blocks. In spherical coordinates, on the other hand, it helps to think of your tiny pieces as being slightly curved blocks "hugging" a sphere. I'll be drawing a fairly large version of one of these chunks, partly to exaggerate its curvature, and partly just so we can see it. For example, here's what one looks like in three dimensions:
Khan Academy video wrapper
The reason for this shape is that each face represents a constant value for one of the spherical coordinates:
  • One pair of faces represents constant values of r (these will be slightly curved, as if hugging a sphere).
  • One pair of faces represents constant values of ϕ.
  • One pair of faces represents constant values of θ.
Why is that significant? Because the way multiple integrals work is that each individual integral treats all coordinate as constants, except for one. Therefore, as we consider how the multiple integral as a whole assembles these tiny pieces together, it is more natural to think about pieces whose volume can be expressed in terms of changes to individual coordinates. This will become clearer as you read further.
As the size of these blocks approaches zero, the curve will become so negligible that we can treat them as rectangular prisms. One edge represents a tiny change in the length in the distance from the origin, dr:
The other two edges are related to the tiny changes in the other two coordinates, dθ and dϕ . However, since θ and ϕ measure radians, not a unit of length, these values must be multiplied by a unit of length in order to properly reflect the lengths of the edges in our rectangular prism.
For example, the edge representing a change in ϕ has length rdϕ:
The edge representing a change in θ is a little trickier. This edge is part of some circle wrapping around the z-axis, and the radius of that circle is not r, but rsin(ϕ). This means the arc length due to a small change in θ is rsin(ϕ)dθ.
That can be confusing at first, so it might be worth a moment of contemplation to ensure you understand how that works.
Putting all this together, we can express the volume of our "rectangular" block in terms of dr, dϕ and dθ by taking the product of all its side lengths.
dV=(dr)(rdϕ)(rsin(ϕ)dθ)=r2sin(ϕ)drdϕdθ
In other words, when you have some triple integral,
RfdV
and you choose to express the bounds and the function using spherical coordinates, you cannot just replace dV with drdϕdθ. You must also remember the r2sin(ϕ) term:
Rf(r,θ,ϕ)r2sin(ϕ)drdϕdθ
Personally, I can never quite remember exactly how to expand the dV term off the top of my head
"Was it sin(ϕ) or sin(θ)... and is it r or r2...?"
Instead, I think through the process I just illustrated above, asking what the arc lengths resulting from changes to ϕ and θ are.

Example 1: Volume of a sphere revisited

This might be the simplest possible starting example for triple integration in spherical coordinates, but it let's us compute an interesting non-trivial fact: The volume of a sphere.
Question: What is the volume of a sphere with radius R?
Situate the sphere such that its center is on the origin.
If we were doing this integral in cartesian coordinates, we would have that ugly-but-common situation where the bounds of inner integrals are functions of the outer variables. However, because spherical coordinates are so well suited to describing, well, actual spheres, our bounds are all constants.
Concept check: Which of the following sets of bounds on the coordinates r, ϕ and θ accurately describes all the points inside a sphere of radius R (without running over the entire sphere multiple times)
Choose 1 answer:

Using these bounds, together with the fact that
dV=r2sin(ϕ)drdϕdθ
we can start setting up our integral like this:
BalldV=02π0π0Rr2sin(ϕ)drdϕdθ
Concept check: Work through this integral, and appreciate just how lovely it is compared with the other nasty triple integrals you may have encountered.
02π0π0Rr2sin(ϕ)drdϕdθ=

If you dare, imagine trying to do this integral in cartesian coordinates. It's a nightmare! This gives us an important takeaway:
Key takeaway If you are integrating over a region with some spherical symmetry, passing to spherical coordinates can make the bounds much nicer to deal with.

Example 2: Integrating a function

Integrate the function
f(x,y,z)=x+2y+3z
in the region of the first octant where
x2+y2+z23

Step 1: Express the region in spherical coordinates.

How could you know that we should pass to spherical coordinates? We could do this whole integral in cartesian coordinates, couldn't we? Cylindrical coordinates would work too.
The fact that our boundary includes the condition x2+y2+z23 is a description of the distance between points of our region and the origin. Since the spherical coordinate r expresses precisely this idea, we can feel confident that describing the boundary of our region using r will make the bounds of our three integrals simpler than if we did so in terms of x, y and z.
Specifically, this condition becomes
x2+y2+z23r23r3
Concept check: What about θ and ϕ? What bounds should we place on these two coordinates to keep our integral within the first octant?
θ
ϕ

Step 2: Express the function in spherical coordinates

Next, we convert the function
f(x,y,z)=x+2y+3z
into spherical coordinates. To do this, we use the conversions for each individual cartesian coordinate.
  • x=rsin(ϕ)cos(θ)
  • y=rsin(ϕ)sin(θ)
  • z=rcos(ϕ)
Plugging each of these in, we get
f(x,y,z)=x+2y+3z=rsin(ϕ)cos(θ)+2rsin(ϕ)sin(θ)+3rcos(ϕ)=r(sin(ϕ)cos(θ)+2sin(ϕ)sin(θ)+3cos(ϕ))
You might say that this makes things more complicated than they were in cartesian coordinates. And you'd be right! But when it comes to triple integrals, a more complicated function is a relatively small price to pay for getting our bounds to be constants.

Step 3: Compute the triple integral

Concept check: Putting the previous two steps together, what is the integral that we need to solve?
Choose 1 answer:

Bring it on home: Solve that integral!
Integral from previous question:

Summary

  • When you are performing a triple integral, if you choose to describe the function and the bounds of your region using spherical coordinates, (r,ϕ,θ), the tiny volume dV should be expanded as follows:
    Rf(r,ϕ,θ)dV=Rf(r,ϕ,θ)(dr)(rdϕ)(rsin(ϕ)dθ)=Rf(r,ϕ,θ)r2sin(ϕ)dθdϕdr
    The key term to remember (or re-derive) is r2sin(ϕ)
  • Converting to spherical coordinates can make triple integrals much easier to work out when the region you are integrating over has some spherical symmetry.

Want to join the conversation?

  • blobby green style avatar for user Marin Dumitru
    For the last triple integral, my answer is 27pi/8 and not 81pi/16.
    (9 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Nuno Daniel
    In my book the key term to remember is rather R^2*COS(ϕ§). Why is it different here?
    (6 votes)
    Default Khan Academy avatar avatar for user
    • orange juice squid orange style avatar for user Kai Shaikh
      Maybe your book is using phi as the angle of elevation from the xy plane instead of from the positive x axis. In other words, this would start at π/2 (in the sin version) and go in the opposite direction (since elevation from the xy plane means decreasing phi as measured from the positive z-axis. Since sin(π/2-x) = cosx, these two statements would be equivalent.
      (6 votes)
  • male robot hal style avatar for user David
    how do you get x=rsin(phi)cos(theta) y=rsin(phi)sin(theta) and z=rcos(phi)
    (3 votes)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user avivbrest
      To find the values of x, y, and z in spherical coordinates, you can construct a triangle, like the first figure in the article, and use trigonometric identities to solve for the coordinates in terms of r, theta, and phi. To do this, I find it easier to first find that ϕ is the angle of the triangle opposite the line segment in the xy-plane. This is the angle between the hypotenuse of the triangle and its z-component.

      For z, take cos(ϕ) = z/r. Then solve for z to find z = r*cos(ϕ).

      For x and y, we first have to find the component in the xy-plane, then use θ to solve for the two coordinates. The component of r in the xy-plane, which I'll refer to as R, is given by sin(ϕ) = R/r. Solving for R gives R = r*sin(ϕ).

      Now that we have the component of r in the xy-plane, we can find the x and y components. Construct another triangle in the xy-plane with a hypotenuse of length R, and with an angle of θ between the hypotenuse and x-component.

      For x, we find that cos(θ) = x/R. Solving for x gives x = R*cos(θ). Substituting the value of R we found earlier gives x = r*sin(ϕ)*cos(θ).

      For y, we use similar logic to get y = R*sin(θ). Then substituting in the value of R gives
      y = r*sin(ϕ)*sin(θ).
      (10 votes)
  • duskpin sapling style avatar for user Nikitacina
    From the first problem, I don't understand why are the limits of phi are from 0 to pi. Shouldn't they be from 0 to 2*pi?
    I don't understand the explanation in the article.
    (4 votes)
    Default Khan Academy avatar avatar for user
    • piceratops seed style avatar for user amg227
      I believe because you are already running around the sphere with theta(circle perimeter), you only need to check the vertical side of the sphere to account for the entire surface.

      Doing 0 -> 2*pi counts both sides, but since you are already running around the whole circle perimeter this will count it twice.
      (5 votes)
  • blobby green style avatar for user sohammakim.10
    For the first concept check in example number 1, what if you let theta range from 0-pi and a phi range from 0-2pi?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • aqualine ultimate style avatar for user Charles James
    I am having so much trouble finding a resource that explains: the tiny volume dV is expanded the way it is above. Can somone point me in the direction of a proof?
    (1 vote)
    Default Khan Academy avatar avatar for user
    • orange juice squid orange style avatar for user Kai Shaikh
      I suggest learning about the Jacobian matrix, which provides a more general framework for coordinate transformations in integrals and allows easy computation of the necessary corrections in area/volume differential elements (in this case, the jacobian would relate dxdydz to drdϕdθ by some function of r,θ, and ϕ, which in this case turns out to be (r^2)​​sin(ϕ)).
      (5 votes)
  • blobby green style avatar for user mathisduguin
    I got the volume of a sphere with raidus r using cartesian coordinate integration and I can confirm, it's a pain (involves trig substitution, u substitution, and annoying bounds)
    (2 votes)
    Default Khan Academy avatar avatar for user
  • leaf blue style avatar for user Richard
    Hello friends, In the text of the article [such as in the summary] it is stated that spherical coordinates are (r, phi, theta) but in two of the figures the coordinates are shown as (r, theta, phi). Which is correct or does the sequence in a triplet vary among authors [as which angle is phi and which is theta varies]? Which is correct would matter if you were given (2, 0.5, 0.75) and asked where it is. Also - just for curiosity - are the 8 octants numbered in any consistent way? The articles are great. Best wishes to all. (April 2019)
    (1 vote)
    Default Khan Academy avatar avatar for user
    • leafers seedling style avatar for user thymetuo
      The ordering of the variables does not matter as long as their definitions and order remain consistent. Some put it (r, phi, theta) and others (r, theta, phi). The wikipedia page on "Octant (solid geometry)" has a table showing the octant numbering.
      (2 votes)
  • blobby green style avatar for user benjiwoollven
    Could you not switch the differential θ and ϕ so that θ becomes rdθ and ϕ becomes rsin(θ)dϕ? Would this just mean that instead of having the radius change as you move along z, it would change as you move across the xy plane? This is referring to the explanation for each differential variable you give.
    (1 vote)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user aisha.noor0204
    What if we are given an improper integral (from -oo to oo) with a regular xyz function and we are told to change the function into spherical coordinates. What should the bounds look like then?
    (1 vote)
    Default Khan Academy avatar avatar for user