:

## Vectors in Spherical Coordinates using Tensor Notation

Maple

Vectors in Spherical Coordinates using Tensor Notation

Edgardo S. Cheb-Terrab1 and Pascal Szriftgiser2

(2) Laboratoire PhLAM, UMR CNRS 8523, Université de Lille, F-59655, France

(1) Maplesoft

The following is a topic that appears frequently in formulations: given a 3D vector in spherical (or any curvilinear) coordinates, how do you represent and relate, in simple terms, the vector and the corresponding vectorial operations Gradient, Divergence, Curl and Laplacian using tensor notation?

The core of the answer is in the relation between the - say physical - vector components and the more abstract tensor covariant and contravariant components. Focusing the case of a transformation from Cartesian to spherical coordinates, the presentation below starts establishing that relationship between 3D vector and tensor components in Sec.I. In Sec.II, we verify the transformation formulas for covariant and contravariant components on the computer using TransformCoordinates. In Sec.III, those tensor transformation formulas are used to derive the vectorial form of the Gradient in spherical coordinates. In Sec.IV, we switch to using full tensor notation, a curvilinear metric and covariant derivatives to derive the 3D vector analysis traditional formulas in spherical coordinates for the Divergence, Curl, Gradient and Laplacian. On the way, some useful technics, like changing variables in 3D vectorial expressions, differential operators, using Jacobians, and shortcut notations are shown.

The computation below is reproducible in Maple 2020 using the Maplesoft Physics Updates v.640 or newer.

Start setting the spacetime to be 3-dimensional, Euclidean, and use Cartesian coordinates

 >
 >
 (1)

I. The line element in spherical coordinates and the scale-factors

In vector calculus, at the root of everything there is the line element , which in Cartesian coordinates has the simple form

 >
 (1.1)

To compute the line element   in spherical coordinates, the starting point is the transformation

 >
 (1.2)
 >
 (1.3)

Since in  are just symbols with no relationship to start transforming these differentials using the chain rule, computing the Jacobian of the transformation (1.2). In this Jacobian J, the first line is , ,

 >

So in matrix notation,

 >
 (1.4)

To complete the computation of   in spherical coordinates we can now use ChangeBasis , provided that next we substitute (1.4) in the result, expressing the abstract objects  in terms of .

In two steps:

 >
 (1.5)

The line element

 >
 (1.6)

This result is important: it gives us the so-called scale factors, the key that connect 3D vectors with the related covariant and contravariant tensors in curvilinear coordinates. The scale factors are computed from (1.6) by taking the scalar product with each of the unit vectors , then taking the coefficients of the differentials  (just substitute them by the number 1)

 >
 (1.7)

The scale factors are relevant because the components of the 3D vector and the corresponding tensor are not the same in curvilinear coordinates. For instance, representing the differential of the coordinates as the tensor , we see that corresponding vector, the line element in spherical coordinates , is not  constructed by directly equating its components to the components of , so

The vector  is constructed multiplying these contravariant components  by the scaling factors, as

This rule applies in general. The vectorial components of a 3D vector in an orthogonal system (curvilinear or not) are always expressed in terms of the contravariant components  the same way we did in the line above with the line element, using the scale-factors , so that

where on the right-hand side we see the contravariant components  and the scale-factors . Because the system is orthogonal, each vector component satisfies

The scale-factors  do not constitute a tensor, so on the right-hand side we do not sum over j.  Also, from

it follows that,

where on the right-hand side we now have the covariant tensor components .

 • This relationship between the components of a 3D vector and the contravariant and covariant components of a tensor representing the vector is key to translate vector-component to corresponding tensor-component formulas.

II. Transformation of contravariant and covariant tensors

Define here two representations for one and the same tensor:  will represent A in Cartesian coordinates, while  will represent A in spherical coordinates.

 >
 (2.1)

Transformation rule for a contravariant tensor

We know, by definition, that the transformation rule for the components of a contravariant tensor is , that is the same as the rule for the differential of the coordinates. Then, the transformation rule from  to computed using TransformCoordinates should give the same relation (1.4). The application of the command, however, requires attention, because, as in (1.4), we want the Cartesian (not the spherical) components isolated. That is like performing a reversed transformation. So we will use

where on the left-hand side we get, isolated, the three components of A in Cartesian coordinates, and on the right-hand side we transform the spherical components , from spherical  (4th argument) to Cartesian  (3rd argument), which according to the 5th bullet of TransformCoordinates  will result in a transformation expressed in terms of the old coordinates (here the spherical ). Expand things to make the comparison with (1.4) possible by eye

 >
 (2.2)

We see that the transformation rule for a contravariant vector is, indeed, as the transformation (1.4) for the differential of the coordinates.

Transformation rule for a covariant tensor

For the transformation rule for the components of a covariant tensor , we know, by definition, that it is , so the same transformation rule for the gradient , where  and so on. We can experiment this by directly changing variables in the differential operators , for example

 >
 (2.3)

This result, and the equivalent ones replacing x by y or z in the input above can be computed in one go, in matricial and simplified form, using the Jacobian of the transformation computed in . We need to take the transpose of the inverse of J (because now we are transforming the components of the gradient   )

 >
 >
 (2.4)

The corresponding transformation equations relating the tensors  and  in Cartesian and spherical coordinates is computed with TransformCoordinates  as in (2.2), just lowering the indices on the left and right hand sides (i.e., remove the tilde ~)

 >
 (2.5)

We see that the transformation rule for a covariant vector  is, indeed, as the transformation rule (2.4) for the gradient.

To the side: once it is understood how to compute these transformation rules, we can have the inverse of (2.5) as follows

 >
 (2.6)

III. Deriving the transformation rule for the Gradient using TransformCoordinates

Turn ON the CompactDisplay  notation for derivatives, so that the differentiation variable is displayed as an index:

 >

The gradient of a function f in Cartesian coordinates and spherical coordinates is respectively given by

 >
 (3.1)
 >
 (3.2)

What we want now is to depart from (3.1) in Cartesian coordinates and obtain (3.2) in spherical coordinates using the transformation rule for a covariant tensor computed with TransformCoordinates in (2.5). (An equivalent derivation, simpler and with less steps is done in Sec. IV.)

Start changing the vector basis in the gradient (3.1)

 >
 (3.3)

By eye, we see that in this result the coefficients of  are the three lines in the right-hand side of (2.6) after replacing the covariant components  by the derivatives of f with respect to the jth coordinate, here displayed using indexed notation due to using CompactDisplay

 >
 (3.4)
 >
 (3.5)

So since (2.5) is the inverse of (2.6), replace A by ∂ f in (2.5), the formula computed using TransformCoordinates, then insert the result in (3.3) to relate the gradient in Cartesian and spherical coordinates. We expect to arrive at the formula for the gradient in spherical coordinates (3.2) .

 >
 (3.6)
 >
 (3.7)

Simplifying, we arrive at (3.2)

 >
 (3.8)
 >
 (3.9)

IV. Deriving the transformation rule for the Divergence, Curl, Gradient and Laplacian, using TransformCoordinates and Covariant derivatives

 • The Divergence

Introducing the vector A in spherical coordinates, its Divergence is given by

 >
 (4.1)
 >
 (4.2)
 >
 (4.3)

We want to see how this result, (4.3), can be obtained using TransformCoordinates and departing from a tensorial representation of the object, this time the covariant derivative . For that purpose, we first transform the coordinates and the metric introducing nonzero Christoffel symbols

 >
 (4.4)

To the side: despite having nonzero Christoffel symbols, the space still has no curvature, all the components of the Riemann tensor are equal to zero

 >
 (4.5)

Consider now the divergence of the contravariant tensor, computed in tensor notation

 >
 (4.6)
 >
 (4.7)

To the side: the covariant derivative  expressed using the D_  operator can be rewritten in terms of the non-covariant d_  and Christoffel  symbols as follows

 >
 (4.8)

Summing over the repeated indices in (4.7), we have

 >
 (4.9)

How is this related to the expression of the  in (4.3) ? The answer is in the relationship established at the end of Sec I between the components of the tensor and the components of the vector , namely that the vector components are obtained multiplying the contravariant tensor components by the scale-factors . So, in the above we need to substitute the contravariant  by the vector components  divided by the scale-factors

 >
 (4.10)
 >
 (4.11)

Comparing with (4.3), we see these two expressions are the same:

 >
 (4.12)
 • The Curl

The Curl of the the vector  in spherical coordinates is given by

 >
 (4.13)

One could think that the expression for the Curl in tensor notation is as in a non-curvilinear system

But in a curvilinear system  is not a tensor, we need to use the non-Galilean form , where  is the determinant of the metric. Moreover, since the expression has one free covariant index (the first one), to compare with the vectorial formula (4.12) this index also needs to be rewritten as a vector component as discussed at the end of Sec. I, using

The formula (4.13) for the vectorial Curl is thus expressed using tensor notation as

 >
 (4.14)
 >
 (4.15)

followed by replacing the contravariant tensor components  by the vector components  using (4.10). Proceeding the same way we did with the Divergence, expand this expression. We could use TensorArray , but Library:-TensorComponents places a comma between components making things more readable in this case

 >
 (4.16)

Replace now the components of the tensor  by the components of the 3D vector  using (4.10)

 >
 (4.17)
 >
 (4.18)

We see these are exactly the components of the Curl (4.13)

 >
 (4.19)

Once the problem is fully understood, it is easy to redo the computations of Sec.III for the Gradient, this time using tensor notation and the covariant derivative. In tensor notation, the components of the Gradient are given by the components of the right-hand side

 >
 (4.20)

where on the left-hand side we have the vectorial Nabla  differential operator and on the right-hand side, since  is a scalar, the covariant derivative  becomes the standard derivative .

 >
 (4.21)

The above is the expected result (3.2)

 >
 (4.22)
 • The Laplacian

Likewise we can compute the Laplacian directly as

 >
 (4.23)

In this case there are no free indices nor tensor components to be rewritten as vector components, so there is no need for scale-factors. Summing over the repeated indices,

 >
 (4.24)

Evaluating the  Vectors:-Laplacian on the left-hand side,

 >
 (4.25)

On the right-hand side we see the dAlembertian , in curvilinear coordinates; rewrite it using standard diff  derivatives and expand both sides of the equation for comparison

 >
 (4.26)

This is an identity, the left and right hand sides are equal:

 >
 (4.27)