Main content

## Multivariable calculus

### Course: Multivariable calculus > Unit 4

Lesson 9: Polar, spherical, and cylindrical coordinates# Triple integrals in spherical coordinates

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

## Background

- Spherical coordinates:

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.
- theta the angle around the z-axis. Specifically, if you project the radial line onto the x, y-plane, theta is the angle that line makes with the x-axis.
- \phi 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, left parenthesis, r, comma, \phi, comma, theta, right parenthesis, the tiny volume d, V should be expanded as follows:

The key term to remember (or re-derive) is start color #bc2612, r, squared, sine, left parenthesis, \phi, right parenthesis, end color #bc2612

- 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 d, V.

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:

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 start color #0c7f99, r, end color #0c7f99 (these will be slightly curved, as if hugging a sphere).
- One pair of faces represents constant values of start color #a75a05, \phi, end color #a75a05.
- One pair of faces represents constant values of start color #0d923f, theta, end color #0d923f.

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, start color #0c7f99, d, r, end color #0c7f99:

The other two edges are related to the tiny changes in the other two coordinates, start color #0d923f, d, theta, end color #0d923f and start color #a75a05, d, \phi, end color #a75a05 . However,

**since start color #0d923f, theta, end color #0d923f and start color #a75a05, \phi, end color #a75a05 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 start color #a75a05, \phi, end color #a75a05 has length start color #a75a05, r, d, \phi, end color #a75a05:

The edge representing a change in start color #0d923f, theta, end color #0d923f is a little trickier. This edge is part of some circle wrapping around the z-axis, and the radius of that circle is not start color #0c7f99, r, end color #0c7f99, but start color #0c7f99, r, end color #0c7f99, sine, left parenthesis, start color #a75a05, \phi, end color #a75a05, right parenthesis. This means the arc length due to a small change in start color #0d923f, theta, end color #0d923f is start color #0c7f99, r, end color #0c7f99, sine, left parenthesis, start color #a75a05, \phi, end color #a75a05, right parenthesis, start color #0d923f, d, theta, end color #0d923f.

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 start color #0c7f99, d, r, end color #0c7f99, start color #a75a05, d, \phi, end color #a75a05 and start color #0d923f, d, theta, end color #0d923f by taking the product of all its side lengths.

In other words, when you have some triple integral,

and you choose to express the bounds and the function using spherical coordinates,

**you cannot just replace d, V with d, r, d, \phi, d, theta**. You must also remember the start color #bc2612, r, squared, sine, left parenthesis, \phi, right parenthesis, end color #bc2612 term:Personally, I can never quite remember exactly how to expand the d, V term off the top of my head

"Was it sine, left parenthesis, \phi, right parenthesis or sine, left parenthesis, theta, right parenthesis... and is it r or r, squared...?"

Instead, I think through the process I just illustrated above, asking what the arc lengths resulting from changes to \phi and theta 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, \phi and theta accurately describes all the points inside a sphere of radius R (without running over the entire sphere multiple times)

Using these bounds, together with the fact that

we can start setting up our integral like this:

**Concept check**: Work through this integral, and appreciate just how lovely it is compared with the other nasty triple integrals you may have encountered.

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

in the region of the

**first octant**where### 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 x, squared, plus, y, squared, plus, z, squared, is less than or equal to, 3 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

**Concept check**: What about theta and \phi? 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

into spherical coordinates. To do this, we use the conversions for each individual cartesian coordinate.

Plugging each of these in, we get

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

**Bring it on home**: Solve that integral!

## Summary

- When you are performing a triple integral, if you choose to describe the function and the bounds of your region using spherical coordinates, left parenthesis, r, comma, \phi, comma, theta, right parenthesis, the tiny volume d, V should be expanded as follows:The key term to remember (or re-derive) is start color #bc2612, r, squared, sine, left parenthesis, \phi, right parenthesis, end color #bc2612
- 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?

- For the last triple integral, my answer is 27pi/8 and not 81pi/16.(8 votes)
- Your answer is correct. When substituting in ϕ=π/2, the solution in the article forgot the factor of 1/2 in the ϕ/2 term.(11 votes)

- In my book the key term to remember is rather R^2*COS(ϕ§). Why is it different here?(5 votes)
- 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.(5 votes)

- how do you get x=rsin(phi)cos(theta) y=rsin(phi)sin(theta) and z=rcos(phi)(3 votes)
- 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)

- 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)- 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.(3 votes)

- 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)
- 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)
- 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(ϕ)).(4 votes)

- 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)
- 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)
- 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)

- 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)
- 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)