Lesson 2: Arithmetic Operations - Maple Help

DifferentialGeometry Lessons

Lesson 2: Arithmetic Operations and Special Input Commands

Overview

In this lesson, you will learn to do the following:

 – Add, subtract, and scalar multiply vectors, forms and tensors.
 – Calculate the wedge product of forms.
 – Calculate the tensor product of two tensors.
 – Use the DifferentialGeometry parser evalDG.
 – Calculate the inner product of a vector and a form.
 – Use the DGzip command to form linear combinations of vectors, forms, and tensors.
 – Work with matrices of differential forms.
 – Create zero forms of a given degree, and volume forms.
 – Convert an array to a tensor.
 – Convert a differential form to a tensor.

&plus, &minus, &mult

When using these algebraic commands, it is important to use parentheses to indicate the order of operation.

 > with(DifferentialGeometry): DGsetup([x, y, z], E3);
 ${\mathrm{frame name: E3}}$ (2.1)

Enter the vector field D_x + 3D_y - 2xyD_z.

 E3 > D_x &plus (3 &mult D_y) &minus ((2*x*y) &mult D_z);
 ${\mathrm{D_x}}{+}{3}{}{\mathrm{D_y}}{-}{2}{}{x}{}{y}{}{\mathrm{D_z}}$ (2.2)

Enter the vector field dx + 3dy - 2xydz.

 E3 > dx &plus (3 &mult dy) &minus ((2*x*y) &mult dz);
 ${\mathrm{dx}}{+}{3}{}{\mathrm{dy}}{-}{2}{}{x}{}{y}{}{\mathrm{dz}}$ (2.3)

&wedge, &tensor

 E3 > with(DifferentialGeometry): DGsetup([x, y, z], E3);
 ${\mathrm{frame name: E3}}$ (3.1)

Enter the wedge product of the 1-forms dx, dy, dz.

 E3 > dx &wedge dy &wedge dz;
 ${\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dy}}{}{\mathrm{^}}{}{\mathrm{dz}}$ (3.2)

Enter the tensor product of the 1-forms dx, dy, dz.

 E3 > dx &tensor dy &tensor dz;
 ${\mathrm{dx}}{}{\mathrm{dy}}{}{\mathrm{dz}}$ (3.3)

Enter the tensor product of the vector fields D_x, D_y, D_z.

 E3 > D_x &tensor D_y &tensor D_z;
 ${\mathrm{D_x}}{}{\mathrm{D_y}}{}{\mathrm{D_z}}$ (3.4)

Enter the 2 form 3dx^dy + xdy^dz.

 E3 > (3 &mult (dx &wedge dy)) &plus ( x &mult (dy &wedge dz));
 ${3}{}{\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dy}}{+}{x}{}{\mathrm{dy}}{}{\mathrm{^}}{}{\mathrm{dz}}$ (3.5)

evalDG

The DifferentialGeometry parser evalDG provides an easier way to perform arithmetic operations.

 – Use +, -, and * for addition, subtraction, and scalar multiplication.
 – Use &w for wedge product.
 – Use &t for tensor product.

 E3 > restart: with(DifferentialGeometry): DGsetup([x, y, z], E3):

Enter the vector field 2D_x - xD_y + yD_z.

 E3 > evalDG(2*D_x - x*D_y + y*D_z);
 ${2}{}{\mathrm{D_x}}{-}{x}{}{\mathrm{D_y}}{+}{y}{}{\mathrm{D_z}}$ (4.1)

Enter the rank 2 tensor 2D_x dy - xD_y - xD_y dz.

 E3 > evalDG(2*D_x &t dy - x*D_y &t dz);
 ${2}{}{\mathrm{D_x}}{}{\mathrm{dy}}{-}{x}{}{\mathrm{D_y}}{}{\mathrm{dz}}$ (4.2)

Enter the 2-form 2dx^dy - xdy^dz.

 E3 > evalDG(2*dx &w dy - x*dy &w dz );
 ${2}{}{\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dy}}{-}{x}{}{\mathrm{dy}}{}{\mathrm{^}}{}{\mathrm{dz}}$ (4.3)

Hook

The command Hook calculates the interior product of a vector and a differential p-form.

 E3 > with(DifferentialGeometry): DGsetup([x, y, z], E3):

Define vectors X, Y and a 2-form alpha.

 E3 > X := D_x;
 ${X}{≔}{\mathrm{D_x}}$ (5.1)
 E3 > Y := D_y;
 ${Y}{≔}{\mathrm{D_y}}$ (5.2)
 E3 > alpha := evalDG(3*dx &w dy - 4*dy &w dz + 2*dx &w dz);
 ${\mathrm{α}}{≔}{3}{}{\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dy}}{+}{2}{}{\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dz}}{-}{4}{}{\mathrm{dy}}{}{\mathrm{^}}{}{\mathrm{dz}}$ (5.3)

Calculate the interior product of X and alpha.

 E3 > beta1 := Hook(X, alpha);
 ${\mathrm{β1}}{≔}{3}{}{\mathrm{dy}}{+}{2}{}{\mathrm{dz}}$ (5.4)

Calculate the interior product of Y and beta1.

 E3 > beta2 := Hook(Y, beta1);
 ${\mathrm{β2}}{≔}{3}$ (5.5)

Note that multiple interior products can also be evaluated with a single call to Hook.

 E3 > Hook([X, Y], alpha) = Hook(Y, Hook(X,alpha));
 ${3}{=}{3}$ (5.6)

DGzip, FrameBaseVectors, FrameBaseForms

DGzip is a handy command that gets used a lot.

 E3 > with(DifferentialGeometry): DGsetup([x, y, z], E3):

Create the 1-form 4dx + 5dy + 6dz.

 E3 > DGzip([4, 5, 6], [dx, dy, dz], "plus");
 ${4}{}{\mathrm{dx}}{+}{5}{}{\mathrm{dy}}{+}{6}{}{\mathrm{dz}}$ (6.1)

Create the 3-form dx^dy^dz.

 E3 > DGzip([dx, dy, dz], "wedge");
 ${\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dy}}{}{\mathrm{^}}{}{\mathrm{dz}}$ (6.2)

Create the tensor dx D_y dz.

 E3 > DGzip([dx, D_y, dz], "tensor");
 ${\mathrm{dx}}{}{\mathrm{D_y}}{}{\mathrm{dz}}$ (6.3)

The coordinate basis for the tangent and cotangent spaces can be obtained from the command DGinfo.

This command is often used in conjunction with DGzip.

 E3 > Fr := Tools:-DGinfo("FrameBaseVectors");
 ${\mathrm{Fr}}{≔}\left[{\mathrm{D_x}}{,}{\mathrm{D_y}}{,}{\mathrm{D_z}}\right]$ (6.4)
 E3 > Omega := Tools:-DGinfo("FrameBaseForms");
 ${\mathrm{Ω}}{≔}\left[{\mathrm{dx}}{,}{\mathrm{dy}}{,}{\mathrm{dz}}\right]$ (6.5)

Create the 1-form dx + 2dy + 3dz.

 E3 > alpha := DGzip([1, 2, 3], Fr, "plus");
 ${\mathrm{α}}{≔}{\mathrm{D_x}}{+}{2}{}{\mathrm{D_y}}{+}{3}{}{\mathrm{D_z}}$ (6.6)

&MatrixMinus, &MatrixPlus, &MatrixMult, &MatrixWedge

Use these commands for working with matrices of differential forms.  They are found in the Tools package.

 E3 > with(DifferentialGeometry): with(Tools):
 E3 > DGsetup([x, y, z], E3):

Define a matrix A of scalars.

 E3 > A := Matrix([[1, 2], [3, 4]]);
 ${A}{≔}\left[\begin{array}{rr}{1}& {2}\\ {3}& {4}\end{array}\right]$ (7.1)

Define a matrix Omega1 of 1-forms.

 E3 > Omega1 := Matrix([[dx, dy], [dz, dx]]);
 ${\mathrm{Ω1}}{≔}\left[\begin{array}{cc}{\mathrm{dx}}& {\mathrm{dy}}\\ {\mathrm{dz}}& {\mathrm{dx}}\end{array}\right]$ (7.2)

Scalar multiply the matrix of 1-forms Omega1 by 3.

 E3 > 3 &MatrixMult Omega1;
 $\left[\begin{array}{cc}{3}{}{\mathrm{dx}}& {3}{}{\mathrm{dy}}\\ {3}{}{\mathrm{dz}}& {3}{}{\mathrm{dx}}\end{array}\right]$ (7.3)

Matrix multiply the matrix of scalars A and the matrix of 1-forms Omega1.

 E3 > Omega2 := A &MatrixMult Omega1;
 ${\mathrm{Ω2}}{≔}\left[\begin{array}{cc}{\mathrm{dx}}{+}{2}{}{\mathrm{dz}}& {2}{}{\mathrm{dx}}{+}{\mathrm{dy}}\\ {3}{}{\mathrm{dx}}{+}{4}{}{\mathrm{dz}}& {4}{}{\mathrm{dx}}{+}{3}{}{\mathrm{dy}}\end{array}\right]$ (7.4)

Add the two matrices of 1-forms Omega1 and Omega2.

 E3 > Omega1 &MatrixPlus Omega2;
 $\left[\begin{array}{cc}{2}{}{\mathrm{dx}}{+}{2}{}{\mathrm{dz}}& {2}{}{\mathrm{dx}}{+}{2}{}{\mathrm{dy}}\\ {3}{}{\mathrm{dx}}{+}{5}{}{\mathrm{dz}}& {5}{}{\mathrm{dx}}{+}{3}{}{\mathrm{dy}}\end{array}\right]$ (7.5)

Matrix multiply the two matrices of 1-forms Omega1 and Omega2.

 E3 > Omega1 &MatrixWedge Omega1;
 $\left[\begin{array}{cc}{\mathrm{dy}}{}{\mathrm{^}}{}{\mathrm{dz}}& {0}{}{\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dy}}\\ {0}{}{\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dy}}& {-}{\mathrm{dy}}{}{\mathrm{^}}{}{\mathrm{dz}}\end{array}\right]$ (7.6)

DGzero, DGvolume

Use the command DGzero to create the zero vector, or the zero differential p-form.  Use the command DGvolume to create a differential n-form, where n is the dimension of the active coordinate system.  These commands are found in the Tools package.

 E3 > with(DifferentialGeometry): DGsetup([x, y, z], E3):

Create the zero vector.

 E3 > Tools:-DGzero("vector");
 ${0}{}{\mathrm{D_x}}$ (8.1)

Create the zero 2-form.

 E3 > Tools:-DGzero("form", 2);
 ${0}{}{\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dy}}$ (8.2)

Create the volume form with a coefficient of k.

 E3 > Tools:-DGvolume("form", k);
 ${k}{}{\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dy}}{}{\mathrm{^}}{}{\mathrm{dz}}$ (8.3)

DGvector, DGform

The commands DGvector and DGform provide an alternative way of defining the coordinate vector fields and differential 1-forms and are useful when writing new programs for differential geometry applications.  These commands are found in the Tools package.

 E3 > with(DifferentialGeometry): DGsetup([x, y, z], E3):

Create the vector D_x.

 E3 > Tools:-DGvector(1);
 ${\mathrm{D_x}}$ (9.1)

Create the vector D_y.

 E3 > Tools:-DGvector(y);
 ${\mathrm{D_y}}$ (9.2)

Create the 1-form dz.

 E3 > Tools:-DGform(z);
 ${\mathrm{dz}}$ (9.3)

convert/DGtensor, convert/DGArray

The DifferentialGeometry package provides a number of extensions to the Maple convert facility.

The convert/DGtensor command enables one to convert

 – a vector to a rank 1 covariant tensor;
 – a differential p-form to a rank p covariant tensor field;
 – a p-dimensional Maple Array to a rank p tensor field.

See DifferentialGeometry, Convert for details.

 > with(DifferentialGeometry):
 > DGsetup([x, y, z], E3);
 ${\mathrm{frame name: E3}}$ (10.1)

Define a differential 2-form omega and convert it to a tensor.

 E3 > omega := evalDG(dx &w dy - 3*dy &w dz);
 ${\mathrm{ω}}{≔}{\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dy}}{-}{3}{}{\mathrm{dy}}{}{\mathrm{^}}{}{\mathrm{dz}}$ (10.2)
 E3 > convert(omega, DGtensor);
 ${\mathrm{dx}}{}{\mathrm{dy}}{-}{\mathrm{dy}}{}{\mathrm{dx}}{-}{3}{}{\mathrm{dy}}{}{\mathrm{dz}}{+}{3}{}{\mathrm{dz}}{}{\mathrm{dy}}$ (10.3)

Define a 3-dimensional array A and convert it to a type (2, 1) tensor.

 E3 > A := Array(1..3, 1..3, 1..3);
 ${A}{≔}\left[\begin{array}{c}{\mathrm{1..3 x 1..3 x 1..3}}{\mathrm{Array}}\\ {\mathrm{Data Type:}}{\mathrm{anything}}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{Fortran_order}}\end{array}\right]$ (10.4)
 E3 > A[1, 2, 3] := 5;
 ${{A}}_{{1}{,}{2}{,}{3}}{≔}{5}$ (10.5)
 E3 > A[1, 1, 1] := -1;
 ${{A}}_{{1}{,}{1}{,}{1}}{≔}{-}{1}$ (10.6)

The last argument must specify the index type of the tensor being defined by the Array.

 E3 > T := convert(A, DGtensor, [["cov_bas", "cov_bas", "con_bas"], []]);
 ${T}{≔}{-}{\mathrm{dx}}{}{\mathrm{dx}}{}{\mathrm{D_x}}{+}{5}{}{\mathrm{dx}}{}{\mathrm{dy}}{}{\mathrm{D_z}}$ (10.7)

The command convert/DGArray will convert a tensor to an Array.

 E3 > B := convert(T, DGArray);
 ${B}{≔}\left[\begin{array}{c}{\mathrm{1..3 x 1..3 x 1..3}}{\mathrm{Array}}\\ {\mathrm{Data Type:}}{\mathrm{anything}}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{Fortran_order}}\end{array}\right]$ (10.8)
 E3 > B[1, 2, 3];
 ${5}$ (10.9)
 E3 > B[1, 1, 1];
 ${-}{1}$ (10.10)
 E3 > B[1, 2, 2];
 ${0}$ (10.11)

Copy and Paste DifferentialGeometry output

The results of a DifferentialGeometry computation are displayed in a format consistent with standard mathematical usage.  The displayed format for vector fields and differential 1-forms can be copied and pasted into other parts of the worksheet or even other worksheets and the result passed directly to the DifferentialGeometry parser evalDG.

Unfortunately, differential forms of higher degree and tensors cannot be copied and pasted without editing.  In this section, we describe some possible workarounds.

 E3 > with(DifferentialGeometry): DGsetup([x, y, z], M):
 M > alpha := evalDG(dx &w dy + (1/x) *dy &w dz);
 ${\mathrm{α}}{≔}{\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dy}}{+}\frac{{\mathrm{dy}}{}{\mathrm{^}}{}{\mathrm{dz}}}{{x}}$ (11.1)

Copy and paste this output here to see the problem.

 M > alpha := dx*^*dy+1/x*dy*^*dz:

To make this readable by evalDG, the string *^* must be replaced by &w.

To simplify this editing, we can use the Preferences program to change the way the wedge product is displayed.  With the WedgeDisplay value = 2, the wedge symbol is suppressed; with the WedgeDisplay value = 3, the wedge symbol is changed to &w.  In either case, the editing of the result of a copy and paste is slightly easier.

 M > Preferences("WedgeDisplay", 2);
 ${1}$ (11.2)
 M > alpha;
 ${\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dy}}{+}\frac{{\mathrm{dy}}{}{\mathrm{^}}{}{\mathrm{dz}}}{{x}}$ (11.3)

Copy and paste this line to get

 M > dx*dy+1/x*dy*dz;
 ${\mathrm{dx}}{}{\mathrm{dy}}{+}\frac{{\mathrm{dy}}{}{\mathrm{dz}}}{{x}}$ (11.4)

Here we need only replace the appropriate * by &w.

 M > Preferences("WedgeDisplay",3);
 ${2}$ (11.5)
 M > alpha;
 ${\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dy}}{+}\frac{{\mathrm{dy}}{}{\mathrm{^}}{}{\mathrm{dz}}}{{x}}$ (11.6)

Copy and paste this line to get

 M > dx* &w *dy+1/x*dy* &w *dz:

Here we need only remove the strings *.

Change the WedgeDisplay back to its default value.

Preferences("WedgeDisplay", 1);

Finally, another alternative is to use lprint to display the internal representation of the form alpha.  This can always be copied and pasted.

 M > lprint(alpha);
 _DG([["form", M, 1], [[[1], 1]]])*^*_DG([["form", M, 1], [[[2], 1]]])+1/x*_DG([["form", M, 1], [[[2], 1]]])*^*_DG([["form", M, 1], [[[3], 1]]])

Copy and paste this.

 M > beta := _DG([["form", M, 2], [[[1, 2], 1], [[2, 3], 1/x]]]);
 ${\mathrm{β}}{≔}{\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dy}}{+}\frac{{\mathrm{dy}}{}{\mathrm{^}}{}{\mathrm{dz}}}{{x}}$ (11.7)

Exercises

Exercise 1

Check, by example, that the inner product of a vector with a form is an anti-derivation.

Solution

 M > with(DifferentialGeometry): DGsetup([x, y, z], E3):

Define a vector.

 E3 > X := evalDG(D_x - 2*D_y + 3*D_z);
 ${X}{≔}{\mathrm{D_x}}{-}{2}{}{\mathrm{D_y}}{+}{3}{}{\mathrm{D_z}}$ (12.1.1.1)

Define a pair of 1-forms.

 E3 > alpha := evalDG(dx + 3*dy - 2*dz);
 ${\mathrm{α}}{≔}{\mathrm{dx}}{+}{3}{}{\mathrm{dy}}{-}{2}{}{\mathrm{dz}}$ (12.1.1.2)
 E3 > beta := evalDG(-dx + 4*dy + dz);
 ${\mathrm{β}}{≔}{-}{\mathrm{dx}}{+}{4}{}{\mathrm{dy}}{+}{\mathrm{dz}}$ (12.1.1.3)
 E3 > LHS := Hook(X, alpha &w beta);
 ${\mathrm{LHS}}{≔}{17}{}{\mathrm{dx}}{-}{26}{}{\mathrm{dy}}{-}{23}{}{\mathrm{dz}}$ (12.1.1.4)
 E3 > RHS := evalDG(Hook(X, alpha) &w beta - alpha &w Hook(X, beta));
 ${\mathrm{RHS}}{≔}{17}{}{\mathrm{dx}}{-}{26}{}{\mathrm{dy}}{-}{23}{}{\mathrm{dz}}$ (12.1.1.5)
 E3 > LHS &minus RHS;
 ${0}{}{\mathrm{dx}}$ (12.1.1.6)

Exercise 2

Write a program which takes an integer r for its input and returns the 2-form dx1^dx2 + dx3^dx4 + ..., where there are r summands.

Solution

 > with(DifferentialGeometry):
 > TwoForm1 := proc(r)
 > local n, ans, Omega, i;
 > n := min(r, iquo(Tools:-DGinfo("FrameBaseDimension"),2));
 > Omega := Tools:-DGinfo("FrameBaseForms");
 > evalDG(add(Omega[2*i-1] &wedge Omega[2*i], i = 1 .. n));
 > end:
 >
 > DGsetup([x1, x2, x3, x4, x5, x6], E6);
 ${\mathrm{frame name: E6}}$ (12.2.1.1)
 E6 > TwoForm1(2);
 ${\mathrm{dx1}}{}{\mathrm{^}}{}{\mathrm{dx2}}{+}{\mathrm{dx3}}{}{\mathrm{^}}{}{\mathrm{dx4}}$ (12.2.1.2)
 E6 > TwoForm1(3);
 ${\mathrm{dx1}}{}{\mathrm{^}}{}{\mathrm{dx2}}{+}{\mathrm{dx3}}{}{\mathrm{^}}{}{\mathrm{dx4}}{+}{\mathrm{dx5}}{}{\mathrm{^}}{}{\mathrm{dx6}}$ (12.2.1.3)

Exercise 3

Write a program which takes as input an n x n matrix A, where n is the dimension of the active coordinate system, and returns the 2-form dx^t A dx, where dx is a column vector of coordinate differentials.

Solution

 > with(DifferentialGeometry):
 >
 > TwoForm2:=proc(A)
 > local Omega1, Omega2, n, Fr, ans;
 > n := LinearAlgebra:-RowDimension(A);
 > Fr := DifferentialGeometry:-Tools:-DGinfo("FrameBaseForms");
 > Omega1 := Matrix(n, 1, Fr);
 > Omega2 := LinearAlgebra:-Transpose(Omega1);
 > use DifferentialGeometry:-Tools in
 > ans := Omega2 &MatrixWedge (A &MatrixMult Omega1);
 > end use;
 > ans[1,1]; end:
 >
 > DGsetup([x, y, z, w], E4);
 ${\mathrm{frame name: E4}}$ (12.3.1.1)
 E4 > A := Matrix([[0, 1, 2, 3],[-1, 0, 4, 5], [-2, -4, 0, 6], [-3, -5, -6, 0]]);
 ${A}{≔}\left[\begin{array}{rrrr}{0}& {1}& {2}& {3}\\ {-}{1}& {0}& {4}& {5}\\ {-}{2}& {-}{4}& {0}& {6}\\ {-}{3}& {-}{5}& {-}{6}& {0}\end{array}\right]$ (12.3.1.2)
 E4 > TwoForm2(A);
 ${2}{}{\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dy}}{+}{4}{}{\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dz}}{+}{6}{}{\mathrm{dx}}{}{\mathrm{^}}{}{\mathrm{dw}}{+}{8}{}{\mathrm{dy}}{}{\mathrm{^}}{}{\mathrm{dz}}{+}{10}{}{\mathrm{dy}}{}{\mathrm{^}}{}{\mathrm{dw}}{+}{12}{}{\mathrm{dz}}{}{\mathrm{^}}{}{\mathrm{dw}}$ (12.3.1.3)

Exercise 4

Write a program which will return a list of 2-forms which define a basis for the vector space of all 2-forms for a given manifold M.

Solution

 E4 > TwoFormBasis := proc(M)
 E4 > local n ,i, j, alpha, beta, Basis;
 E4 > n := DifferentialGeometry:-Tools:-DGinfo(M, "FrameBaseDimension");
 E4 > Basis := [];
 E4 > for i to n do
 E4 > alpha := DifferentialGeometry:-Tools:-DGform(i);
 E4 > for j from i + 1 to n do
 E4 > beta := DifferentialGeometry:-Tools:-DGform(j);
 E4 > Basis := [op(Basis), alpha &wedge beta];
 E4 > od;
 E4 > od;
 E4 > Basis;
 E4 > end:
 E4 >
 E4 > with(DifferentialGeometry):
 E6 > DGsetup([x1, x2, x3, x4], M);
 ${\mathrm{frame name: M}}$ (12.4.1.1)
 M > TwoFormBasis(M);
 ${\mathrm{TwoFormBasis}}{}\left({M}\right)$ (12.4.1.2)

It is very inefficient to define the Basis to be a list.  It is highly recommended that 1 dimensional Arrays be used in place of lists.  Thus,the above program becomes

 M > TwoFormBasis2 := proc(M)
 E4 > local n ,i, j, alpha, beta, Basis, k;
 E4 > n := DifferentialGeometry:-Tools:-DGinfo(M, "FrameBaseDimension");
 E4 > Basis := Array(1 .. n*(n - 1)/2):
 M > k := 0;
 E4 > for i to n do
 E4 > alpha := DifferentialGeometry:-Tools:-DGform(i);
 E4 > for j from i + 1 to n do
 M > k := k + 1;
 E4 > beta := DifferentialGeometry:-Tools:-DGform(j);
 E4 > Basis[k] := alpha &wedge beta;
 E4 > od;
 E4 > od;
 E4 > convert(Basis, list);
 M > end:
 M >
 M > TwoFormBasis2(M);
 $\left[{\mathrm{dx1}}{}{\mathrm{^}}{}{\mathrm{dx2}}{,}{\mathrm{dx1}}{}{\mathrm{^}}{}{\mathrm{dx3}}{,}{\mathrm{dx1}}{}{\mathrm{^}}{}{\mathrm{dx4}}{,}{\mathrm{dx2}}{}{\mathrm{^}}{}{\mathrm{dx3}}{,}{\mathrm{dx2}}{}{\mathrm{^}}{}{\mathrm{dx4}}{,}{\mathrm{dx3}}{}{\mathrm{^}}{}{\mathrm{dx4}}\right]$ (12.4.1.3)

Exercise 5

Let M be a manifold and recall that a type (1, 1) tensor T defined at a point p in M can be viewed as a linear transformation from T_pM to T_pM, that is, as an element of Hom(T_pM, T_pM).  Write a program that will compute the k-th power of a type (1, 1) tensor.

Hint: Use DGinfo to obtain the tensor type.

Solution

 M > TensorPower := proc(T, k)
 E4 > local IndexType, A, B, C;
 E4 > IndexType := DifferentialGeometry:-Tools:-DGinfo(T, "TensorType");
 M > A := convert(T, DGArray);
 M > B := convert(A, Matrix):
 M > C := B^k;
 M > convert(C,DGtensor, IndexType);
 M > end:
 M >
 M > with(DifferentialGeometry): with(Tensor): DGsetup([x, y, z], V):
 V > T1 := evalDG(dx &t D_y + 3*dy &t D_y - 2*dy &t D_z);
 ${\mathrm{T1}}{≔}{\mathrm{dx}}{}{\mathrm{D_y}}{+}{3}{}{\mathrm{dy}}{}{\mathrm{D_y}}{-}{2}{}{\mathrm{dy}}{}{\mathrm{D_z}}$ (12.5.1.1)
 V > TensorPower(T1, 3);
 ${9}{}{\mathrm{dx}}{}{\mathrm{D_y}}{-}{6}{}{\mathrm{dx}}{}{\mathrm{D_z}}{+}{27}{}{\mathrm{dy}}{}{\mathrm{D_y}}{-}{18}{}{\mathrm{dy}}{}{\mathrm{D_z}}$ (12.5.1.2)
 V > TensorPower(T1, 4);
 ${27}{}{\mathrm{dx}}{}{\mathrm{D_y}}{-}{18}{}{\mathrm{dx}}{}{\mathrm{D_z}}{+}{81}{}{\mathrm{dy}}{}{\mathrm{D_y}}{-}{54}{}{\mathrm{dy}}{}{\mathrm{D_z}}$ (12.5.1.3)