How do I properly represent a displacement vector inside of an integral in curvilinear coordinates?

You are asked to evaluate the following integral involving a displacement vector: \int \vec{r}\ d\tau over a spherical volume centered at the origin with sphere radius a.

Note that we use Griffiths notation for the differential volume element d\tau and not the Jackson notation d^3 x.

In order to make the integration limits simple to write down, we make a choice to carry out this integral using spherical coordinate variables, which in Griffiths notation is:

  • r = distance from the origin
  • \theta = polar angle
  • \phi = azimuthal angle

Having now made this choice of spherical coordinates, the integral can be written explicitly as:

\int_0^a \int_0^{2\pi} \int_0^\pi \vec{r}\ r^2 \sin(\theta) \ d\theta \ d\phi \ dr

One choice for representing the integrand is \vec{r} = r \hat{r} where \hat{r} is the unit vector that, by definition, points radially away from the origin. If we plug this into our integral, it is tempting to claim that the integral is evaluated in the following way:

\int_0^a \int_0^{2\pi} \int_0^\pi r \hat{r} \ r^2 \sin(\theta) \ d\theta \ d\phi \ dr = \hat{r} \int_0^a \int_0^{2\pi} \int_0^\pi r^3 \sin(\theta) \ d\theta \ d\phi \ dr

= \hat{r} \left [ \int_0^a r^3\ dr \right ] \left [ \int_0^{2\pi} d\phi \right ] \left [ \int_0^\pi \sin(\theta) \ d\theta \right ] = \hat{r} (a^4/4) (2\pi) (2) = \pi a^4 \hat{r}

Even though the units are correct (distance times volume or distance to the fourth power), It turns out that this result is incorrect! Stop and think about how you can tell that this is the wrong answer.

One way to see that this is incorrect is to think about what the integral represents conceptually. It is the vector sum of all displacement vectors \vec{r} contained within a sphere. Let’s pick one of the displacement vectors within our spherical integration volume with length b < a that points along the positive x-axis. Our integration volume also contains a displacement vector with length b but points along the negative x-axis. The vector sum of this pair is zero. Indeed, all displacement vectors within our spherical integration volume come in pairs that exactly cancel. Convince yourself of this argument. As a consequence, our integral must evaluate to zero.

Where did we make a mistake? It turns out that we took the \hat{r} outside of the integral as if it were a constant. It is true that the length of \hat{r} is 1 by definition and the length of \hat{r} is indeed a constant. However, the direction that \hat{r} points depends on where one is located. For example, if you were standing on the positive x-axis, then, in order to point directly away from the origin, \hat{r} = +\hat{x}. Suppose instead that you were standing on the negative y-axis, then, in order to point directly away from the origin, \hat{r} = -\hat{y}. Think about these last two statements and convince yourself that you agree with them. The rest of this post relies on you agreeing that these statements are true.

We could have avoided this problem if we had written \hat{r} as \hat{r}(\theta,\phi) which would have reminded us that \hat{r} has a dependence on location. This is notationally cumbersome so we don’t write \hat{r} in this way and therefore we just need to remember that \hat{r} is not a constant (even though its length is always 1)!

So how do we proceed? The key to moving forward is to recall that, by definition, the Cartesian unit vectors (\hat{x}, \hat{y}, \hat{z}) are truly constants. They all have a length of 1 and, crucially, they all point away from the origin along the positive direction of the corresponding Cartesian axis (x,y,z). Since Cartesian unit vectors are truly constants, they can be safely moved into or out of integrals and derivatives with complete impunity.

The last piece of the puzzle is the now choosing the representation of \vec{r} in the appropriate way to evaluate the integral. The length of \vec{r} is one of the integration variables, so we represent that in spherical coordinates r instead of Cartesian coordinates \sqrt{x^2 + y^2 +z^2}.

On the other hand, the direction of \hat{r} depends on location (\theta,\phi) which are the other two integration variables. We need to write \hat{r} in such a way that its (\theta,\phi) dependence is explicit. We can do this by representing \hat{r} in terms of its Cartesian unit vector components:

\hat{r} = \sin(\theta) \cos(\phi) \hat{x} + \sin(\theta) \sin(\phi) \hat{y} + \cos(\theta) \hat{z}

Stare at this representation of \hat{r} and convince yourself that its length is always 1 regardless of the values of (\theta,\phi).

Putting this altogether, we find that the appropriate representation of the integrand is the following:

\vec{r} = r\hat{r} = r \sin(\theta) \cos(\phi) \hat{x} + r \sin(\theta) \sin(\phi) \hat{y} + r \cos(\theta) \hat{z}

You might find that this feels awkward and somewhat uncomfortable because we are “mixing” coordinate representations:

  1. spherical coordinates to represent the length of the displacement vector
  2. Cartesian unit vectors to separate the displacement vector into its individual components

We have done nothing wrong and the math police is not coming to arrest you to throw you in math jail because of this mixing and matching of coordinate representations. When you start to feel comfortable with what we have just done, then let’s finish evaluating the integral.

\int_0^a \int_0^{2\pi} \int_0^\pi r \hat{r} \ r^2 \sin(\theta) \ d\theta \ d\phi \ dr
= \int_0^a \int_0^{2\pi} \int_0^\pi \left [ \sin(\theta) \cos(\phi) \hat{x} + \sin(\theta) \sin(\phi) \hat{y} + \cos(\theta) \hat{z}\right ] r^3 \sin(\theta) \ d\theta \ d\phi \ dr

This is the sum of three separate integrals which correspond to each of the three Cartesian unit vectors:

\int_0^a \int_0^{2\pi} \int_0^\pi \sin(\theta) \cos(\phi) \hat{x} r^3 \sin(\theta) \ d\theta \ d\phi \ dr = \hat{x} \int_0^a \int_0^{2\pi} \int_0^\pi \sin^2(\theta) \cos(\phi) r^3 \ d\theta \ d\phi \ dr

\int_0^a \int_0^{2\pi} \int_0^\pi \sin(\theta) \sin(\phi) \hat{y} r^3 \sin(\theta) \ d\theta \ d\phi \ dr = \hat{y} \int_0^a \int_0^{2\pi} \int_0^\pi \sin^2(\theta) \sin(\phi) r^3 \ d\theta \ d\phi \ dr

\int_0^a \int_0^{2\pi} \int_0^\pi \cos(\theta) \hat{z} r^3 \sin(\theta) \ d\theta \ d\phi \ dr = \hat{z} \int_0^a \int_0^{2\pi} \int_0^\pi \cos(\theta) \sin(\theta) r^3 \ d\theta \ d\phi \ dr

Note that, in all of the above, it was safe to move the Cartesian units vectors outside of the integrals because both their magnitudes (always 1) and directions (by definition) are constants regardless of location.

All that remains is to evaluate the integrals corresponding to each Cartesian component. It turns out that the integrals for all three components are individually zero. This can be seen most quickly by noting the following integrals:

\int_0^{2\pi} \cos(\phi)\ d\phi = 0
\int_0^{2\pi} \sin(\phi)\ d\phi = 0
\int_0^{\pi} \cos(\theta)\sin(\theta)\ d\theta = 0