<<

Classroom Tips and Techniques: Directional in Maple

Robert J. Lopez Emeritus Professor of and Maple Fellow Maplesoft

Introduction

The directional of a scalar , computed in Cartesian coordinates, is defined by , where is the vector x evaluated along a line with direction u. When it exists, it can be evaluated as . In Maple, it is easy to implement both the definition and the evaluation, as we will show.

Several identities in vector involve the operator acting on a vector B. The resulting expression is interpreted as the directional derivative of the vector B in the direction of the vector A. This is not easy to implement in Maple's VectorCalculus package. However, this functionality exists in the Physics:-Vectors package, and in the DifferentialGeometry package where it is properly called the DirectionalCovariantDerivative.

This month's article explores all of these issues.

Directional Derivative of a Scalar

Cartesian Coordinates Top Level

If is a in Cartesian coordinates, then the rate of change of the scalar function taken at in the direction U is

= as computed by Maple. This directional derivative can be written as , or as , provided we define as the vector .

VectorCalculus

The DirectionalDiff command in the VectorCalculus packages will compute, at , the directional derivative of the scalar function in the direction of the vector V, where V does not have to be a unit vector. We illustrate these calculations for the Student VectorCalculus package because this package is a bit more lenient with respect to defining coordinate systems and the names of coordinate variables.

 Tools≻Load Package: Student Loading Student:-VectorCalculus

 Define the vector .

 Apply the DirectionalDiff command.  Note that Maple normalizes V.

 The DirectionalDiff command supports evaluation at a point from within the command itself.

Obtain the directional derivative from first principles

 Apply ∇ to obtain the of f.  Apply the Normalize command to V.

 Normalize V by dividing it by its length.

Student MultivariateCalculus

The Student MultivariateCalculus package has a DirectionalDerivative command that normalizes the direction vector and also has the "evaluation" property.

 Tools≻Load Package:  Student Multivariate Calculus Loading Student:-MultivariateCalculus

 Apply the DirectionalDerivative command.

Physics:-Vectors

The Physics:-Vectors package also has a DirectionalDiff command that will normalize the direction vector. However, it does not have the "evaluation" property.

 Restart Maple.  Load the Physics:-Vectors package.  Allow notational enhancements.

 Define the direction vector V.  The basis vector i can be entered as or as .

 Apply the DirectionalDiff command.  The vector V is normalized by DirectionalDiff.

Polar Coordinates

In Cartesian coordinates, the defining calculation

= suggests that when the of this derivative exists, it can be more easily calculated as . The paradigm extends to other coordinate systems.

VectorCalculus

 Restart Maple.  Tools≻Load Package: Student Vector Loading Student:-VectorCalculus Calculus

 Define the direction vector V as a vector field in polar coordinates.

 Apply the DirectionalDiff command to

 The third argument indicates the system in which to interpret .  Simplify: , and

 Change to , etc.

Maple obtains this result by mapping the whole calculation back to Cartesian coordinates, applying the paradigm , then mapping back to polar coordinates. Note that Maple also normalizes the vector V.

Physics:-Vectors

Like the Student VectorCalculus package, the Physics:-Vectors package can work in Cartesian and , as well as spherical and cylindrical coordinates. For polar coordinates, Physics:-Vectors uses the cylindrical system with basis vectors and . The VectorCalculus package itself works with all of the orthogonal coordinate systems known to Maple. (See for the complete list.)

 Restart Maple.  Load the Physics:-Vectors package.  Allow notational enhancements.

 Define the direction vector V in polar coordinates.  The basis vector can be entered as or as

.

 Apply the DirectionalDiff command.  The vector V is normalized by DirectionalDiff.

This result is equivalent to the result produced by the DirectionalDiff command in the VectorCalculus packages.

Directional Derivative of a Vector

The operator acting on a vector B appears in the vector identities for the gradient of a , and for the of a cross product. In particular, the operator appears in the identities

and

and is generally interpreted as the directional derivative of one vector taken in the direction of the other vector. Indeed, it is a form of the directional of . Just as the directional derivative of a scalar leads to the definition of the gradient vector, so too does the directional derivative of a vector lead to the covariant derivative, a rank-two .

Implementing this directional derivative of a vector in the confines of the VectorCalculus packages pushes these packages to their limits. In effect, the calculation can only be done in Cartesian coordinates, and that, by an artifact. Outside its DifferentialGeometry package, Maple cannot form the operator , so must first compute the of each component of B, and then dot A with each such gradient.

The Physics:-Vectors package extends the applicability of its DirectionalDiff command, but unfortunately normalizes the direction vector when applied to a scalar (correct) and also when applied to a vector (problematic).

Cartesian Coordinates VectorCalculus

 Restart Maple.  Tools≻Load Package: Student Vector Calculus Loading Student:-VectorCalculus  Set display format for vectors.

 Define vector fields F and V.

 Compute by mapping the gradient onto the components of F, then mapping the dot product with V onto each component of that "vector."

 Compute by mapping DirectionalDiff onto the components of F. This then requires multiplying by because DirectionalDiff normalizes the direction vector V.

The syntax for mapping the DirectionalDiff command onto the components of F is far more complex than that required for mapping both the gradient and the dot product. This is for two reasons. First, the DirectionalDiff command normalized the direction vector (here, V); and second, because the Norm command in the VectorCalculus packages produces a function whose value at a point is the norm of the given vector.

A proposal to modify DirectionalDiff in the VectorCalculus packages has already been made. Under this proposal, application of the command to a vector field would be allowed, and when so applied, the direction vector would not be normalized. Maplesoft has given serious consideration to this modification, and if implemented, would allow the (2-D) Math notation to stand for .

Physics:-Vectors

Although the DirectionalDiff command in the Physics:-Vectors package automatically maps onto the components of a vector, the direction vector is normalized.

Unlike the VectorCalculus packages, the Physics:-Vectors package lets the syntax to form a valid operator that can be applied to a vector B. Hence, the notation will compute the directional derivative of B in the direction of A.

 Restart Maple.  Load the Physics:-Vectors package.  Allow notational enhancements.

 Define the vector F.  The basis vector i can be entered as or as .

 Define the direction vector V.  The basis vector i can be entered as or as .

 Apply the DirectionalDiff command, organizing the result by components.

 Implement the notation , again organizing the result by components.

Since the DirectionalDiff command again normalizes the direction vector, the best implementation of the directional derivative of a vector is via the notation in the Physics:-Vectors package, at least in Cartesian coordinates.

Polar Coordinates

As earlier, polar coordinates are used as an example of nonCartesian coordinates.

VectorCalculus

In the VectorCalculus packages, the mapping artifact that works in Cartesian coordinates does not work in polar coordinates. A wrong answer results. Therefore, to obtain the directional derivative of a vector in polar coordinates, the calculation must be implemented in Cartesian coordinates.

 Restart Maple.  Tools≻Load Package: Student Vector Loading Student:-VectorCalculus Calculus  Set display format for vectors.

 Define, in polar coordinates, the vector fields F and V.

 Apply the MapToBasis command to convert F and V to vector fields in Cartesian coordinates.

 Obtain the directional derivative.  Map the result back to polar coordinates.  Simplify: , and

 Change to , etc.

 Display the directional derivative, after having grouped the result by components.

In this directional derivative, the terms and in the first and second components respectively, imply that cannot be represented in nonCartesian coordinates as an operator acting componentwise on F. This is because ultimately, derivatives have to be taken of the varying basis vectors and . Indeed, let , , define a line through the Cartesian point in the direction . The polar vector F evaluated along this line is

The directional derivative is given by , in which the basis vectors and vary along the line described by . Thus, computing requires differentiating the products and , a process that would generate the Christoffel symbols of covariant differentiation. It is this differentiation process that is responsible for the non-differentiated terms in the directional derivative, and therefore the need to carry out the calculation in Cartesian coordinates.

Physics:-Vectors

As pointed out earlier, the Physics:-Vectors package uses cylindrical coordinates to implement polar coordinates. The basis vectors are and .

Unfortunately, none of , or give the correct directional derivative for vectors F and V in polar coordinates. The calculation must still be carried out in Cartesian coordinates, even in the Physics:-Vectors package.

 Restart Maple.  Load the Physics:-Vectors package.  Allow notational enhancements.

 Define, in polar coordinates, the vector fields F and V.

 The following three results are not correct. The first two are missing the non-differentiated terms. The third, using syntax that worked for the scalar case, has incorrect and missing terms.

The correct result can be obtained by the same process used with polar coordinates in the VectorCalculus package. The following calculations bring the vectors to Cartesian coordinates, compute the directional derivative, and return the results to polar coordinates.

Apply the ChangeBasis command to convert F and V to vectors in Cartesian coordinates.

 Obtain the directional derivative and simplify:   Map the result back to polar coordinates.  Force

 Change to , etc.

 Display the directional derivative, after having grouped the result by components.

DifferentialGeometry

There is considerable overhead in setting up a calculation of the directional derivative in the DifferentialGeometry package. Moreover, the notation is ill-adapted for math-mode entry or display of the basic objects of the subject, as demonstrated in greater detail in the earlier Reporter article with the Differential Geometry Package, available in the Maple Application Center.

If and are the contravariant components of the vectors F, and V, respectively, then the directional covariant derivative is given by , where is the covariant derivative of F. The following manipulations leading to the invocation of the DirectionalCovariantDerivative command generate the directional covariant derivative of F in the direction of V.

 Restart Maple.  Load the package and the necessary subpackages.   Avail of notational compression.

 Define R2 as a Cartesian frame.  Define P as a polar frame.

 Define the covariant () basis vectors .

 Define the contravariant (gradient) basis vectors .

 Define the tensor for the Euclidean frame.

The metric tensor for the polar frame is obtained by transforming the Cartesian one

 Equations defining the inverse map from polar to Cartesian.

 Define the inverse map as a DifferentialGeometry object.

 Obtain the metric tensor for polar coordinates.

for polar coordinates.

 , Christoffel symbols (second kind) for polar coordinates:  ,

 List the nonzero Christoffel symbols:

 Define the contravariant vector F.

 Define the contravariant vector V.

 Apply the DirectionalCovariantDerivative command to obtain the directional derivative of F along V.

 Write the directional covariant derivative as a column vector.

 Write the covariant derivative of F as an array.

At first glance, the result produced by the DirectionalCovariantDerivative does not agree with the earlier result

This is because the VectorCalculus and Physics:-Vectors packages use unit basis vectors, so components of vectors are the so-called physical components. The DifferentialGeometry package uses the natural basis vectors, which are not necessarily of unit length. Consequently, to make the results agree, consider the following.

 Let R be the position vector for polar coordinates.

 Natural basis vectors: =

 Unit basis vectors: =

 Express with unit vectors  Express with unit vectors

 Match physical components with "natural" components.

 Replace physical components and unit basis vectors with natural components and natural basis vectors.

Thus, using either the VectorCalculus or Physics:-Vectors packages to compute in polar coordinates by mapping back to Cartesian coordinates produces the same result as computing the directional covariant derivative in the DifferentialGeometry package. Perhaps one day these Maple packages will become more interconnected.

Legal Notice: © Maplesoft, a division of Waterloo Maple Inc. 2011. Maplesoft and Maple are trademarks of Waterloo Maple Inc. This application may contain errors and Maplesoft is not liable for any damages resulting from the use of this material. This application is intended for non-commercial, non-profit use only. Contact Maplesoft for permission if you wish to use this application in for-profit activities.