maxima book chapter 8

38
Vectors: arithmetic, algebra, and analysis in Maxima In this chapter we present examples of vector arithmetic, vector algebra, and vector analysis using Maxima. Vector arithmetic in Maxima A vector in Maxima can be simply defined as a list. Typically, physical vectors (representing, for example, position, velocity, acceleration, force, moment, momentum, angular velocity, angular acceleration, etc.) are three-dimensional vectors. Therefore, physical vectors can be represented by a list of three elements, e.g., the vectors u = -2i + 3j+8k and v = 3i-2j-4k can be represented, in Maxima, as follows: Addition, subtraction, multiplication by a scalar, and linear combinations of vectors are straightforward, as illustrated in the following examples: _______________________________________________________________________________ NOTE: Use of the traditional multiplication (*) and division (/) symbols with two vectors, such as u and v , results in a term-by-term operation that produces a list . The resulting lists, in these cases, have no physical meaning. The following examples illustrate the use of the term-by-term multiplication and division operations: 8-1 © Gilberto E. Urroz, 2009

Upload: prakushprakush

Post on 22-Oct-2015

70 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Maxima Book Chapter 8

Vectors: arithmetic, algebra, and analysis in MaximaIn this chapter we present examples of vector arithmetic, vector algebra, and vector analysis using Maxima.

Vector arithmetic in MaximaA vector in Maxima can be simply defined as a list. Typically, physical vectors (representing, for example, position, velocity, acceleration, force, moment, momentum, angular velocity, angular acceleration, etc.) are three-dimensional vectors. Therefore, physical vectors can be represented by a list of three elements, e.g., the vectors u = -2i + 3j+8k and v = 3i-2j-4k can be represented, in Maxima, as follows:

Addition, subtraction, multiplication by a scalar, and linear combinations of vectors are straightforward, as illustrated in the following examples:

_______________________________________________________________________________

NOTE: Use of the traditional multiplication (*) and division (/) symbols with two vectors, such as u and v, results in a term-by-term operation that produces a list. The resulting lists, in these cases, have no physical meaning. The following examples illustrate the use of the term-by-term multiplication and division operations:

8-1 © Gilberto E. Urroz, 2009

Page 2: Maxima Book Chapter 8

Scalar (dot) and vector (cross) productsThe scalar, or dot , product of two vectors is accomplished by using a period between the vectors, e.g.,

Since the dot product of a vector with itself represents the square of the vector's magnitude (or Euclidean length), the magnitude of a vector can be calculated as the square root of the dot product of the vector with itself, i.e., ∣u∣=u⋅u . For example, the magnitudes of vectors u and v will be calculated as:

A unit vector in the direction of u is calculated as eu=u∣u∣ . Using Maxima, this can be

accomplished by the following commands:

The angle between two vectors is calculated as =cos−1 u⋅v∣u∣∣v∣ . Thus, using Maxima, the

angle, in radians, between vectors u and v is calculated as:

8-2 © Gilberto E. Urroz, 2009

Page 3: Maxima Book Chapter 8

The corresponding angle in degrees would be calculated as:

The vector, or cross, product of two vectors is calculated using the wedge operator: ~ , which belongs in the vect package. The evaluation of a cross product requires the use of the express (expression) function. Try the following example:

Alternatively, you can combine express with the wedge operator to calculate the cross product in a single step:

_______________________________________________________________________________NOTE: The vect package is used later in this Chapter to perform operations of vector analysis._______________________________________________________________________________

The volume of the parallelepiped defined by three vectors u, v, and w, is calculated by the formula V =∣u⋅v×w∣ .

This operation is illustrated by using the following commands (u,v defined above):

8-3 © Gilberto E. Urroz, 2009

Page 4: Maxima Book Chapter 8

Determining the equation of a plane using the dot productThe figure below shows a plane containing a point P0(x0,y0,z0) with normal vector n. If one selects an arbitrary point P(x,y,z) in the plane, one can form the vector r=P0 P = P-P0, and use the fact that n⋅r=∣n∣∣r∣cos 90o=0 to determine the equation of the plane.

Consider, for example, a plane containing point P0(-2, 5, 3) normal to the vector n = 3i+5j+2k. First, we define the vector n and points P0 and P:

Next, we use the dot product to produce the equation of the plane:

It's easy to verify that point P0 belongs in the plane by using:

Using function solve we can solve for z out of the equation EQ, and define a function f(x,y)

8-4 © Gilberto E. Urroz, 2009

Page 5: Maxima Book Chapter 8

that can be used to plot the plane:

To produce the plot you can use the wxMaxima menu option plotting>plot3d... which produces the following input form. The options used to produce the plot, as well as the resulting plot, are shown in the figure below:

8-5 © Gilberto E. Urroz, 2009

Page 6: Maxima Book Chapter 8

Vector plots using the draw package The draw package includes a number of functions for producing a variety of plots. Examples of applications of the draw package are available at this web address:

http://www.telefonica.net/web2/biomates/maxima/gpdraw/

In this section we describe the use of function draw2d to produce the plot of one or more vectors.

The first example illustrates the use of function draw2d, together with the wx wrapper (to use it in the wxMaxima interface), to plot the two-dimensional vector r = 3i + 3j, based on point (2,1). The command required to produce this plot is shown in Figure 8.1, below.

The command wxdraw2d requires the following parameters:

• xrange: range of values of x for the two-dimensional plot = [xmin, xmax]• yrange: range of values of y for the two-dimensional plot = [ymin, ymax]• head_length: length of vector head in units of the graph• head_angle: angle of the arrow head in degrees• line_width: width of the arrow line in pixels• color: color for the vector (e.g., red, blue, yellow, green, etc.)• vector: requires two vectors: base point, and vector components

The result of command wxdraw2d, illustrated in Figure 8.1, below, is the red vector based at point [2,1] with components [3,3]. The figure shows the other parameters in the plot. To produce the command in multiple lines, use the multiple-line input box (see Figure 8.2, below)

Figure 8.1. Parameter for plotting a vector using function draw2d in package draw.

8-6 © Gilberto E. Urroz, 2009

Page 7: Maxima Book Chapter 8

The multiple-line input box for this command will look as follows:

Figure 8.2. Multiple-line input box for the command used in Figure 8.1, above.

A second example of plotting vectors is shown in Figure 8.3, which shows the plot of vectors u = 2i + 3j, v = 3i + 2j, and their sum, w = u + v. Notice the use of different colors to indicate the different vectors involved. All the vectors use the same head_length, head_angle, and base point [0,0].

Figure 8.3. Use of function wxdraw2d to plot multiple vectors.

8-7 © Gilberto E. Urroz, 2009

Page 8: Maxima Book Chapter 8

Function draw3d can be used to plot three-dimensional vectors as illustrated in the following example. The result is shown in Figure 8.5.

Figure 8.4. wxMaxima input for plotting 3 three-dimensional vectors and multiple-line input box command with the plotting command.

Figure 8.5. Plot of 3 vectors in three-dimensions using function draw3d.

8-8 © Gilberto E. Urroz, 2009

Page 9: Maxima Book Chapter 8

Vector calculus in MaximaDerivatives of vector functions. Consider a position vector defined by r(t) = ti + t2j + t1/2 k. The following commands define this position vector as a vector function r(t), and calculates the functions velocity v(t) = dr/dt, and the acceleration a(t) = d2r/dt2 for r(t), using diff.

The magnitude of the position, velocity, and acceleration vectors can be calculated using the definition ∣r∣=r⋅r , ∣v∣= v⋅v , and ∣a∣=a⋅a , respectively. With Maxima:

8-9 © Gilberto E. Urroz, 2009

Page 10: Maxima Book Chapter 8

Any of these functions can be evaluated for different values of t, e.g., using the option Algebra > Make list … , results in the following:

Scalar functions, such as the magnitudes of the position, velocity, and acceleration vectors, mag_r(t), mag_v(t), and mag_a(t), can be plotted using function wxplot2d, e.g.,

Integrals of vector functions. Function integrate, or the option Calculus>Integrate..., can be used to calculate indefinite or definite integrals for a vector function. For example, given a velocity v(t) = sin(t)i + cos(t)j + tk, the position vector can be calculated as an indefinite integral, r t=∫ v t dtC . Maxima does not include the integrating constant automatically, therefore, in the Maxima command, we include the constant ourselves in the command:

8-10 © Gilberto E. Urroz, 2009

Page 11: Maxima Book Chapter 8

Suppose that the initial conditions are r(0) = [2,-3,4], which we will re-write as an equation Eq = r(0)-[2,-3,4], and use the command solve to calculate the constants Cx, Cy, and Cz:

The user can then substitute the values of the constants Cx, Cy, and Cz into the different components of the vector r(t), namely, r(t)[1], r(t)[2], and r(t)[3], respectively. Finally, the vector function r(t) gets re-defined:

Plots of vector functions. To plot vector functions we can generate a list of vectors by evaluating the vector functions at different values of the parameter t. For example, for the following position r(t) and velocity v(t) functions:

we can define the following functions r2df(t) and v2df(t) that will create the vectors for plotting:

8-11 © Gilberto E. Urroz, 2009

Page 12: Maxima Book Chapter 8

The following commands use function r2df and v2df to produce the lists of vectors rvects and vvects:

Next, we are going to produce a couple of lists of vectors and their properties (list1, list2) that we will then incorporate into the draw2d command to produce the vector plots. Notice the use of function append to append all the graphic properties to the list of vectors:

We will also create a third list, list3, that describes the curve whose parametric equations, x(t) and y(t), are the components of vector r(t):

8-12 © Gilberto E. Urroz, 2009

Page 13: Maxima Book Chapter 8

To illustrate the application of function wxdraw2d to the lists created above, we use function apply to function wxdraw2d and to each list:

To plot the curve and the two sets of vectors we combine the three lists into one using append, and then use function apply with function wxdraw2d as follows:

8-13 © Gilberto E. Urroz, 2009

Page 14: Maxima Book Chapter 8

Consider now a three-dimensional vector plot including position, velocity, and acceleration vectors for a space curve. First, we define the vectors as follows:

Next, we define functions to put together the vectors for plotting:

The next step is to create lists of vectors for position, velocity, and acceleration:

8-14 © Gilberto E. Urroz, 2009

Page 15: Maxima Book Chapter 8

Next, we create lists of graphic properties for the three set of vectors and for the parametric equations describing the curve r(t):

Next, we combine all the lists of graph commands into a single one, and apply function draw3d to this new list to produce the following graph. In this plot, blue arrows = position vector, red arrows =velocity vector, and green arrows =acceleration vector:

8-15 © Gilberto E. Urroz, 2009

Page 16: Maxima Book Chapter 8

Differential geometry of curvesA curve C in space can be defined by a triad of parametric equations x = x(t), y = y(t), and z = z(t). Notice that the parameter t may or may not represent time. If it does, then the curve represents the trajectory of a particle undergoing motion. If the parametric equations are written in terms of a parameter s representing the arc length of the curve, (measured from an arbitrary point on the curve), then we can define the unit tangent vector T as

T= d rds .

Also, the principal (unit) normal vector is defined by the expression

d Tds

=N ,

where κ is the curvature of curve C at a given point. Since |N| = 1, the curvature is calculated as:

=∣d Tds ∣ .

The radius of curvature is defined as

= 1 .

The center of curvature of C at a given point is found by measuring a distance ρ along the direction of N. A circle of curvature can be traced for every point in a curve. The curvature of a space curve is illustrated in Figure 8.6(a).

Figure 8.6. Curvature and vector triad for a space curve.

8-16 © Gilberto E. Urroz, 2009

Page 17: Maxima Book Chapter 8

A unit binormal vector can be calculated using vectors N and T as

B=T×N .

The unit vectors T, N, and B constitute a local system of orthogonal axes known as the vector triad at any point on the curve C. The plane defined by vectors T and N is known as the osculating plane 1 . The plane defined by vectors B and N is known as the normal plane. The plane defined by vectors B and T is known as the rectifying plane. Figure 8.6(b) illustrates the vector triad and the osculating, normal, and rectifying planes associated with a point P in a space curve.

Since, in most cases, it is difficult to determine the dependency of the position vector r on the curve length s, we can write the parametric equations in terms of another parameter, say, t, so that r(t) = x(t)i + y(t)j + z(t)k. In this case the calculations to perform to find the curvature parameters as well as the vector triad are as follows. First, the unit tangent vector is calculated as:

T=d rds

=d r / dtds /dt

= d r /dt∣d r /dt∣ ,

since ds=∣d r∣ . Also, to calculate dT/ds, curvature, radius of curvature, unit normal vector, and binomial unit vector use, respectively:

d Tds

= d T / dtds /dt

= d T /dt∣d r /dt∣ , ∣∣=∣d Tds ∣ , = 1

, and N=1

d Tds .

Finally, B=T×N .

Example of a vector triad calculated using Maxima Consider the parametric equations that define a curve C in space, namely, x(t) = 3 sin(2t), y(t) = 3 cos(2t), z(t) = t/2, where s is the distance measured along the curve from point P0(0,3,0), i.e., s= 0. Thus, the position vector corresponding to curve C is given by:

First, we calculate dr/dt (drdt):

1 From the Latin word osculare (to kiss), i.e., the osculating plane is the kissing plane.

8-17 © Gilberto E. Urroz, 2009

Page 18: Maxima Book Chapter 8

The magnitude of dr/dt is ds/dt = |dr/dt| (mag_drdt):

The unit normal tangent vector T is calculated as T=d rds

=d r / dtds /dt

= d r /dt∣d r /dt∣ , i.e.,

Just as a check, we calculate the magnitude of T (mag_T):

The derivative dT/ds (dTds) is calculated using d Tds

= d T / dtds /dt

= d T /dt∣d r /dt∣ . In the following

Maxima calculation we use variable dTdt to represent dT/dt and we use the quantity mag_drdt, previously calculated, to represent dr/dt, i.e.,

8-18 © Gilberto E. Urroz, 2009

Page 19: Maxima Book Chapter 8

The curvature κ of the curve C, =∣d Tds ∣ , is calculated as follows:

To check the sign of the curvature, compare the vectors d Tds

and ∣∣N :

Since d Tds

=∣∣N , then the correct sign for κ is a positive sign, i.e.,

The radius of curvature = 1 is, therefore,

The normal vector is calculated as N=1

d Tds , i.e.,

8-19 © Gilberto E. Urroz, 2009

Page 20: Maxima Book Chapter 8

By inspection we can see that the magnitude of N is 1. If you have any doubts, try the following:

The binormal vector is calculated using the cross product B=T×N :

To find the vector triad at point P0(0,3,0), for t = 0, we use the following commands:

We can check that the (T,N,B) triad is orthogonal by calculating the dot products: N•T, T•B, and B•N, which should all be zero:

8-20 © Gilberto E. Urroz, 2009

Page 21: Maxima Book Chapter 8

The Frenet-Serret FormulasThese are formulas that relate the derivatives of the unit vectors with respect to the curve length s. The first formula was already used to define curvature and the unit normal vector, i.e.,

d Tds

=N

Derivatives of the other two unit vectors are calculated below in terms of the curvature κ and a quantity τ, known as the torsion of the curve:

d Nds

=B−T ,

d Bds

=−N .

From the last formula it follows that the magnitude of the torsion is

∣∣=∣d Bds ∣ .

The radius of torsion is calculated as

= 1 .

The derivatives of the unit vectors, when the curve is described by parametric equations of the form r(t) = x(t)i + y(t)j + z(t)k, are calculated as

d Tds

= d T / dtds /dt

= d T /dt∣d r /dt∣ ,

d Nds

=d N /dtds /dt

=d N /dt∣d r /dt∣ ,

and

d Bds

=d B /dtds /dt

=d B / dt∣d r /dt∣ .

Calculating derivatives d N /ds, d B /ds, torsion and radius of torsion In this section we continue the calculations using the position vector r(t) defined earlier. We start by calculating the derivatives dN/ds (dNds) and dB/ds (dBds) using the derivatives dN/dt (dNdt) and dB/dt (dBdt) and the magnitude |dr/dt| (mag_drdt), calculated earlier:

8-21 © Gilberto E. Urroz, 2009

Page 22: Maxima Book Chapter 8

To calculate the magnitude of the torsion, we use:

To determine the sign of the the torsion, we compare the vectors d Bds and −∣∣N .

Notice that d Bds

=−−∣∣N =∣∣N , thus, the correct sign for τ is a negative sign since

d Bds

=−N , i.e.,

The radius of torsion is calculated:

8-22 © Gilberto E. Urroz, 2009

Page 23: Maxima Book Chapter 8

Vector analysisThe term vector analysis is presented here in terms of differential operations of scalar and vector fields, i.e., functions of the form φ(x,y,z), scalar, or F(x,y,z), vector. These two examples represent steady-state fields, i.e., fields that do not depend on time. In the most general case, fields are time dependent, and the expressions to use for scalar and vector fields are φ(x,y,z,t), scalar, or F(x,y,z,t), vector, respectively.

Definitions. The following definitions are used for differential operations in vector analysis:

• The del or nabla operator: ∇[ ]=∂[ ]∂ xi∂[ ]

∂ yj∂[ ]

∂ zk

• The gradient of a scalar function: apply the del or nabla operator to a scalar function φ, for example:

∇=∂∂ x

i∂∂ y

j∂∂ z

k

• The directional derivative represents the rate of change of function φ in the direction defined by a unit vector u=ux iu y juz k , i.e.,

Du=∇⋅u= ∂∂ xi∂

∂ yj∂

∂ zk⋅ux iu y juz k =u x

∂∂ x

u y∂∂ y

uz∂∂ z

• Normal vector to a surface: Let φ(x,y,z) = 0 represent a surface in space, then the vector n=∇ at any point of the surface represents a normal vector to the surface.

• Direction of maximum rate of change of φ(x,y,z) on the surface φ(x,y,z) = 0: The magnitude of the directional derivative is Du=∇⋅u . Since the magnitude of u is 1, then ∣D u∣=∣∇⋅u∣=∣∇∣∣u∣cos =∣∇∣cos where θ is the angle between vectors u and ∇ . The maximum value of ∣D u∣ occurs when θ = 0, i.e., ∣D u∣max=∣∇∣ when u and ∇ are parallel. Therefore, the maximum rate of

change of the function φ(x,y,z) on the surface φ(x,y,z) = 0 occurs in the direction of the gradient vector ∣∇∣ , i.e., in a direction normal to the surface.

• The divergence of a vector function is defined by the “dot” product of the del or nabla operator and the vector function:

div =∇⋅F=∂[ ]∂ xi∂[]

∂ yj∂[]

∂ zk⋅F x iF y jF zk =

∂ F x

∂ x∂F y

∂ y∂ F z

∂ z

8-23 © Gilberto E. Urroz, 2009

Page 24: Maxima Book Chapter 8

• The curl, or rotational, of a vector function is defined by the “cross” product of the del or nabla operator and the vector function:

curl =∇×F=∣ i j k∂∂ x

∂∂ y

∂∂ z

F x F y F z∣

• The Laplacian of a scalar function is defined as the divergence of the gradient of the scalar function, i.e.,

∇2=div grad =∇⋅∇=∂2∂ x2

∂2∂ y 2

∂2∂ z2

• The homogeneous partial differential equation ∇2=0 is known as the Laplace equation, and functions φ(x,y,z) that satisfy this equation are known as harmonic functions. The corresponding non-homogeneous equation ∇2=K x , y , z is known as the Poisson equation.

• A vector field F(x,y,z) for which ∇×F=0 is said to be a solenoidal field. Since ∇×∇=0 , for any scalar function φ(x,y,z), if there exists a function φ(x,y,z) so

that F=∇=grad for a solenoidal field, then φ(x,y,z) is known as the vector potential of F.

Using the package vect . Differential operations in Maxima are available through the package vect. The package defines the following operators: . (dot), ~ (cross), grad, div, curl, laplacian. The package also includes functions: declare, vectorsimp, express, potential, vectorpotential, and scalefactors. Some applications of these operators and functions are presented below.

• Dot and cross products : these operations were presented earlier, here we show a few other examples. First, we load package vect, and define a couple of vector functions:

The dot product produces a scalar function:

8-24 © Gilberto E. Urroz, 2009

Page 25: Maxima Book Chapter 8

The cross product, on the other hand, requires the use of function express (expression) to complete the operation:

These two steps can be combined into a single operation:

• Vector formulas expansions . We can use the vect package and declare a few symbols as scalar functions and a few as non-scalar (for all practical purposes, vector) functions and use ev and vectorsimp to produce equivalent expansions of differential operations of sums, products, and divisions of functions. For example, let's declare φ and ψ as scalar functions, and F and G as nonscalar (vector) functions:

Then, we use Maxima to expand the formula ∇=∇∇ as follows:

Since both φ and ψ were declared as scalar functions, and attempt to expand the operation div =∇⋅ fails. Instead, Maxima converts the operation to a gradient expansion with dot products:

8-25 © Gilberto E. Urroz, 2009

Page 26: Maxima Book Chapter 8

A more appropriate combination for the application of the div operator is the divergence of the product of a scalar and a vector function, i.e.,

∇⋅F =∇F∇⋅F :

Using Maxima this operation is expanded as:

The following commands show the gradient of the ratio of two scalar functions:

One example involving the laplacian of the product of two scalar functions follows:

Using the package vect_transform . Load the packages, vect and vect_transform to have access to the following systems of orthogonal coordinates:

• cartesian2d• cartesian3d• polar• polarcylindrical• spherical• oblatespheroidal• prolatespheroidal• oblatespheroidalsqrt• prolatespheroidalsqrt• elliptic

• ellipticcylindrical• confocalelliptic• confocalellipsoidal• parabolic• paraboliccylindrical• paraboloidal• bipolar• bipolarcylindrical• toroidal• conical

To obtain the Cartesian coordinate transformations corresponding to each of these orthogonal systems of coordinates, simply type the appropriate name in Maxima. The following figure shows some of the most commonly used coordinate systems:

8-26 © Gilberto E. Urroz, 2009

Page 27: Maxima Book Chapter 8

The general form of the coordinate definitions is the following:

• In two dimensions (2-D): [ [ f1(u1,u2), f2(u1,u2) ], u1, u2]• In three dimensions (3-D): [ [ f1(u1,u2,u3), f2(u1,u2,u3), f3(u1,u2,u3) ], u1, u2, u3]

where u1,u2,u3 are the basic coordinates in the system, and x = f1(u1,u2,u3), y = f2(u1,u2,u3), z = f3(u1,u2,u3) are the transformations required to convert from the (u1,u2,u3) to the Cartesian coordinate system (x,y, z).

For example, for polar coordinates the basic coordinates are u1 = r, u2 = θ, and the transformations to convert to Cartesian coordinates are x = r cos(θ) and y = r sin(θ).

• Expressions for differential vector operations in Cartesian coordinates Use function scalefactors from package vect with the name of an orthogonal coordinate system from package vect_transform, and you can then obtain expressions for differential vector operations in that particular coordinate system. For example, using Cartesian coordinates in three dimensions, one can find the expressions for selected differential vector operations. First, we load packages vect and vect_transform, and declare a few variable names as scalars and non-scalars (vectors):

Here are some of the vector differential operations in Cartesian coordinates:

8-27 © Gilberto E. Urroz, 2009

Page 28: Maxima Book Chapter 8

Some other operations are shown below:

• Expressions for vector differential operations in cylindrical-polar coordinates Changing the coordinate system to polarcylindrical we can obtain vector differential operations in cylindrical-polar coordinates:

8-28 © Gilberto E. Urroz, 2009

Page 29: Maxima Book Chapter 8

Obviously, the total derivatives shown in the expressions above need to be interpreted as partial derivatives. For example, the gradient of φ in cylindrical polar coordinates,

would be interpreted as

∇=[∂∂ r, 1∣r∣

∂∂

, ∂∂ z ] , or ∇=∂

∂ rer

1∣r∣

∂∂e

∂∂ ze z .

• Expressions for vector differential operations in spherical coordinates Changing the coordinate system to spherical we can obtain vector differential operations in spherical coordinates:

8-29 © Gilberto E. Urroz, 2009

Page 30: Maxima Book Chapter 8

Calculating vector differential operations for specific scalar and vector fieldsIf the expression for scalar or vector fields are given, we can find expressions for vector differential operations as illustrated below. First, we show some examples in Cartesian coordinates by defining the scalar function

φ = x2+y2+z2,

and the vector function

F = (x+y+z)i + (x+xy+yz)j + ((y+x)(z+y))k,

and calculating the following operations:

∇ ,∇⋅F ,∇×F , and ∇2 .

The Maxima commands used are the following:

8-30 © Gilberto E. Urroz, 2009

Page 31: Maxima Book Chapter 8

• Loading packages and calculating grad(φ):

• Calculating div(F):

• Calculating curl(F):

• Calculating ∇2 :

8-31 © Gilberto E. Urroz, 2009

Page 32: Maxima Book Chapter 8

The following calculations show examples using cylindrical polar coordinates:

• Defining φ and calculating grad(φ):

• Defining F and calculating div(F):

8-32 © Gilberto E. Urroz, 2009

Page 33: Maxima Book Chapter 8

• Calculating curl(F):

• Calculating ∇2 :

Curvilinear CoordinatesIn the section above we presented calculations using Cartesian, cylindrical (polar), and spherical coordinates. Cartesian coordinates have the property of being such that the coordinate positions (x,y,z) also represent the distances, from the origin, along the coordinate directions. Such is not the case for other systems of orthogonal systems. For example, in cylindrical (polar) coordinates, the r and z coordinates do correspond to the distances from the origin along those coordinates, however, a distance along the θ coordinate is actually calculated as rθ. Thus, we say that r is the scale factor for the θ coordinate, i.e., the factor that converts the coordinate θ into a distance.

Coordinate transformationsConsider a generic orthogonal coordinate system defined by coordinates (u1,u2,u3) such that u1 = u1(x,y,z), u2 = u2(x,y,z), and u3= u3(x,y,z) represent the transformation of coordinates from (x,y,z) to (u1,u2,u3). For example, in the cylindrical (polar) coordinate system with (u1,u2,u3) = (r,θ,z), the coordinate transformations are

u1=r= x2 y2z2 , u2==tan−1 y / x , and u3=z=z .

8-33 © Gilberto E. Urroz, 2009

Page 34: Maxima Book Chapter 8

If the relationships describing the coordinate transformations are uniquely defined, it is possible to write the inverse transformation of coordinates back into Cartesian coordinates, i.e., x = x(u1,u2,u3), y = y(u1,u2,u3), and z = z(u1,u2,u3). For example, for the conversion of cylindrical to Cartesian coordinates these relationships are:

x=r⋅cos =u1⋅cos u2 , x=r⋅sin =u1⋅sin u2 , and z=z=u3 .

Coordinate transformations using Maxima As we indicated earlier in this chapter, when you load the packages vect and vect_transform you have access to the following systems of orthogonal coordinates:

• cartesian2d• cartesian3d• polar• polarcylindrical• spherical• oblatespheroidal• prolatespheroidal• oblatespheroidalsqrt• prolatespheroidalsqrt• elliptic

• ellipticcylindrical• confocalelliptic• confocalellipsoidal• parabolic• paraboliccylindrical• paraboloidal• bipolar• bipolarcylindrical• toroidal• conical

To obtain the Cartesian coordinate transformations corresponding to each of these coordinate systems simply type the appropriate name in Maxima. Earlier on we obtained the Cartesian coordinate transformation for the polar (2D), polarcylindrical (3D), and spherical (3D) coordinate systems. Other coordinate transformations are shown below.

8-34 © Gilberto E. Urroz, 2009

Page 35: Maxima Book Chapter 8

Notice that Maxima uses coordinate names ϕ, u, and v, instead of u1,u2, and u3, for many of the three-dimensional coordinate systems. Also, coordinate systems such as the polar, elliptic, parabolic, and bipolar, are two dimensional (using only coordinates u and v), while their corresponding three-dimensional systems, i.e., polarcylindrical, ellipticcylindrical, paraboliccylindrical, and bipolarcylindrical, simply add the coordinate z. The confocalelliptic system is two-dimensional, while the confocalellipsoildal is a three-dimensional system using the coordinates u, v, and w. Wherever they appear, e, f, and g, represent constants.

8-35 © Gilberto E. Urroz, 2009

Page 36: Maxima Book Chapter 8

Illustration of orthogonal coordinate systemsTo illustrate three-dimensional orthogonal coordinate systems using Maxima we can produce a plot showing coordinates surfaces u1 = constant, u2 = constant, and u3 = constant. For example, for the polarycylindrical coordinate system, namely,

we can generate the coordinate surfaces z = 5, r = 5, and θ = 0. The following draw3d command, used after loading the draw package, produces the required plot.

The resulting plot is shown below. The blue plane represents z = 5, the red cylinder represent r = 5, and the green plane represents θ = 0.

8-36 © Gilberto E. Urroz, 2009

Page 37: Maxima Book Chapter 8

The following commands are used to produce constant coordinate surfaces for the spherical coordinate system:

The figure below shows two views of the plot thus produced. The surfaces shown are r = 5 (blue sphere), φ = 0 (red plane)d, and θ = π/4 (green cone).

8-37 © Gilberto E. Urroz, 2009

Page 38: Maxima Book Chapter 8

Two-dimensional coordinate systems can be illustrated by using a parametric surface plot on a z = constant plane (e.g., z = 0). The following command and plot illustrate the constant lines of the parabolic coordinate system on the plane z = 0:

8-38 © Gilberto E. Urroz, 2009