Computer algebra: GR with REDUCE

We will set up the Einstein field equations G_{ij}=R_{ij}-\tfrac{1}{2}g_{ij} R, with the Ricci tensor R_{ij}=R^{k}\, _{ikj} and scalar curvature R=R^i\, _i all computed from the Riemann tensor R_{ijk\ell}, which we construct from the metric g_{ij} and the Christofel symbols

    \[\Gamma^i\, _{jk}=\tfrac{1}{2}g^{i\ell}\Big(\partial_j g_{k\ell}+\partial_k g_{j\ell}-\partial_\ell g_{jk}\Big)\]

We will construct a spherically symmetric static metric with x(1)=t, x(2)=r, x(3)=\theta and x(4)=\phi using REDUCE’s “operator”, the generic indexed variable with dependencies. The metric g_{ij}=g(i,j) and g^{ij}=h(i,j) as well as the Riemann, Ricci, and Einstein tensors are all defined as operators.

    \[ds^2=e^A dt^2-e^B dr^2-r^2 d\theta^2-r^2\sin^2\theta d\phi^2\]

and we try to get the equations for A,B that will lead to the Schwartzchild solution

perator g,h,x,gamm,R,!G;
depend !A, x(2);
depend !B, x(2);
% lower-index metric
for n:=1:4 do for m:=1:4 do g(n,m):=0;
for n:=1:4 do for m:=1:4 do h(n,m):=0;
g(1,1):=e^!A; h(1,1):=1/g(1,1);
g(2,2):=-e^!B; h(2,2):=1/g(2,2);
g(3,3):=-x(2)^2; h(3,3):=1/g(3,3);
g(4,4):=-(x(2)*sin(x(3)))^2; h(4,4):=1/g(4,4);

First we compute the operators \Gamma^i\, _{jk}= gamma(i,j,k), the Christofel symbols. Lines in reduce end in ; if you want output printed, or in a dollar sign if you want output suppressed. WE suppress the output here because we don’t want all 64 symbols printed

% Christofel symbols
for i:=1:4 do for j:=1:4 do for k:=1:4 do 
   gamm(i,j,k):=for l:=1:4 sum (df(g(k,l),x(j))+df(g(j,l),x(k))
      -df(g(j,k),x(l)))*h(i,l)/2$

Next we compute the Riemann tensor, Ricci tensor, and scalar curvature

% Riemann, first upper, rest lower index
for a:=1:4 do for b:=1:4 do for c:=1:4 do for d:=1:4 do
   R(a,b,c,d):=df(gamm(a,d,b),x(c))-df(gamm(a,c,b),x(d))
      +for m:=1:4 sum (gamm(m,d,b)*gamm(a,c,m)-gamm(m,c,b)*gamm(a,m,d))$
% Ricci tensor, lower indices
operator ricci;
for i:=1:4 do for j:=1:4 do ricci(i,j):=for k:=1:4  sum R(k,i,k,j)$
% scalar curvature
operator sc;
sc:=for i:=1:4 sum for j:=1:4 sum h(i,j)*ricci(i,j)$

Finally we build the Einstein tensor…

% Einstein, all lower indices
for i:=1:4 do for j:=1:4 do !G(i,j):=ricci(i,j)-(1/2)*g(i,j)*sc$

We have suppressed printing all along, now we load the rlfi package and use it to print the components of R_{ij} but remember our labels are 1\sim t, 2\sim r, 3\sim\theta, 4\sim \phi

load_package rlfi$   % load LaTeX package
on latex$            % switch on LaTeX output
operator !R$ defindex !R(down,down,arg)$ defid !R,name=!R$  % so we can print math
operator !x$ defindex !x(down,arg)$ defid !x,name=!x$
!R(1,1)=ricci(2,2);
!R(0,0)=ricci(1,1);
!R(2,2)=ricci(3,3);
!R(3,3)=ricci(4,4);

This is what it looks like, a little cleanup is needed

    \[R_{00}=\]

    \[\left(2 e^{A} \frac{{\rm d}^{2}A}{({\rm d}x_{2})^{2}} x_{2}+e^{A}  \left(\frac{{\rm d}\,A}{{\rm d}\,x_{2}}\right)^{2} x_{2}-e^{A} \frac{{\rm d}\, A}{{\rm d}\,x_{2}} \frac{{\rm d}\,B}{{\rm d}\,x_{2}} x_{2}+4 e^{A} \frac{ {\rm d}\,A}{{\rm d}\,x_{2}}\right)/\left(4 e^{B} x_{2}\right)\]

    \[R_{11}=\left(-2 \frac{{\rm d}^{2}A}{({\rm d}x_{2})^{2}} x_{2}-\left(\frac{ {\rm d}\,A}{{\rm d}\,x_{2}}\right)^{2} x_{2}+\frac{{\rm d}\,A}{{\rm d}\,x_{2}}  \frac{{\rm d}\,B}{{\rm d}\,x_{2}} x_{2}+4 \frac{{\rm d}\,B}{{\rm d}\,x_{2}} \right)/\left(4 x_{2}\right)\]

    \[R_{22}=\left(-\frac{{\rm d}\,A}{{\rm d}\,x_{2}} x_{2}+\frac{{\rm d}\,B}{ {\rm d}\,x_{2}} x_{2}+2 e^{B}-2\right)/\left(2 e^{B}\right)\]

    \[R_{33}=\]

    \[\left(-\frac{{\rm d}\,A}{{\rm d}\,x_{2}} \sin ^{2}\left(x_{3}\right) x_ {2}+\frac{{\rm d}\,B}{{\rm d}\,x_{2}} \sin ^{2}\left(x_{3}\right) x_{2}+2 e^{B } \sin ^{2}\left(x_{3}\right)-2 \sin ^{2}\left(x_{3}\right)\right)/\left(2 e^{ B}\right)\]

Home 2.0
error: Content is protected !!