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

with(Physics); with(Vectors)

Setup(dimension = 3, coordinates = cartesian, g_ = `+`, spacetimeindices = lowercaselatin)

`The dimension and signature of the tensor space are set to `[3, `+ + +`]

 

`Default differentiation variables for d_, D_ and dAlembertian are:`*{X = (x, y, z)}

 

`Systems of spacetime coordinates are:`*{X = (x, y, z)}

 

_______________________________________________________

 

`The Euclidean metric in coordinates `*[x, y, z]

 

_______________________________________________________

 

Physics:-g_[mu, nu] = Matrix(%id = 18446744078312229334)

 

(`Defined Pauli sigma matrices (Psigma): `*sigma[1]*`, `*sigma[2]*`, `)*sigma[3]

 

__________________________________________________

 

_______________________________________________________

(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 `#mover(mi("dr"),mo("→"))`, which in Cartesian coordinates has the simple form

dr_ = _i*dx+_j*dy+_k*dz

dr_ = _i*dx+_j*dy+_k*dz

(1.1)

To compute the line element  `#mover(mi("dr"),mo("→"))` in spherical coordinates, the starting point is the transformation

tr := `~`[`=`]([X], ChangeCoordinates([X], spherical))

[x = r*sin(theta)*cos(phi), y = r*sin(theta)*sin(phi), z = r*cos(theta)]

(1.2)

Coordinates(S = [r, theta, phi])

`Systems of spacetime coordinates are:`*{S = (r, theta, phi), X = (x, y, z)}

(1.3)

Since in (dr_ = _i*dx+_j*dy+_k*dz)*[dx, dy, dz] are just symbols with no relationship to "[x,y,z],"start transforming these differentials using the chain rule, computing the Jacobian of the transformation (1.2). In this Jacobian J, the first line is "[(∂x)/(∂r)dr", "(∂x)/(∂theta)"`dθ`, "(∂x)/(∂phi)dphi]"

J := VectorCalculus:-Jacobian(map(rhs, [x = r*sin(theta)*cos(phi), y = r*sin(theta)*sin(phi), z = r*cos(theta)]), [S])

 

So in matrix notation,

Vector([dx, dy, dz]) = J.Vector([dr, dtheta, dphi])

Vector[column](%id = 18446744078518652550) = Vector[column](%id = 18446744078518652790)

(1.4)

To complete the computation of  `#mover(mi("dr"),mo("→"))` in spherical coordinates we can now use ChangeBasis , provided that next we substitute (1.4) in the result, expressing the abstract objects [dx, dy, dz] in terms of [dr, `dθ`, `dφ`].

 

In two steps:

lhs(dr_ = _i*dx+_j*dy+_k*dz) = ChangeBasis(rhs(dr_ = _i*dx+_j*dy+_k*dz), spherical)

dr_ = (dx*sin(theta)*cos(phi)+dy*sin(theta)*sin(phi)+dz*cos(theta))*_r+(dx*cos(phi)*cos(theta)+dy*sin(phi)*cos(theta)-dz*sin(theta))*_theta+(cos(phi)*dy-sin(phi)*dx)*_phi

(1.5)

The line element

"simplify(subs(convert(lhs(?) =~ rhs(?),set),dr_ = (dx*sin(theta)*cos(phi)+dy*sin(theta)*sin(phi)+dz*cos(theta))*_r+(dx*cos(phi)*cos(theta)+dy*sin(phi)*cos(theta)-dz*sin(theta))*_theta+(cos(phi)*dy-sin(phi)*dx)*_phi))"

dr_ = _phi*dphi*r*sin(theta)+_theta*dtheta*r+_r*dr

(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 [`#mover(mi("r"),mo("∧"))`, `#mover(mi("θ",fontstyle = "normal"),mo("∧"))`, `#mover(mi("φ",fontstyle = "normal"),mo("∧"))`], then taking the coefficients of the differentials [dr, `dθ`, `dφ`] (just substitute them by the number 1)

h := subs(`~`[`=`]([dr, `dθ`, `dφ`], 1), [seq(rhs(dr_ = _phi*dphi*r*sin(theta)+_theta*dtheta*r+_r*dr).q, q = [`#mover(mi("r"),mo("∧"))`, `#mover(mi("θ",fontstyle = "normal"),mo("∧"))`, `#mover(mi("φ",fontstyle = "normal"),mo("∧"))`])])

[1, r, r*sin(theta)]

(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 dS^j = [dr, `dθ`, `dφ`], we see that corresponding vector, the line element in spherical coordinates `#mover(mi("dS"),mo("→"))`, is not  constructed by directly equating its components to the components of dS^j = [dr, `dθ`, `dφ`], so  

 

 `#mover(mi("dS"),mo("&rarr;"))` <> `d&phi;`*`#mover(mi("&phi;",fontstyle = "normal"),mo("&and;"))`+dr*`#mover(mi("r"),mo("&and;"))`+`d&theta;`*`#mover(mi("&theta;",fontstyle = "normal"),mo("&and;"))` 

 

The vector `#mover(mi("dS"),mo("&rarr;"))` is constructed multiplying these contravariant components [dr, `d&theta;`, `d&phi;`] by the scaling factors, as

 

 `#mover(mi("dS"),mo("&rarr;"))` = `d&phi;`*`h__&phi;`*`#mover(mi("&phi;",fontstyle = "normal"),mo("&and;"))`+dr*h__r*`#mover(mi("r"),mo("&and;"))`+`d&theta;`*`h__&theta;`*`#mover(mi("&theta;",fontstyle = "normal"),mo("&and;"))` 

 

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 A^j the same way we did in the line above with the line element, using the scale-factors h__j, so that

 

 `#mover(mi("A"),mo("&rarr;"))` = Sum(h[j]*A^j*`#mover(mi("\`e__j\`"),mo("&circ;"))`, j = 1 .. 3)

 

where on the right-hand side we see the contravariant components "A[]^(j)" and the scale-factors h[j]. Because the system is orthogonal, each vector component `#msub(mi("A",fontstyle = "normal"),mfenced(mi("j")))`satisfies

A__j = h[j]*A[`~j`]

 

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

 

LinearAlgebra[Norm](`#mover(mi("A"),mo("&rarr;"))`) = A[j]*A[`~j`]

it follows that,

A__j = A__j/h__j

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

 

• 

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: A__c will represent A in Cartesian coordinates, while A__s will represent A in spherical coordinates.

Define(A__c[j], A__s[j])

`Defined objects with tensor properties`

 

{A__c[j], A__s[j], Physics:-Dgamma[a], Physics:-Psigma[a], Physics:-d_[a], Physics:-g_[a, b], Physics:-LeviCivita[a, b, c], Physics:-SpaceTimeVector[a](S), Physics:-SpaceTimeVector[a](X)}

(2.1)

Transformation rule for a contravariant tensor

 

We know, by definition, that the transformation rule for the components of a contravariant tensor is `#mrow(msup(mi("A"),mi("&mu;",fontstyle = "normal")),mo("&ApplyFunction;"),mfenced(mi("y")),mo("&equals;"),mfrac(mrow(mo("&PartialD;"),msup(mi("y"),mi("&mu;",fontstyle = "normal"))),mrow(mo("&PartialD;"),msup(mi("x"),mi("&nu;",fontstyle = "normal"))),linethickness = "1"),mo("&InvisibleTimes;"),mo("&InvisibleTimes;"),msup(mi("A"),mi("&nu;",fontstyle = "normal")),mfenced(mi("x")))`, that is the same as the rule for the differential of the coordinates. Then, the transformation rule from "`A__c`[]^(j)" to "`A__s`[]^(j)"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

 

"TensorArray(`A__c`[]^(j))=TransformCoordinates(tr,`A__s`[]^(j),[X],[S])"

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 "`A__c`[]^(j)", from spherical S = (r, theta, phi) (4th argument) to Cartesian X = (x, y, z) (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 [S]). Expand things to make the comparison with (1.4) possible by eye

 

Vector[column](TensorArray(A__c[`~j`])) = TransformCoordinates(tr, A__s[`~j`], [X], [S], simplifier = expand)

Vector[column](%id = 18446744078459463070) = Vector[column](%id = 18446744078459463550)

(2.2)

We see that the transformation rule for a contravariant vector "`A__c`[]^(j)"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 A__c[j], we know, by definition, that it is `#mrow(msub(mi("A"),mi("&mu;",fontstyle = "normal")),mo("&ApplyFunction;"),mfenced(mi("y")),mo("&equals;"),mfrac(mrow(mo("&PartialD;"),msup(mi("x"),mi("&nu;",fontstyle = "normal"))),mrow(mo("&PartialD;"),msup(mi("y"),mi("&mu;",fontstyle = "normal"))),linethickness = "1"),mo("&InvisibleTimes;"),mo("&InvisibleTimes;"),msub(mi("A"),mi("&nu;",fontstyle = "normal")),mfenced(mi("x")))`, so the same transformation rule for the gradient [`&PartialD;`[x], `&PartialD;`[y], `&PartialD;`[z]], where `&PartialD;`[x] = (proc (u) options operator, arrow; diff(u, x) end proc) and so on. We can experiment this by directly changing variables in the differential operators [`&PartialD;`[x], `&PartialD;`[y], `&PartialD;`[z]], for example

d_[x] = PDEtools:-dchange(tr, proc (u) options operator, arrow; diff(u, x) end proc, simplify)

Physics:-d_[x] = (proc (u) options operator, arrow; ((-r*cos(theta)^2+r)*cos(phi)*(diff(u, r))+sin(theta)*cos(phi)*cos(theta)*(diff(u, theta))-(diff(u, phi))*sin(phi))/(r*sin(theta)) end proc)

(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   [`&PartialD;`[x], `&PartialD;`[y], `&PartialD;`[z]])

H := simplify(LinearAlgebra:-Transpose(1/J))

Vector([d_[x], d_[y], d_[z]]) = H.Vector([d_[r], d_[theta], d_[phi]])

Vector[column](%id = 18446744078518933014) = Vector[column](%id = 18446744078518933254)

(2.4)

The corresponding transformation equations relating the tensors A__c and A__s 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 ~)

Vector[column](TensorArray(A__c[j])) = TransformCoordinates(tr, A__s[j], [X], [r, theta, phi], simplifier = expand)

Vector[column](%id = 18446744078557373854) = Vector[column](%id = 18446744078557374334)

(2.5)

We see that the transformation rule for a covariant vector A__c[j] 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

Vector[column](TensorArray(A__s[j])) = TransformCoordinates(tr, A__c[j], [S], [X], simplifier = expand)

Vector[column](%id = 18446744078557355894) = Vector[column](%id = 18446744078557348198)

(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:

ON


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

(%Nabla = Nabla)(f(X))

%Nabla(f(X)) = (diff(f(X), x))*_i+(diff(f(X), y))*_j+(diff(f(X), z))*_k

(3.1)

(%Nabla = Nabla)(f(S))

%Nabla(f(S)) = (diff(f(S), r))*_r+(diff(f(S), theta))*_theta/r+(diff(f(S), phi))*_phi/(r*sin(theta))

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

lhs(%Nabla(f(X)) = (diff(f(X), x))*_i+(diff(f(X), y))*_j+(diff(f(X), z))*_k) = ChangeBasis(rhs(%Nabla(f(X)) = (diff(f(X), x))*_i+(diff(f(X), y))*_j+(diff(f(X), z))*_k), spherical)

%Nabla(f(X)) = ((diff(f(X), x))*sin(theta)*cos(phi)+(diff(f(X), y))*sin(theta)*sin(phi)+(diff(f(X), z))*cos(theta))*_r+((diff(f(X), x))*cos(phi)*cos(theta)+(diff(f(X), y))*sin(phi)*cos(theta)-(diff(f(X), z))*sin(theta))*_theta+(-(diff(f(X), x))*sin(phi)+cos(phi)*(diff(f(X), y)))*_phi

(3.3)

By eye, we see that in this result the coefficients of [`#mover(mi("r"),mo("&and;"))`, `#mover(mi("&theta;",fontstyle = "normal"),mo("&and;"))`, `#mover(mi("&phi;",fontstyle = "normal"),mo("&and;"))`] are the three lines in the right-hand side of (2.6) after replacing the covariant components A__j by the derivatives of f with respect to the jth coordinate, here displayed using indexed notation due to using CompactDisplay

`~`[`=`]([A__s[1], A__s[2], A__s[3]], [diff(f(S), r), diff(f(S), theta), diff(f(S), phi)])

[A__s[1] = Physics:-Vectors:-diff(f(S), r), A__s[2] = Physics:-Vectors:-diff(f(S), theta), A__s[3] = Physics:-Vectors:-diff(f(S), phi)]

(3.4)

`~`[`=`]([A__c[1], A__c[2], A__c[3]], [diff(f(X), x), diff(f(X), y), diff(f(X), z)])

[A__c[1] = Physics:-Vectors:-diff(f(X), x), A__c[2] = Physics:-Vectors:-diff(f(X), y), A__c[3] = Physics:-Vectors:-diff(f(X), z)]

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

"subs([A__s[1] = Physics:-Vectors:-diff(f(S),r), A__s[2] = Physics:-Vectors:-diff(f(S),theta), A__s[3] = Physics:-Vectors:-diff(f(S),phi)],[A__c[1] = Physics:-Vectors:-diff(f(X),x), A__c[2] = Physics:-Vectors:-diff(f(X),y), A__c[3] = Physics:-Vectors:-diff(f(X),z)],?)"

Vector[column](%id = 18446744078344866862) = Vector[column](%id = 18446744078344866742)

(3.6)

"subs(convert(lhs(?) =~ rhs(?),set),%Nabla(f(X)) = (diff(f(X),x)*sin(theta)*cos(phi)+diff(f(X),y)*sin(theta)*sin(phi)+diff(f(X),z)*cos(theta))*_r+(diff(f(X),x)*cos(phi)*cos(theta)+diff(f(X),y)*sin(phi)*cos(theta)-diff(f(X),z)*sin(theta))*_theta+(-diff(f(X),x)*sin(phi)+cos(phi)*diff(f(X),y))*_phi)"

%Nabla(f(X)) = ((sin(theta)*cos(phi)*(diff(f(S), r))+cos(theta)*cos(phi)*(diff(f(S), theta))/r-sin(phi)*(diff(f(S), phi))/(r*sin(theta)))*sin(theta)*cos(phi)+(sin(theta)*sin(phi)*(diff(f(S), r))+cos(theta)*sin(phi)*(diff(f(S), theta))/r+cos(phi)*(diff(f(S), phi))/(r*sin(theta)))*sin(theta)*sin(phi)+(cos(theta)*(diff(f(S), r))-sin(theta)*(diff(f(S), theta))/r)*cos(theta))*_r+((sin(theta)*cos(phi)*(diff(f(S), r))+cos(theta)*cos(phi)*(diff(f(S), theta))/r-sin(phi)*(diff(f(S), phi))/(r*sin(theta)))*cos(phi)*cos(theta)+(sin(theta)*sin(phi)*(diff(f(S), r))+cos(theta)*sin(phi)*(diff(f(S), theta))/r+cos(phi)*(diff(f(S), phi))/(r*sin(theta)))*sin(phi)*cos(theta)-(cos(theta)*(diff(f(S), r))-sin(theta)*(diff(f(S), theta))/r)*sin(theta))*_theta+(-(sin(theta)*cos(phi)*(diff(f(S), r))+cos(theta)*cos(phi)*(diff(f(S), theta))/r-sin(phi)*(diff(f(S), phi))/(r*sin(theta)))*sin(phi)+cos(phi)*(sin(theta)*sin(phi)*(diff(f(S), r))+cos(theta)*sin(phi)*(diff(f(S), theta))/r+cos(phi)*(diff(f(S), phi))/(r*sin(theta))))*_phi

(3.7)

Simplifying, we arrive at (3.2)

(lhs = `@`(`@`(expand, simplify), rhs))(%Nabla(f(X)) = ((sin(theta)*cos(phi)*(diff(f(S), r))+cos(theta)*cos(phi)*(diff(f(S), theta))/r-sin(phi)*(diff(f(S), phi))/(r*sin(theta)))*sin(theta)*cos(phi)+(sin(theta)*sin(phi)*(diff(f(S), r))+cos(theta)*sin(phi)*(diff(f(S), theta))/r+cos(phi)*(diff(f(S), phi))/(r*sin(theta)))*sin(theta)*sin(phi)+(cos(theta)*(diff(f(S), r))-sin(theta)*(diff(f(S), theta))/r)*cos(theta))*_r+((sin(theta)*cos(phi)*(diff(f(S), r))+cos(theta)*cos(phi)*(diff(f(S), theta))/r-sin(phi)*(diff(f(S), phi))/(r*sin(theta)))*cos(phi)*cos(theta)+(sin(theta)*sin(phi)*(diff(f(S), r))+cos(theta)*sin(phi)*(diff(f(S), theta))/r+cos(phi)*(diff(f(S), phi))/(r*sin(theta)))*sin(phi)*cos(theta)-(cos(theta)*(diff(f(S), r))-sin(theta)*(diff(f(S), theta))/r)*sin(theta))*_theta+(-(sin(theta)*cos(phi)*(diff(f(S), r))+cos(theta)*cos(phi)*(diff(f(S), theta))/r-sin(phi)*(diff(f(S), phi))/(r*sin(theta)))*sin(phi)+cos(phi)*(sin(theta)*sin(phi)*(diff(f(S), r))+cos(theta)*sin(phi)*(diff(f(S), theta))/r+cos(phi)*(diff(f(S), phi))/(r*sin(theta))))*_phi)

%Nabla(f(X)) = (diff(f(S), r))*_r+(diff(f(S), theta))*_theta/r+(diff(f(S), phi))*_phi/(r*sin(theta))

(3.8)

%Nabla(f(S)) = (diff(f(S), r))*_r+(diff(f(S), theta))*_theta/r+(diff(f(S), phi))*_phi/(r*sin(theta))

%Nabla(f(S)) = (diff(f(S), r))*_r+(diff(f(S), theta))*_theta/r+(diff(f(S), phi))*_phi/(r*sin(theta))

(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

A__s_ := A__r(S)*_r+`A__&theta;`(S)*_theta+`A__&phi;`(S)*_phi

A__r(S)*_r+`A__&theta;`(S)*_theta+`A__&phi;`(S)*_phi

(4.1)

CompactDisplay(%)

` A__r`(S)*`will now be displayed as`*A__r

 

` A__&phi;`(S)*`will now be displayed as`*`A__&phi;`

 

` A__&theta;`(S)*`will now be displayed as`*`A__&theta;`

(4.2)

%Divergence(%A__s_) = Divergence(A__s_)

%Divergence(%A__s_) = ((diff(A__r(S), r))*r+2*A__r(S))/r+((diff(`A__&theta;`(S), theta))*sin(theta)+`A__&theta;`(S)*cos(theta))/(r*sin(theta))+(diff(`A__&phi;`(S), phi))/(r*sin(theta))

(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 "`&dtri;`[j](`A__s`[]^(j))". For that purpose, we first transform the coordinates and the metric introducing nonzero Christoffel symbols

TransformCoordinates(tr, g_[j, k], [S], setmetric)

`Systems of spacetime coordinates are:`*{S = (r, theta, phi), X = (x, y, z)}

 

`Changing the differentiation variables used to compute the Christoffel symbols from `[x, y, z]*` to `[r, theta, phi]*` while the spacetime metric depends on `[r, theta]

 

`Default differentiation variables for d_, D_ and dAlembertian are:`*{S = (r, theta, phi)}

 

_______________________________________________________

 

`Coordinates: `[r, theta, phi]*`. Signature: `(`+ + -`)

 

_______________________________________________________

 

Physics:-g_[a, b] = Matrix(%id = 18446744078312216446)

 

_______________________________________________________

 

`Setting `*greek*` letters to represent `*space*` indices`

(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

Riemann[nonzero]

Physics:-Riemann[a, b, c, d] = {}

(4.5)

Consider now the divergence of the contravariant "`A__s`[]^(j)"tensor, computed in tensor notation

CompactDisplay(A__s(S))

` A__s`(S)*`will now be displayed as`*A__s

(4.6)

D_[j](A__s[`~j`](S))

Physics:-D_[j](A__s[`~j`](S), [S])

(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

D_[j](A__s[`~j`](S), [S]) = convert(D_[j](A__s[`~j`](S), [S]), d_)

Physics:-D_[j](A__s[`~j`](S), [S]) = Physics:-d_[j](A__s[`~j`](S), [S])+Physics:-Christoffel[`~j`, a, j]*A__s[`~a`](S)

(4.8)

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

%D_[j](%A__s[`~j`]) = SumOverRepeatedIndices(D_[j](A__s[`~j`](S), [S]))

%D_[j](%A__s[`~j`]) = diff(A__s[`~1`](S), r)+diff(A__s[`~2`](S), theta)+diff(A__s[`~3`](S), phi)+2*A__s[`~1`](S)/r+cos(theta)*A__s[`~2`](S)/sin(theta)

(4.9)

How is this related to the expression of the VectorCalculus[Nabla].`#mover(mi("\`A__s\`"),mo("&rarr;"))` in (4.3) ? The answer is in the relationship established at the end of Sec I between the components of the tensor "`A__s`[]^(j)"and the components of the vector `#mover(mi("\`A__s\`"),mo("&rarr;"))`, namely that the vector components are obtained multiplying the contravariant tensor components by the scale-factors h__j. So, in the above we need to substitute the contravariant "`A__s`[]^(j)" by the vector components A__j divided by the scale-factors

[seq(A__s[Library:-Contravariant(j)](S) = Component(A__s_, j)/h[j], j = 1 .. 3)]

[A__s[`~1`](S) = A__r(S), A__s[`~2`](S) = `A__&theta;`(S)/r, A__s[`~3`](S) = `A__&phi;`(S)/(r*sin(theta))]

(4.10)

subs[eval]([A__s[`~1`](S) = A__r(S), A__s[`~2`](S) = `A__&theta;`(S)/r, A__s[`~3`](S) = `A__&phi;`(S)/(r*sin(theta))], %D_[j](%A__s[`~j`]) = diff(A__s[`~1`](S), r)+diff(A__s[`~2`](S), theta)+diff(A__s[`~3`](S), phi)+2*A__s[`~1`](S)/r+cos(theta)*A__s[`~2`](S)/sin(theta))

%D_[j](%A__s[`~j`]) = diff(A__r(S), r)+(diff(`A__&theta;`(S), theta))/r+(diff(`A__&phi;`(S), phi))/(r*sin(theta))+2*A__r(S)/r+cos(theta)*`A__&theta;`(S)/(sin(theta)*r)

(4.11)

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

expand(%Divergence(%A__s_) = ((diff(A__r(S), r))*r+2*A__r(S))/r+((diff(`A__&theta;`(S), theta))*sin(theta)+`A__&theta;`(S)*cos(theta))/(r*sin(theta))+(diff(`A__&phi;`(S), phi))/(r*sin(theta)))

%Divergence(%A__s_) = diff(A__r(S), r)+(diff(`A__&theta;`(S), theta))/r+(diff(`A__&phi;`(S), phi))/(r*sin(theta))+2*A__r(S)/r+cos(theta)*`A__&theta;`(S)/(sin(theta)*r)

(4.12)
• 

The Curl

 

The Curl of the the vector `#mover(mi("\`A__s\`"),mo("&rarr;"))` in spherical coordinates is given by

%Curl(%A__s_) = Curl(A__s_)

%Curl(%A__s_) = ((diff(`A__&phi;`(S), theta))*sin(theta)+`A__&phi;`(S)*cos(theta)-(diff(`A__&theta;`(S), phi)))*_r/(r*sin(theta))+(diff(A__r(S), phi)-(diff(`A__&phi;`(S), r))*r*sin(theta)-`A__&phi;`(S)*sin(theta))*_theta/(r*sin(theta))+((diff(`A__&theta;`(S), r))*r+`A__&theta;`(S)-(diff(A__r(S), theta)))*_phi/r

(4.13)

 

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

 

"`&epsilon;`[i,j,k] `&dtri;`[]^(j)(`A__s`[]^(k))"

 

But in a curvilinear system `&epsilon;`[i, j, k] is not a tensor, we need to use the non-Galilean form Epsilon[i, j, k] = sqrt(%g_[determinant])*`&epsilon;`[i, j, k], where %g_[determinant] is the determinant of the metric. Moreover, since the expression "Epsilon[i,j,k] `&dtri;`[]^(j)(`A__s`[]^(k))"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

A__j = A__j/h__j

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

Setup(levicivita = nongalilean)

[levicivita = nongalilean]

(4.14)

%Curl(%A__s_) = LeviCivita[i, j, k]*D_[`~j`](A__s[`~k`](S))/%h[i]

%Curl(%A__s_) = Physics:-LeviCivita[i, j, k]*Physics:-D_[`~j`](A__s[`~k`](S), [S])/%h[i]

(4.15)

followed by replacing the contravariant tensor components "`A__s`[]^(k)" by the vector components A__k/h__k 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

lhs(%Curl(%A__s_) = Physics[LeviCivita][i, j, k]*D_[`~j`](A__s[`~k`](S), [S])/%h[i]) = Library:-TensorComponents(rhs(%Curl(%A__s_) = Physics[LeviCivita][i, j, k]*D_[`~j`](A__s[`~k`](S), [S])/%h[i]))

%Curl(%A__s_) = [(sin(theta)^3*(diff(A__s[`~3`](S), theta))*r^2+2*sin(theta)^2*cos(theta)*A__s[`~3`](S)*r^2-(diff(A__s[`~2`](S), phi))*sin(theta)*r^2)/(%h[1]*sin(theta)^2*r^2), (-sin(theta)^3*(diff(A__s[`~3`](S), r))*r^4-2*sin(theta)^3*A__s[`~3`](S)*r^3+(diff(A__s[`~1`](S), phi))*sin(theta)*r^2)/(%h[2]*sin(theta)^2*r^2), (sin(theta)^3*(diff(A__s[`~2`](S), r))*r^4+2*sin(theta)^3*A__s[`~2`](S)*r^3-sin(theta)^3*(diff(A__s[`~1`](S), theta))*r^2)/(%h[3]*sin(theta)^2*r^2)]

(4.16)

Replace now the components of the tensor "`A__s`[]^(j)" by the components of the 3D vector `#mover(mi("\`A__s\`"),mo("&rarr;"))` using (4.10)

lhs(%Curl(%A__s_) = [(sin(theta)^3*(diff(A__s[`~3`](S), theta))*r^2+2*sin(theta)^2*cos(theta)*A__s[`~3`](S)*r^2-(diff(A__s[`~2`](S), phi))*sin(theta)*r^2)/(%h[1]*sin(theta)^2*r^2), (-sin(theta)^3*(diff(A__s[`~3`](S), r))*r^4-2*sin(theta)^3*A__s[`~3`](S)*r^3+(diff(A__s[`~1`](S), phi))*sin(theta)*r^2)/(%h[2]*sin(theta)^2*r^2), (sin(theta)^3*(diff(A__s[`~2`](S), r))*r^4+2*sin(theta)^3*A__s[`~2`](S)*r^3-sin(theta)^3*(diff(A__s[`~1`](S), theta))*r^2)/(%h[3]*sin(theta)^2*r^2)]) = value(subs[eval]([A__s[`~1`](S) = A__r(S), A__s[`~2`](S) = `A__&theta;`(S)/r, A__s[`~3`](S) = `A__&phi;`(S)/(r*sin(theta))], rhs(%Curl(%A__s_) = [(sin(theta)^3*(diff(A__s[`~3`](S), theta))*r^2+2*sin(theta)^2*cos(theta)*A__s[`~3`](S)*r^2-(diff(A__s[`~2`](S), phi))*sin(theta)*r^2)/(%h[1]*sin(theta)^2*r^2), (-sin(theta)^3*(diff(A__s[`~3`](S), r))*r^4-2*sin(theta)^3*A__s[`~3`](S)*r^3+(diff(A__s[`~1`](S), phi))*sin(theta)*r^2)/(%h[2]*sin(theta)^2*r^2), (sin(theta)^3*(diff(A__s[`~2`](S), r))*r^4+2*sin(theta)^3*A__s[`~2`](S)*r^3-sin(theta)^3*(diff(A__s[`~1`](S), theta))*r^2)/(%h[3]*sin(theta)^2*r^2)])))

%Curl(%A__s_) = [(sin(theta)^3*((diff(`A__&phi;`(S), theta))/(r*sin(theta))-`A__&phi;`(S)*cos(theta)/(r*sin(theta)^2))*r^2+2*sin(theta)*cos(theta)*`A__&phi;`(S)*r-(diff(`A__&theta;`(S), phi))*r*sin(theta))/(h[1]*sin(theta)^2*r^2), (-sin(theta)^3*((diff(`A__&phi;`(S), r))/(r*sin(theta))-`A__&phi;`(S)/(r^2*sin(theta)))*r^4-2*sin(theta)^2*`A__&phi;`(S)*r^2+(diff(A__r(S), phi))*sin(theta)*r^2)/(h[2]*sin(theta)^2*r^2), (sin(theta)^3*((diff(`A__&theta;`(S), r))/r-`A__&theta;`(S)/r^2)*r^4+2*sin(theta)^3*`A__&theta;`(S)*r^2-sin(theta)^3*(diff(A__r(S), theta))*r^2)/(h[3]*sin(theta)^2*r^2)]

(4.17)

(lhs = `@`(simplify, rhs))(%Curl(%A__s_) = [(sin(theta)^3*((diff(`A__&phi;`(S), theta))/(r*sin(theta))-`A__&phi;`(S)*cos(theta)/(r*sin(theta)^2))*r^2+2*sin(theta)*cos(theta)*`A__&phi;`(S)*r-(diff(`A__&theta;`(S), phi))*r*sin(theta))/(h[1]*sin(theta)^2*r^2), (-sin(theta)^3*((diff(`A__&phi;`(S), r))/(r*sin(theta))-`A__&phi;`(S)/(r^2*sin(theta)))*r^4-2*sin(theta)^2*`A__&phi;`(S)*r^2+(diff(A__r(S), phi))*sin(theta)*r^2)/(h[2]*sin(theta)^2*r^2), (sin(theta)^3*((diff(`A__&theta;`(S), r))/r-`A__&theta;`(S)/r^2)*r^4+2*sin(theta)^3*`A__&theta;`(S)*r^2-sin(theta)^3*(diff(A__r(S), theta))*r^2)/(h[3]*sin(theta)^2*r^2)])

%Curl(%A__s_) = [((diff(`A__&phi;`(S), theta))*sin(theta)+`A__&phi;`(S)*cos(theta)-(diff(`A__&theta;`(S), phi)))/(r*sin(theta)), (diff(A__r(S), phi)-(diff(`A__&phi;`(S), r))*r*sin(theta)-`A__&phi;`(S)*sin(theta))/(r*sin(theta)), ((diff(`A__&theta;`(S), r))*r+`A__&theta;`(S)-(diff(A__r(S), theta)))/r]

(4.18)

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

%Curl(%A__s_) = ((diff(`A__&phi;`(S), theta))*sin(theta)+`A__&phi;`(S)*cos(theta)-(diff(`A__&theta;`(S), phi)))*_r/(r*sin(theta))+(diff(A__r(S), phi)-(diff(`A__&phi;`(S), r))*r*sin(theta)-`A__&phi;`(S)*sin(theta))*_theta/(r*sin(theta))+((diff(`A__&theta;`(S), r))*r+`A__&theta;`(S)-(diff(A__r(S), theta)))*_phi/r

%Curl(%A__s_) = ((diff(`A__&phi;`(S), theta))*sin(theta)+`A__&phi;`(S)*cos(theta)-(diff(`A__&theta;`(S), phi)))*_r/(r*sin(theta))+(diff(A__r(S), phi)-(diff(`A__&phi;`(S), r))*r*sin(theta)-`A__&phi;`(S)*sin(theta))*_theta/(r*sin(theta))+((diff(`A__&theta;`(S), r))*r+`A__&theta;`(S)-(diff(A__r(S), theta)))*_phi/r

(4.19)
• 

The Gradient

 

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

%Nabla(f(S)) = `&dtri;`[j](f(S))/%h[j]

%Nabla(f(S)) = Physics:-d_[j](f(S), [S])/%h[j]

(4.20)

where on the left-hand side we have the vectorial Nabla  differential operator and on the right-hand side, since f(S) is a scalar, the covariant derivative `&dtri;`[j](f) becomes the standard derivative `&PartialD;`[j](f).

lhs(%Nabla(f(S)) = Physics[d_][j](f(S), [S])/%h[j]) = eval(value(Library:-TensorComponents(rhs(%Nabla(f(S)) = Physics[d_][j](f(S), [S])/%h[j]))))

%Nabla(f(S)) = [Physics:-Vectors:-diff(f(S), r), (diff(f(S), theta))/r, (diff(f(S), phi))/(r*sin(theta))]

(4.21)

The above is the expected result (3.2)

%Nabla(f(S)) = (diff(f(S), r))*_r+(diff(f(S), theta))*_theta/r+(diff(f(S), phi))*_phi/(r*sin(theta))

%Nabla(f(S)) = (diff(f(S), r))*_r+(diff(f(S), theta))*_theta/r+(diff(f(S), phi))*_phi/(r*sin(theta))

(4.22)
• 

The Laplacian

 

Likewise we can compute the Laplacian directly as

%Laplacian(f(S)) = D_[j](D_[j](f(S)))

%Laplacian(f(S)) = Physics:-D_[j](Physics:-d_[`~j`](f(S), [S]), [S])

(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,

SumOverRepeatedIndices(%Laplacian(f(S)) = D_[j](Physics[d_][`~j`](f(S), [S]), [S]))

%Laplacian(f(S)) = Physics:-dAlembertian(f(S), [S])+2*(diff(f(S), r))/r+cos(theta)*(diff(f(S), theta))/(sin(theta)*r^2)

(4.24)

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

value(%Laplacian(f(S)) = Physics[dAlembertian](f(S), [S])+2*(diff(f(S), r))/r+cos(theta)*(diff(f(S), theta))/(sin(theta)*r^2))

((diff(diff(f(S), r), r))*r+2*(diff(f(S), r)))/r+((diff(diff(f(S), theta), theta))*sin(theta)+cos(theta)*(diff(f(S), theta)))/(r^2*sin(theta))+(diff(diff(f(S), phi), phi))/(r^2*sin(theta)^2) = Physics:-dAlembertian(f(S), [S])+2*(diff(f(S), r))/r+cos(theta)*(diff(f(S), theta))/(sin(theta)*r^2)

(4.25)

On the right-hand side we see the dAlembertian , "`&square;`(f(S)),"in curvilinear coordinates; rewrite it using standard diff  derivatives and expand both sides of the equation for comparison

expand(convert(((diff(diff(f(S), r), r))*r+2*(diff(f(S), r)))/r+((diff(diff(f(S), theta), theta))*sin(theta)+cos(theta)*(diff(f(S), theta)))/(r^2*sin(theta))+(diff(diff(f(S), phi), phi))/(r^2*sin(theta)^2) = Physics[dAlembertian](f(S), [S])+2*(diff(f(S), r))/r+cos(theta)*(diff(f(S), theta))/(sin(theta)*r^2), diff))

diff(diff(f(S), r), r)+(diff(diff(f(S), theta), theta))/r^2+(diff(diff(f(S), phi), phi))/(r^2*sin(theta)^2)+2*(diff(f(S), r))/r+cos(theta)*(diff(f(S), theta))/(sin(theta)*r^2) = diff(diff(f(S), r), r)+(diff(diff(f(S), theta), theta))/r^2+(diff(diff(f(S), phi), phi))/(r^2*sin(theta)^2)+2*(diff(f(S), r))/r+cos(theta)*(diff(f(S), theta))/(sin(theta)*r^2)

(4.26)

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

evalb(diff(diff(f(S), r), r)+(diff(diff(f(S), theta), theta))/r^2+(diff(diff(f(S), phi), phi))/(r^2*sin(theta)^2)+2*(diff(f(S), r))/r+cos(theta)*(diff(f(S), theta))/(sin(theta)*r^2) = diff(diff(f(S), r), r)+(diff(diff(f(S), theta), theta))/r^2+(diff(diff(f(S), phi), phi))/(r^2*sin(theta)^2)+2*(diff(f(S), r))/r+cos(theta)*(diff(f(S), theta))/(sin(theta)*r^2))

true

(4.27)


 

Download Vectors_and_Spherical_coordinates_in_tensor_notation.mw

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft


Please Wait...