5ce5316a33 2021-03-01 1: % calculation of metric tensor (3-dim space-time)
5ce5316a33 2021-03-01 2:
5ce5316a33 2021-03-01 3: off echo;
5ce5316a33 2021-03-01 4: on revpri;
5ce5316a33 2021-03-01 5:
5ce5316a33 2021-03-01 6: n:=3;
5ce5316a33 2021-03-01 7:
5ce5316a33 2021-03-01 8: operator x$
5ce5316a33 2021-03-01 9: x(0):=t; x(1):=lambda0; x(2):=lambda1;
5ce5316a33 2021-03-01 10:
5ce5316a33 2021-03-01 11: % rules
5ce5316a33 2021-03-01 12: trig1:={sin(~x)^2=>(1-cos(x)^2)}$ let trig1$
5ce5316a33 2021-03-01 13:
5ce5316a33 2021-03-01 14: % procedures
5ce5316a33 2021-03-01 15: procedure scalprod(a,b); begin
5ce5316a33 2021-03-01 16: integer n; n:=first(length(a))-1;
5ce5316a33 2021-03-01 17: result:=for i:=0:n-1 sum a(i)*b(i);
5ce5316a33 2021-03-01 18: return result end;
5ce5316a33 2021-03-01 19:
5ce5316a33 2021-03-01 20: procedure showmatrix(mm);begin integer m,n;l:=length(mm);m:=first(l)-1;n:=second(l)-1;matrix hm(m,n);for i:=0:m-1 do for j:=0:n-1 do hm(i+1,j+1):=mm(i,j); write hm end;
5ce5316a33 2021-03-01 21:
5ce5316a33 2021-03-01 22: procedure showvector(vv);begin scalar n;n:=first(length(vv))-1;matrix hv(n,1);for i:=0:n-1 do hv(i+1,1):=vv(i);write hv end;
5ce5316a33 2021-03-01 23:
5ce5316a33 2021-03-01 24: array f(n+1), dfdt(n+1), dfdl0(n+1), dfdl1(n+1)$
5ce5316a33 2021-03-01 25:
5ce5316a33 2021-03-01 26: % current radius
5ce5316a33 2021-03-01 27: a:=a0*sqrt(1-t^2);
5ce5316a33 2021-03-01 28:
5ce5316a33 2021-03-01 29: % surface of hyper sphere in t and lambda
5ce5316a33 2021-03-01 30:
5ce5316a33 2021-03-01 31: f(0):=a*cos(lambda0)*cos(lambda1);
5ce5316a33 2021-03-01 32: f(1):=a*cos(lambda0)*sin(lambda1);
5ce5316a33 2021-03-01 33: f(2):=a*sin(lambda0);
5ce5316a33 2021-03-01 34: f(3):=a0*t;
5ce5316a33 2021-03-01 35:
5ce5316a33 2021-03-01 36: for i:=0:n do dfdt(i):=df(f(i),x(0))$
5ce5316a33 2021-03-01 37: for i:=0:n do dfdl0(i):=df(f(i),x(1))$
5ce5316a33 2021-03-01 38: for i:=0:n do dfdl1(i):=df(f(i),x(2))$
5ce5316a33 2021-03-01 39:
5ce5316a33 2021-03-01 40: array g(n,n)$
5ce5316a33 2021-03-01 41:
5ce5316a33 2021-03-01 42: g(0,0):=scalprod(dfdt,dfdt)$
5ce5316a33 2021-03-01 43: g(0,1):=scalprod(dfdt,dfdl0)$
5ce5316a33 2021-03-01 44: g(0,2):=scalprod(dfdt,dfdl1)$
5ce5316a33 2021-03-01 45:
5ce5316a33 2021-03-01 46: g(1,0):=scalprod(dfdl0,dfdt)$
5ce5316a33 2021-03-01 47: g(1,1):=scalprod(dfdl0,dfdl0)$
5ce5316a33 2021-03-01 48: g(1,2):=scalprod(dfdl0,dfdl1)$
5ce5316a33 2021-03-01 49:
5ce5316a33 2021-03-01 50: g(2,0):=scalprod(dfdl1,dfdt)$
5ce5316a33 2021-03-01 51: g(2,1):=scalprod(dfdl1,dfdl0)$
5ce5316a33 2021-03-01 52: g(2,2):=scalprod(dfdl1,dfdl1)$
5ce5316a33 2021-03-01 53:
5ce5316a33 2021-03-01 54: write "f = "; showvector(f);
5ce5316a33 2021-03-01 55: write "df/dt = "; showvector(dfdt);
5ce5316a33 2021-03-01 56: write "g = "; showmatrix(g);
5ce5316a33 2021-03-01 57:
5ce5316a33 2021-03-01 58: off revpri;
5ce5316a33 2021-03-01 59: on echo;
5ce5316a33 2021-03-01 60: end;