Tensor calculations in Maple

General

If Maple is installed on a UNIX machine you can usually run it with the command “maple” and you can then type at the prompt “?tensors” or “?tensorsGR” for help on tensors.

The example below is taken from that help.

 

Example: the Schwarzschild metric

Prepare a file with the following text:

 

with(tensor);

 

# Define the coordinates

Coordinates := [t, r, theta, phi];

 

# the dimension of space-time

dim := nops(Coordinates);

 

# define the metric array

g:=array(symmetric, sparse, 1..dim, 1..dim);

 

# Set the nonzero components

# for example,

# here we have the Schwarzschild metric

g[1,1]:= -(1-2*M/r);

g[2,2]:= -1/g[1,1];

g[3,3]:= r^2;

g[4,4]:=r^2*sin(th)^2;

metric:=create([-1,-1],eval(g));

 

# Calculate all possible (!) tensors

# relevant for GR

tensorsGR(Coordinates,metric,

  MyInverseMetric, MyDetMetric,

  MyC1, MyChristoffel, MyRiemannTensor,

  MyRicciTensor, MyRicciScalar,

  MyEinsteinTensor, MyWeylTensor);

 

# Show the Einstein tensor in a nice way displayGR(Einstein, MyEinsteinTensor);

 

# Show the Christoffel symbols in a nice way

displayGR(Christoffel2, MyChristoffel);

 

# etc . . .

 

Save the file under some name, e.g. “MyTensors”

run Maple … and type in at the prompt

read MyTensors;