Chapter 27. Spherical coordinates

In addition to cylindrical coordinates, there’s one more system we’ll use, called spherical coordinates. This chapter defines them and shows how to use them.

Warning: There are eight competing standards, check your book

Note that there are competing conventions! For us, the letter names are going to mean

𝜌≔distance to(0,0,0)(spelled rho, pronounced like row)𝜑≔angle down𝑧 axis(spelled phi, pronounced like fee)𝜃≔same as in polar coordinates(spelled theta, pronounced like thay-tah)

and we write them in that order. However, depending on your book:

  • The names of 𝜃 and 𝜑 might be swapped. (Also note that the Greek letter 𝜑 may be written as 𝜙 in different fonts. If you use LaTeX, these are \varphi and \phi.)
  • The order of 𝜃 and 𝜑 might be swapped (regardless of whether the names change too).
  • 𝜌 might be replaced by 𝑟 instead.

§27.1 [TEXT] The definition of spherical coordinates

The idea behind spherical coordinates is that the projection of your point 𝑃 onto the 𝑥𝑦-plane will have polar coordinates (𝑟cos𝜃,𝑟sin𝜃,0) for some 𝑟. But then rather than using 𝑧 to lift the point straight up, you rotate via some angle 𝜑, getting a new distance 𝜌 such that 𝑟=𝜌sin𝜑 which we’ll use to replace 𝑟 everywhere in what follows. See Figure 60 below.

Figure 60: The diagram for spherical coordinates.

Because of the right triangle with angle 𝜑, hypotenuse 𝜌, and legs 𝑟 and 𝑧, we have

𝑟=𝜌sin𝜑𝑧=𝜌cos𝜑.

Unwinding everything to kill all the 𝑟’s, the transition map (𝜌,𝜑,𝜃)↦(𝑥,𝑦,𝑧) is given by

𝑥=𝜌sin𝜑⏟=𝑟cos𝜃𝑦=𝜌sin𝜑⏟=𝑟sin𝜃𝑧=𝜌cos𝜑.

Just like how I wrote (𝑟,𝜃)pol for polar if I needed to be more concise, we’ll have the analogous shorthand here:

Definition of spherical coordinates

We define spherical coordinates by

(𝜌,𝜑,𝜃)sph≔(𝜌sin𝜑cos𝜃,𝜌sin𝜑sin𝜃,𝜌cos𝜑).

Now, in order to integrate over this, there’s supposed to be a change of variables with some Jacobian. To get the area scaling factor, we would compute the Jacobian

det𝐽spherical=|𝜕𝑥𝜕𝜌𝜕𝑥𝜕𝜑𝜕𝑥𝜕𝜃𝜕𝑦𝜕𝜌𝜕𝑦𝜕𝜑𝜕𝑦𝜕𝜃𝜕𝑧𝜕𝜌𝜕𝑧𝜕𝜑𝜕𝑧𝜕𝜃|.

This takes some effort, so you probably should only do this once in your life and then remember the result. It works out to

det𝐽spherical=|sin𝜑cos𝜃𝜌cos𝜑cos𝜃−𝜌sin𝜑sin𝜃sin𝜑sin𝜃𝜌cos𝜑sin𝜃𝜌sin𝜑cos𝜃cos𝜑−𝜌sin𝜑0|=cos𝜑|𝜌cos𝜑cos𝜃−𝜌sin𝜑sin𝜃𝜌cos𝜑sin𝜃𝜌sin𝜑cos𝜃|+𝜌sin𝜑|sin𝜑cos𝜃−𝜌sin𝜑sin𝜃sin𝜑sin𝜃𝜌sin𝜑cos𝜃|=cos𝜑(𝜌2cos𝜑sin𝜑)(cos2𝜃+sin2𝜃)+𝜌2sin𝜑(sin2𝜑)(cos2𝜃+sin2𝜃)=𝜌2sin𝜑(cos2𝜑+sin2𝜑)=𝜌2sin𝜑.

I tried to do this calculation during recitation and got stuck at the board; not the kind of thing I’m good at. You really don’t want to redo this calculation on an exam, so just remember the result.

Memorize: Scaling factor for spherical coordinates
d𝑉≔d𝑥d𝑦d𝑧=𝜌2sin𝜑d𝜌d𝜑d𝜃.

§27.2 [TEXT] The bounds of 𝜑

Before talking about bounds for spherical coordinates, let me revisit polar coordinates for comparison.

§27.2.1 The bounds for polar coordinates

In polar (or cylindrical) coordinates, when we considered

(𝑟,𝜃)pol=(𝑟cos𝜃,𝑟sin𝜃),

we usually choose the convention

𝑟≥0and0≤𝜃<2𝜋.

(13)

The thing I want to stress that some thought was put into choosing the interval for 𝜃: the reason we use an interval of length 2𝜋 is because if you choose a value of 𝜃 bigger than 2𝜋, then the point just “wraps around” to one you already knew; e.g.

(𝑟,2.7𝜋)pol=(𝑟,0.7𝜋)pol

denote the same point. More generally,

(𝑟,𝜃+2𝜋)pol=(𝑟,𝜃)pol.

That’s why we adopt the convention Equation 13. When we define a coordinate system (𝑟,𝜃)pol, we want to make sure that every (𝑥,𝑦) point is given by exactly one pair. That is, every point should have a coordinate, but different coordinates should occupy different points.

Hence, to avoid repeating the same point with the same coordinates, the usual convention is to choose 0≤𝜃<2𝜋, although the convention −𝜋<𝜃≤𝜋 works fine too, as does any interval of length 2𝜋.

Digression on 𝑟=0
The claim that Equation 13 lines up perfectly is a white lie: the origin (0,0) in 𝑥𝑦-coordinates can be represented by (0,𝜃)pol for every value of 𝜃. So Equation 13 is almost right, except for the one special case 𝑟=0 where 𝜃 is indeterminate. We will sweep this under the rug and not think about it.

§27.2.2 The bounds for spherical coordinates

Let’s go back to spherical coordinates

(𝜌,𝜑,𝜃)sph≔(𝜌sin𝜑cos𝜃,𝜌sin𝜑sin𝜃,𝜌cos𝜑).

We want to choose a convention for values of (𝜌,𝜑,𝜃) such that (except for a few degenerate cases that we’ll ignore) every point has exactly one set of coordinates. The choice that we’re going to use is:

Memorize: The convention for spherical coordinate values

When we want to impose a range of values for spherical coordinates to avoid repeating points, we will choose the following convention:

𝜌≥00≤𝜑≤𝜋0≤𝜃<2𝜋

(14)

That is, I claim that this choice of values Equation 14 will ensure every point is represented exactly once by (𝜌,𝜑,𝜃)sph, with a small number of exceptions23 we ignore.

The 𝜃 going from 0 to 2𝜋 is the same as in polar coordinates. However, the angle for 𝜑 might be a surprise to you; a common question asked on various forms is:

Question
Why does 𝜑 only range from 0 to 𝜋? What happens if −𝜋<𝜑<0 or 𝜋<𝜑<2𝜋?

Well, if my claim about Equation 14 is true, that means if I plug in an “illegal” value of 𝜑, into the formula then I should get a point that’s already represented. This is a bit like how (𝑟,𝜃+2𝜋)pol=(𝑟,𝜃)pol, but the formula is a bit more complicated. So we’ll illustrate two cases in full to show how to convert the illegal value into a legal one.

§27.2.3 First case: Illegal angle greater than 𝜋

In this case, I assert the following equation is true:

(𝜌,𝜑+𝜋,𝜃)sph=(𝜌,𝜋−𝜑,𝜃±𝜋)sph.

(15)

Here the sign for 𝜃±𝜋 is arbitrary, and it’s chosen so that 0≤𝜃±𝜋<2𝜋 is a legal value.

Figure 61: Illustrating Equation 15 in picture format.

Here are two ways to verify Equation 15 is true.

Algebraic proof (easier)

We need to verify that the 𝑥, 𝑦, 𝑧 coordinates on both sides are the same:

𝜌sin(𝜑+𝜋)cos𝜃=𝜌sin(𝜋−𝜑)cos(𝜃±𝜋)𝜌sin(𝜑+𝜋)sin𝜃=𝜌sin(𝜋−𝜑)sin(𝜃±𝜋)𝜌cos(𝜑+𝜋)=𝜌cos(𝜋−𝜑).

But sin(𝜑+𝜋)=−sin(𝜋−𝜑), cos(𝜃±𝜋)=−cos𝜃, sin(𝜃±𝜋)=−sin(𝜃), and cos(𝜑+𝜋)=cos(𝜋−𝜑), so all the equations are true.

Geometric proof (more informative)

Look at Figure 61. When the “illegal” value 𝜑+𝜋 is picked for the angle, the red arrow ends up going all the way through 𝑂. Hence, the projection of the new point onto the polar circle in blue ends up being the antipode (𝑟,𝜃±𝜋)pol rather than (𝑟,𝜃)pol. If we then think about the angle from the +𝑧 axis to the brown radius 𝜌, it has changed to the angle 𝜋−𝜑 instead. This picture gives a geometric way of seeing why Equation 15 is true.

§27.2.4 Second case: Illegal angle less than zero

This time, I assert the following equation instead:

(𝜌,−𝜑,𝜃)sph=(𝜌,𝜑,𝜃±𝜋)sph.

(16)

This is actually a bit easier to see than the last case.

Figure 62: Illustrating Equation 16 in picture format.
Algebraic proof (easier)

We need to verify that the 𝑥, 𝑦, 𝑧 coordinates on both sides are the same:

𝜌sin(−𝜑)cos𝜃=𝜌sin𝜑cos(𝜃±𝜋)𝜌sin(−𝜑)sin𝜃=𝜌sin𝜑sin(𝜃±𝜋)𝜌cos(−𝜑)=𝜌cos𝜑.

But sin(−𝜑)=−sin(𝜑), cos(𝜃±𝜋)=−cos𝜃, sin(𝜃±𝜋)=−sin(𝜃), and cos(−𝜑)=cos𝜑, so all the equations are true.

Geometric proof (more informative)

Look at Figure 62. This time, all that happens is we take the mirror image through the plane formed by the 𝑧-axis and the line 𝑂𝑃.

§27.3 [TEXT] Examples of using spherical coordinates

Here are two cookie-cutter uses where we have a sphere centered at the origin and we just integrate over the entire sphere (so taking 0≤𝜌≤𝑅, 0≤𝜑≤𝜋 and 0≤𝜃≤2𝜋).

Sample Question
Consider a solid ball of radius 𝑅. Compute its volume.

Solution. Placing the ball 𝒯︀ with its center at the origin:

Vol(𝒯︀)=∭𝒯︀1d𝑉=∭𝒯︀𝜌2sin𝜑d𝜌d𝜑d𝜃=∫𝜌=0𝑅∫𝜑=0𝜋∫𝜃=02𝜋𝜌2sin𝜑d𝜃d𝜑d𝜌=(∫𝜌=0𝑅𝜌2d𝜌)(∫𝜑=0𝜋sin𝜑d𝜑)(∫𝜃=02𝜋d𝜃)=𝑅33⋅2⋅(2𝜋)=43𝜋𝑅3.

□

Sample Question
Consider a solid ball of radius 1. Across all points 𝑃 inside the ball, compute the average value of the distance from 𝑃 to the center.

Here, the “average” value of a function 𝑓 over a solid region 𝒯︀ is defined as 1Vol(𝒯︀)∭𝒯︀𝑓d𝑉.

Solution. The sphere has volume 43𝜋 as we just saw. The only change to what we did before is that rather than integrating 1d𝑉, we replace 1 with the distance:

∭𝒯︀(distance to(0,0,0))d𝑉=∭𝒯︀𝜌d𝑉=∭𝒯︀𝜌⋅(𝜌2sin𝜑d𝜌d𝜑d𝜃)=∫𝜌=01∫𝜑=0𝜋∫𝜃=02𝜋𝜌3sin𝜑d𝜃d𝜑d𝜌=(∫𝜌=01𝜌3d𝜌)(∫𝜑=0𝜋sin𝜑d𝜑)(∫𝜃=02𝜋d𝜃)=14⋅2⋅(2𝜋)=𝜋.

So the average value is

∭𝒯︀(distance to(0,0,0))d𝑉Vol(𝒯︀)=𝜋43𝜋=34.

□

§27.4 [TEXT] Famous example: offset sphere

Recall the famous example in Section 24.3 where we showed that in polar coordinates, we could draw a circle passing through the origin; we called it an “offset circle”. There’s a 3D analog of this with an offset sphere where you have a sphere that’s sitting on the 𝑥𝑦-plane. It’s actually pretty much exactly the same.

Sample Question
Let 𝒯︀ denote the solid ball of radius 1 centered at (0,0,1). Express the region 𝒯︀ in spherical coordinates.

Figure 63: The sketch of (𝑥−1)2+𝑦2≤1 from Figure 53 is drawn along with a 3D version: the solid ball 𝑥2+𝑦2+(𝑧−1)2≤1, which is a unit ball centered at (0,0,1) and lying above and tangent to the 𝑥𝑦-plane at (0,0,0). It corresponds to 𝜌≤2cos𝜑.

Solution. Like in Section 24.3, we can do either an algebra approach or a geometric one.

Geometric approach

See Figure 63. All the points of the sphere lie in the half-space 𝑧≥0 which is described as requiring 0≤𝜑≤𝜋2. The value of 𝜃 is irrelevant by rotational symmetry, and can be anything from 0 to 2𝜋. So we need to figure out how 𝜌 relates to 𝜑.

Let 𝑂=(0,0,0) and 𝐴=(0,0,2). Let 𝑃 be a point on the surface of the sphere. Like before, we have

∠𝑃=90°,𝑂𝐴=2,and∠𝐴𝑂𝑃=𝜑.

So the surface of the sphere is those points for which 𝜌=2cos𝜑. And the points inside the ball are 0≤𝜌≤2cos𝜑, accordingly.

Algebraic approach

The 𝑥𝑦𝑧 coordinates of the ball are

𝑥2+𝑦2+(𝑧−1)2≤1.

Recall the spherical coordinates transformation:

𝑥=𝜌sin𝜑cos𝜃,𝑦=𝜌sin𝜑sin𝜃,𝑧=𝜌cos𝜑.

Substituting these into the sphere’s equation:

(𝜌sin𝜑cos𝜃)2+(𝜌sin𝜑sin𝜃)2+(𝜌cos𝜑−1)2≤1.

Expand and simplify:

1≥𝜌2sin2𝜑cos2𝜃+𝜌2sin2𝜑sin2𝜃+(𝜌cos𝜑−1)2=𝜌2sin2𝜑(cos2𝜃+sin2𝜃)+(𝜌cos𝜑−1)2=𝜌2sin2𝜑+(𝜌cos𝜑−1)2=𝜌2sin2𝜑+𝜌2cos2𝜑−2𝜌cos𝜑+1=𝜌2(sin2𝜑+cos2𝜑)−2𝜌cos𝜑+1=𝜌2−2𝜌cos𝜑+1.

Rearranging, this gives

0≥𝜌2−2𝜌cos𝜑=𝜌(𝜌−2cos𝜑)⟺0≤𝜌≤2cos𝜑.

In particular this requires cos𝜑≥0 i.e. 𝜑≤𝜋2.

In conclusion, the answer is that 𝒯︀ in spherical coordinates is exactly

0≤𝜃<2𝜋 and 0≤𝜑≤𝜋2 and 𝜌≤2cos𝜑.

□

The analogous famous exercise in 3D:

Sample Question

Let 𝒯︀ denote the solid ball of radius 1 centered at (0,0,1). Calculate

∭𝒯︀𝑥2+𝑦2+𝑧2d𝑥d𝑦d𝑧.

Solution. As before, if we try to use 𝑥𝑦𝑧 integration it’s a disaster, but spherical coordinates are great because

𝜌=𝑥2+𝑦2+𝑧2.

We just saw that 𝒯︀ is given in spherical coordinates according to 0≤𝜑≤𝜋2, 0≤𝜃<2𝜋, 0≤𝜌≤2cos𝜑. Thus, the integral becomes:

∭𝒯︀𝜌d𝑉=∭𝒯︀𝜌3sin𝜑d𝜌d𝜑d𝜃=∫𝜃=02𝜋∫𝜑=0𝜋2∫𝜌=02cos𝜑𝜌3sin𝜑d𝜌d𝜑d𝜃=∫𝜃=02𝜋∫𝜑=0𝜋2sin𝜑[𝜌44]𝜌=02cos𝜑d𝜑d𝜃=∫𝜃=02𝜋∫𝜑=0𝜋2sin𝜑⋅(4cos4𝜑)d𝜑d𝜃=4∫𝜃=02𝜋[−15cos5𝜑]𝜑=0𝜋2d𝜃=4∫𝜃=02𝜋15d𝜃=8𝜋5.

□

§27.5 [TEXT] Spherical coordinates for gravity

Let’s go back to the equation for gravity where the components were given by

𝐺1≔𝐺𝑚∭𝒯︀𝑥𝛿(𝑥,𝑦,𝑧)(𝑥2+𝑦2+𝑧2)32d𝑥d𝑦d𝑧𝐺2≔𝐺𝑚∭𝒯︀𝑦𝛿(𝑥,𝑦,𝑧)(𝑥2+𝑦2+𝑧2)32d𝑥d𝑦d𝑧𝐺3≔𝐺𝑚∭𝒯︀𝑧𝛿(𝑥,𝑦,𝑧)(𝑥2+𝑦2+𝑧2)32d𝑥d𝑦d𝑧.

I didn’t do any examples last section because using 𝑥𝑦𝑧 coordinates when you have (𝑥2+𝑦2+𝑧2)32 is just way too annoying. However, in spherical coordinates, the equations become much more manageable. For example, the one for 𝐺3 reads:

𝐺3=𝐺𝑚∭𝒯︀𝑧𝛿(𝑥,𝑦,𝑧)(𝑥2+𝑦2+𝑧2)32d𝑥d𝑦d𝑧=𝐺𝑚∭𝒯︀(𝜌cos𝜑)𝛿(𝑥,𝑦,𝑧)𝜌3(𝜌2sin𝜑d𝜌d𝜑d𝜃)=𝐺𝑚∭𝒯︀𝛿(𝑥,𝑦,𝑧)sin𝜑cos𝜑d𝜌d𝜑d𝜃.

(17)

Let’s see it in action with an offset sphere.

Sample Question
Suppose 𝒯︀ is a metal ball of radius 1 of constant unit density, and 𝑃 is a point of mass 𝑚 on its surface. Calculate the magnitude of the force of gravity exerted on the point 𝑃.

Solution. We use the offset sphere again: we pick coordinates so that 𝑃=(0,0,0) (so the origin is the point 𝑃, not the center of 𝒯︀). The center of 𝒯︀ will instead be at (0,0,1). Then by symmetry, we have 𝐺1=𝐺2=0, and Equation 17 just says

𝐺3=𝐺𝑚∭𝒯︀sin𝜑cos𝜑d𝜌d𝜑d𝜃

after setting the density to 1.

Then we can put in the bounds of integration for the offset sphere:

𝐺3=𝐺𝑚∫𝜃=02𝜋∫𝜑=0𝜋2∫𝜌=02cos𝜑sin𝜑cos𝜑d𝜌d𝜑d𝜃=𝐺𝑚∫𝜃=02𝜋∫𝜑=0𝜋2(2cos𝜑)⋅sin𝜑cos𝜑d𝜑d𝜃=2𝐺𝑚∫𝜃=02𝜋∫𝜑=0𝜋2cos2𝜑sin𝜑d𝜑d𝜃=2𝐺𝑚∫𝜃=02𝜋[−13cos3𝜑]𝜑=0𝜋2d𝜃=2𝐺𝑚∫𝜃=02𝜋13d𝜃=4𝜋𝐺𝑚3.

In other words, in the coordinate system we chose, gravity is given by

𝐆=⟨0,0,4𝜋𝐺𝑚3⟩.

The magnitude is |𝐆|=4𝜋𝐺𝑚3.□

§27.6 [EXER] Exercises

Exercise 27.1. Consider a solid ball of radius 1 and a line ℓ through its center. Across all points 𝑃 inside the ball, compute the average value of the distance from 𝑃 to ℓ. (The average is defined as 1Vol(𝒯︀)∭𝒯︀𝑑(𝑃)d𝑉, where 𝑑(𝑃) is the distance from 𝑃 to ℓ.)
Exercise 27.2. Suppose 𝒯︀ is a solid metal hemisphere of radius 1 of constant unit density, and 𝑃 is a point of mass 𝑚 at the center of the base of the hemisphere. Calculate the magnitude of the force of gravity exerted on the point 𝑃.
  1. 23 If you want to know, the exceptions are exactly the 𝑧-axis, where 𝜃 can be arbitrary. Every other point should only appear once.