Jacobians and spherical polar gradient
Posted by peeterjoot on December 8, 2009
The dumbest and most obvious way to do a chain of variables for the gradient is to utilize a chain rule expansion producing the Jacobian matrix to transform the coordinates. Here we do this to calculate the spherical polar representation of the gradient.
There are smarter and easier ways to do this, but there is some surprising simple structure to the resulting Jacobians that seems worth noting.
Spherical polar gradient coordinates in terms of Cartesian.
We wish to do a change of variables for each of the differential operators of the gradient. This is essentially just application of the chain rule, as in
Collecting all such derivatives we have in column vector form
This becomes a bit more tractable with the Jacobian notation
The change of variables for the operator triplet is then just
This Jacobian matrix is also not even too hard to calculate. With , we have , and
The last two derivatives can be calculated easily if the radial unit vector is written out explicitly, with and for sine and cosine respectively, these are
We can plug these into the elements of the Jacobian matrix explicitly, which produces
however, we are probably better off just referring back to 8, and writing
Unfortunately, this is actually a bit of a dead end. We really want the inverse of this matrix because the desired quantity is
(Here my matrix of unit vectors treats these abusively as single elements and not as column vectors).
The matrix of equation 12 does not look particularly fun to invert directly, and that is what we need to substitute into
13. One knows that in the end if it was attempted things should mystically simplify (presuming this was done error free).
Cartesian gradient coordinates in terms of spherical polar partials.
Let’s flip things upside down and calculate the inverse Jacobian matrix directly. This is a messier job, but it appears less messy than the matrix inversion above.
The messy task is now the calculation of these derivatives.
For the first, from , taking partials on both sides, we have
But these are just the direction cosines, the components of our polar unit vector . We can then write for all of these derivatives in column matrix form
Next from , we get after some reduction
Observe that we can antidifferentiate with respect to theta and obtain
This last column vector is our friend the unit polar vector again, and we have
Finally for the dependence we have after some reduction
Again, we can antidifferentiate
We have our unit polar vector again, and our partials nicely summarized by
With this we can now write out the Jacobian matrix either explicitly, or in column vector form in terms of . First a reminder of why we want this matrix, for the following change of variables
We want the Jacobian matrix
Explicitly this is
As a verification of correctness multiplication of this with 11 should produce identity. That’s a mess of trig that I don’t really feel like trying, but we can get a rough idea why it should all be the identity matrix by multiplying it out in block matrix form
The derivatives are vectors that lie tangential to the unit sphere. We can calculate this to verify, or we can look at the off diagonal terms which say just this if we trust the math that says these should all be zeros. For each of the off diagonal terms to be zero must mean that we have
This makes intuitive sense. We can also verify quickly enough that , and (I did this with a back of the envelope calculation using geometric algebra). That is consistent with what this matrix product implies it should equal.
Completing the gradient change of variables to spherical polar coordinates.
We are now set to calculate the gradient in spherical polar coordinates from our Cartesian representation. From 13 and
25, and 26 we have
The Jacobian matrix has been written out explicitly as scalars because we are now switching to an abusive notation using matrices of vector elements. Our Jacobian, a matrix of scalars happened to have a nice compact representation in column vector form, but we cannot use this when multiplying out with our matrix elements (or perhaps could if we invented more conventions, but lets avoid that). Having written it out in full we see that we recover our original compact Jacobian representation, and have just
Expanding this last product we have the gradient in its spherical polar representation
With the labels
(having confirmed that these are unit vectors), we have the final result for the gradient in this representation
Here the matrix delimiters for the remaining one by one matrix term were also dropped.
General expression for gradient in orthonormal frames.
Having done the computation for the spherical polar case, we get the result for any orthonormal frame for free. That is just
From each of the gradients we can factor out a unit vector in the direction of the gradient, and have an expression that structurally has the same form as 34. Writing , this is
These individual direction gradients are not necessarily easy to compute. The procedures outlined in  are a more effective way of dealing with this general computational task. However, if we want, we can at proceed this dumb obvious way and be able to get the desired result knowing only how to apply the chain rule, and the Cartesian definition of the gradient.
 F.W. Byron and R.W. Fuller. Mathematics of Classical and Quantum Physics. Dover Publications, 1992.