(* 

Example file for GREATER2.m; run this cell first, then the rest. If this doesn't work then you put the .m files in the wrong directory. 

Read the GREATER2.m file for more commands.

If you cannot put things in the Mathematica apps directory for some reason, uncomment the next line and point it to the location of your GREATER2.m file.

*)
(* PrependTo[$Path, ToFileName[{$HomeDirectory, "physics", "my-math-apps"}]]; *)
Needs["GREATER2`"];

(* define our coordinates *)
X = {t,r,ϕ};

(* define a line element for AdS3 *)
ds2 = -r^2 dt^2 + dr^2/r^2 + r^2 dϕ^2;
(* define the metric *)
(* Note: I like to use the tensor name to keep track of where the indices are.  Since the metric has two down indices, I end the name with "dd".  If I defined a tensor with two up indices and two down, I'd call it Xuudd *)
Gdd = Metric[ds2, X];
(* inverse metric *)
Guu = IMetric[Gdd];
Gdd//SMF

(*Compute the Ricci scalar *)
R = SCurvature[Gdd, X]

(*Define a vector field*)
ζu = {e[t-ϕ], 0,0};
(* Norm of ζ *)
ζu.Gdd.ζu//S
(*Take lie derivative of G along ζ; the {-1,-1} indicates we are taking the Lie derivative of a tensor with two lower indices *)
dGdd = LieD[ζu, Gdd, X, {-1,-1}];
(*Take the covariant derivative of ζ; the {1} indicates the ζ has one upper index *)
Ddζu = CoD[ζu, Gdd, X, {1}];

(*Display results nicely*)
dGdd//SMF
Ddζu//SMF

(* Change coordinate systems *)
X2 = {xplus, xminus, y};
trans12 = {xplus== t+ϕ, xminus == t - ϕ, y == 1/r};
(* last parameter specifies the index positions on Gdd *)
Gdd2 = ChangeCoords[Gdd, X, X2, trans12, {-1,-1}];
ζu2 = ChangeCoords[ζu, X, X2, trans12, {1}];
Gdd2//SMF
ζu2

(* Compute some tensor expressions *)
Vu = {v1,v2,v3};
Kdd = ExtrinsicCurvature[Gdd, 2, 1, X]//Simplify[#, r>0]&

(* TensorMath computes arbitrary tensor expressions written in Einstein summation convention *)
sometensor = TensorMath[Vu[[μ]](Kdd[[-μ,-ν]] + 3 f[x] Gdd[[-μ,-ν]]) ]
(* The next statement is equivalent, but writing things this way gets tricky when tensors have more than 2 indices *)
sometensor2 = Vu.Kdd + 3 f[x] Vu.Gdd
sometensor - sometensor2//S

(* Use ?functionname to see the definition of a function so you can see the required syntax *)

?Metric
?Riemann
?ExtrinsicCurvature

??Metric