################################################################### # # Riemann package: # # - Tools to manipulate tensor components # - Applications to General Relativity Theory # - Some symbolic manipulation tools # # # Authors: Renato Portugal (portugal@cat.cpbf.br) # Sandra L. Sautu (sautu@lca1.drp.cbpf.br) # # Address: Centro Brasileiro de Pesquisas Fisicas # Rua Dr. Xavier Sigaud 150 # 22290-180, Urca, Rio de Janeiro, RJ # BRASIL # # Version 1.4 - Aug 18, 1997 # # Maple Release V.4 # # INSTALLATION INSTRUCTIONS (in three steps): # # The Riemann package is distributed freely. The program source, the # help and some example worksheets are available . After copying the # program source, one can create a compiled version as explained. The # necessary informations are given bellow: # # First step: copy the package using one of the following addresses # (using netscape, mosaic, anonymous ftp or equivalent): # # http://www.cbpf.br/~portugal/Riemann.html # ftp://lca1.drp.cbpf.br/pub/Riemann/maplev4 # http://daisy.uwaterloo.ca:80/~rportuga/Riemann.htm # # Put all files in a directory which we are calling /XXX here. # # Second step: Enter in Maple and give the following commands: # > read(`/XXX/Riemann`); # to read the source file # # [acomp, amap, antisymmetrize, apply, bintnames, calc, clear, # # clearbint, clearcomp, cleartensor, codiff, comp, complist, # # coordinates, dalembertian, definetensor, entertensor, evalt, init, # # invariants, ivierbein, lptensor, ltensor, metric, metricV, off, # # on, path, petrov, printtensor, readmetric, readtensor, # # readvierbein, savemetric, savetensor, savevierbein, show, simpfcn, # # sumt, switches, symmetrize, tdiff, tmap, vierbein, viertocoord] # # > save(`/XXX/Riemann.m`); # to create a compiled version # # Third step: If you have succeded in the second step, from now on it is # advisable to load the package using the following commands: # > libname:=libname,`/XXX`; # # libname := /soft/maple5.4/distrib/lib, /XXX # # The output of the last command in your machine will be different from # the above output, but it must contain the /XXX directory. The next # command is: # > with(Riemann); # # [acomp, amap, antisymmetrize, apply, bintnames, calc, clear, # # clearbint, clearcomp, cleartensor, codiff, comp, complist, # # coordinates, dalembertian, definetensor, entertensor, evalt, init, # # invariants, ivierbein, lptensor, ltensor, metric, metricV, off, # # on, path, petrov, printtensor, readmetric, readtensor, # # readvierbein, savemetric, savetensor, savevierbein, show, simpfcn, # # sumt, switches, symmetrize, tdiff, tmap, vierbein, viertocoord] # # Try some help command: # > ?riemann # > ?definetensor # > ?evalt # # Possible problems: If you have received the message: # *** Error, (in with) undefined package , Riemann # after loading the package then there are two possibilities. Either # Riemann.m file is not in the directory /XXX or the variable libname # has not been setup properly. In the first case you must redo the # second step paying attention to the file paths. In the second case you # should verify if the value of the variable libname is the correct one. # Verify if the name Riemann has been spelled correctly with capital # letter. Restart the session and try again. # # If you have received the message: Coud not find any help on ''topic'' # then verify if the file maple.hdb is in the directory /XXX. If it is # there then verify if the variable libname is the correct one. Maple # can find the Riemann help worksheets only by way of the variable # libname. # # # Hint: One can avoid to setup every time the variable libname by # putting this information in the maple initialization file (see ?maple # and ?libname). For unix users: the initialization file is called # .mapleinit and stays in the home directory. One should edit it and add # the line: libname := libname, `/XXX`:. # # # `index/Riemann/calc_RicciV` := proc (ind, T) local i, j, m, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): if type(j,contravariantindex) then if `Riemann/eta_is_diag` then s := tensor.MetricVName.2[j,j]*procname([i, -j],T) else s := 0: for m to Dimension do tensor.MetricVName.2[j,m]: if ('"') <> 0 then s := s+('"')*procname([i, -m],T) fi od fi elif type(i,contravariantindex) then if `Riemann/eta_is_diag` then if i < -j then s := tensor.MetricVName.2[i, i]*procname([-i, j],T) else s := tensor.MetricVName.2[i,i]*procname([j, -i],T) fi else s := 0: for m to Dimension do tensor.MetricVName.2[i,m]: if ('"') <> 0 then if m < -j then s := s+('"')*procname([-m, j],T) else s := s+('"')* procname([j, -m],T) fi fi od fi else s := RicciVSign*add(tensor.RiemannVName.4 [m,i,j,-m],m = 1 .. Dimension) fi: T[i,j] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/latex` := false: `index/Riemann/calc_SWV` := proc (ind, T) local i, j, m, n, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): s := 0: for m to Dimension do tensor.TclRicciVName. 2[m,m]: if ('"') <> 0 then s := s+tensor.WeylVName.4[i,-m,-m,j]*('"') fi: for n from m+1 to Dimension do tensor.TclRicciVName.2[m,n]: if ('"') <> 0 then s := s+('"')*(tensor.WeylVName.4[i,-m,-n,j]+tensor.WeylVName.4[i,-n,-m,j]) fi od od: T[op(ind)] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_RicciSqV` := proc (ind, T) local i, j, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension do tensor.RicciVName.2[-i,-i]: if ('"') <> 0 then s := s+('"')*tensor.RicciVName. 2[i,i] fi: for j from i+1 to Dimension do tensor.RicciVName.2[-i,-j]: if ('"') <> 0 then s := s+2*('"')*tensor.RicciVName.2[i,j] fi od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/greek_alphabet` := {gamma, eta, mu, nu, xi, pi, rho, tau, phi, chi, psi, alpha, beta, delta, zeta, epsilon, theta, iota, kappa, lambda, omicron, sigma, upsilon, omega}: `Riemann/apply/Riemann` := proc (A, ind1, ind2, firstindex, p_name) local i, j , k, l, t, l1, l2, l3, l4: option `Copyright 1995 by Renato Portugal`: l1 := op(1,ind1): l2 := op(2,ind1): l3 := op(3,ind1): l4 := op(4,ind1): for i to Dimension-1 do for j from i+1 to Dimension do for k from i to Dimension-1 do if k = i then t := j else t := k+1 fi: for l from t to Dimension do `Riemann/apply/`.p_name(subs({l1 = i, l2 = j, l4 = l, l3 = k},'A'),ind2,[],1,' nosymm',args[6 .. nargs]) od od od od end: `Riemann/v_is_active` := false: `Riemann/iv` := true: `Riemann/order` := proc (ii, jj) local i, j: options remember, system, `Copyright 1997 by R. Portugal. All rights reserved.`: i := `Riemann/sink`(ii) : j := `Riemann/sink`(jj): if hastype([i, j],nameindex) then if type(i, covariantindex) and type(j,contravariantindex) then 'false' elif type(i, contravariantindex) and type(j,covariantindex) then 'true' else evalb([i, j] = sort([i, j])) fi elif 0 < i*j then evalb(abs(i) <= abs(j)) else evalb(j <= i) fi end: `index/Riemann/calc_detMetricVName1` := proc (ind, T) local M, i, j: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else M := array(1 .. Dimension,1 .. Dimension,'symmetric',[]): for i to Dimension do for j from i to Dimension do M[i,j] := tensor.MetricVName1.2[-i,-j] od od: T[] := `Riemann/simp_function`( linalg[det](M)) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_m2rV` := proc (ind, T) local s, i, j: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension do s := s+1/16*tensor.SWVName.2[-i,-i]*tensor.SWVName.2[i,i]-1/16*tensor. SWStarVName.2[-i,-i]*tensor.SWStarVName.2[i,i]: for j from i+1 to Dimension do s := s+1/8*tensor.SWVName.2[-i,-j]*tensor.SWVName.2[i,j]-1/8*tensor. SWStarVName.2[-i,-j]*tensor.SWStarVName.2[i,j] od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/summedindices` := proc (expr) {`Riemann/summedindices1`(expr)} end: `Riemann/seq/Riemann` := proc (expr, ind1, ind2, firstindex, p_name) local i, j, k, l, t, l1, l2, l3, l4, s: option `Copyright 1995 by Renato Portugal`: l1 := op(1,ind1): l2 := op(2,ind1): l3 := op(3,ind1): l4 := op(4,ind1): s := NULL : for i to Dimension-1 do for j from i+1 to Dimension do for k from i to Dimension-1 do if k = i then t := j else t := k+1 fi: for l from t to Dimension do s := s, `Riemann/seq/`.p_name(subs({l1 = i, l2 = j, l4 = l, l3 = k},'expr'),ind2,[],1,'nosymm') od od od od end: `Riemann/Riemann_order` := proc (i, j, k, l, seq_ind) options remember, system , `Copyright 1995 by Renato Portugal`: if nargs = 2 then if hastype([i, j],' string') then if type(i,covariantindex) and type(j,contravariantindex) then false else true fi elif 0 < i*j then evalb(abs(i) <= abs(j)) else evalb(j <= i ) fi elif type(i,nameindex) and i = -j then 0 elif procname(i,j) then if type( k,nameindex) and k = -l then 0 elif procname(k,l) then if type(j, covariantindex) and (type([k, l],list(contravariantindex)) or type(i, covariantindex) and type(k,contravariantindex)) then seq_ind := k, l, i, j else if hastype([i, j, k, l],'string') then seq_ind := i, j, k, l elif j*l < 0 or i = k and procname(j,l) or i <> k and procname(i,k) then seq_ind := i, j, k , l else seq_ind := k, l, i, j fi fi: 1 else -procname(i,j,l,k,seq_ind) fi else -procname(j,i,k,l,seq_ind) fi end: `Riemann/lptensor` := false: `index/Riemann/calc_m1r` := proc (ind, T) local s, i, j: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension do tensor.TclRicciName.2[i,i]: if ('"') <> 0 then s := s+1/8*('"')*tensor.SWName. 2[-i,-i] fi: for j from i+1 to Dimension do tensor.TclRicciName.2[i,j]: if ('" ') <> 0 then s := s+1/4*('"')*tensor.SWName.2[-i,-j] fi od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: latextensor := proc (x) global `latex/print`, `Riemann/latex/print`: option `Copyright 1995 by Renato Portugal`: if assigned(`Riemann/latex/print`) then readlib(latex): `latex/print` := eval(`Riemann/latex/print`): `Riemann/latex/print` := '`Riemann/latex/print`' fi: eval(subs(`t*e*n*s*o*r` = `l*a*t*e*x`,printtensor(x))): latex(") end: `index/Riemann/calc_WeylSqV` := proc (ind, T) local s, i, j, k, l, t: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension-1 do for j from i+1 to Dimension do for k from i to Dimension-1 do if k = i then t := j else t := k+1 fi: for l from t to Dimension do tensor.WeylVName.4[-i,-j,- k,-l]: if ('"') <> 0 then if i = k and j = l then s := s+4*tensor.WeylVName.4[ i,j,k,l]*('"') else s := s+8*tensor.WeylVName.4[i,j,k,l]*('"') fi fi od od od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end : `index/Riemann/calc_WWV` := proc (ind, T) local i, j, k, l, m, n, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): k := op(3,ind): l := op(4,ind): s := 0: for m to Dimension do for n from m+1 to Dimension do tensor.WeylVName.4[i,j,-m,-n]: if ('"') <> 0 then s := s+2*tensor.WeylVName.4[m,n,k,l]*('"') fi od od: T[op(ind) ] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_in_coord` := proc (ind, T) local k, s, m, kind, SN, kSN, nind: option `Copyright 1995 by Renato Portugal`: if nargs = 2 then if assigned(T[op(ind)]) or hastype(ind,'string') or ind <> [] and ind[1] = 0 then eval(T[op(ind)]) else nind := nops(ind): SN := T[0,4]: for k from nind by -1 to 1 while op(k,SN) = proc (x) if type(x,contravariantindex) then 1 else -1 fi end(op(k,ind)) do od: if k = 0 then if assigned(T[0,3]) then T[op(ind)] := `Riemann/simp_function`(T[0,3](op(ind))) else eval(T[op(ind)]) fi else s := 0: kSN := op(k,SN): kind := op(k,ind): for m to Dimension do tensor.MetricName.2[ kind,-kSN*m]: if ('"') <> 0 then s := s+('"')*eval(tensor.(T[0,1]).nind[op( subsop(k = kSN*m,ind))]) fi od: T[op(ind)] := `Riemann/simp_function`(s) fi fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_RieSq` := proc (ind, T) local s, i, j, k, l, t: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension-1 do for j from i+1 to Dimension do for k from i to Dimension-1 do if k = i then t := j else t := k+1 fi: for l from t to Dimension do tensor.RiemannName.4[-i,-j ,-k,-l]: if ('"') <> 0 then if i = k and j = l then s := s+4*tensor. RiemannName.4[i,j,k,l]*('"') else s := s+8*tensor.RiemannName.4[i,j,k,l]*('"') fi fi od od od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op( args[3]) fi end: `Riemann/for/diagonal` := proc (A, B, ind1, ind2, atrib, firstindex, p_name) local i, Lind1: option `Copyright 1995 by Renato Portugal`: if ind1 = [] then `Riemann/for/`.p_name(A,B,ind2,[],atrib,1,'nosymm') else for i to Dimension do Lind1 := map(proc (x, i) x = i end,ind1,i): procname(subs(Lind1,'A'),subs( Lind1,B),[],ind2,atrib,1,p_name) od fi end: `Riemann/_` := proc (expr) global _: option `Copyright 1995 by Renato Portugal`: if type(expr,`=`) then _ := op(1,expr) else _ := expr fi: NULL end: `index/Riemann/calc_m2I` := proc (ind, T) local s, i, j: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension do tensor.SWName.2[-i,-i]: if ('"') <> 0 then s := s+1/8*('"')*tensor.SWStarName. 2[i,i] fi: for j from i+1 to Dimension do tensor.SWName.2[-i,-j]: if ('"') <> 0 then s := s+1/4*('"')*tensor.SWStarName.2[i,j] fi od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_r3V` := proc (ind, T) local i, j, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension do tensor.SSVName.2[-i,-i]: if ('"') <> 0 then s := s+1/16*('"')*tensor.SSVName.2 [i,i] fi: for j from i+1 to Dimension do tensor.SSVName.2[-i,-j]: if ('"') <> 0 then s := s+1/8*('"')*tensor.SSVName.2[i,j] fi od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `type/numerictensor` := proc (x) options remember, system, `Copyright 1997 by R. Portugal. All right reserved.`: type(x,tensor) and evalb (map(op,[op(1 .. 2,`Riemann/indices`)]) = []) end: `Riemann/seq/diagonal` := proc (expr, ind1, ind2, firstindex, p_name) local i: option `Copyright 1995 by Renato Portugal`: if ind1 = [] then `Riemann/seq/`. p_name(expr,ind2,[],1,'nosymm') else map(proc (x, j) x = j end,ind1,i): seq( procname(subs(",'expr'),[],ind2,1,p_name),i = 1 .. Dimension) fi end: `type/nameindex` := proc (x) options remember, system, `Copyright 1995 by Renato Portugal`: not type(x,numericindex) and (type(x,' string') or type(-x,'string')) end: `Riemann/emerge` := proc (expr) local g: option `Copyright 1995 by Renato Portugal`: if `Riemann/CoordIndices` then g := proc (x) if type(x,integer) then tensor.CoordinateName.1[0,0,3][x] else x fi end: map(g,expr) elif `Riemann/ZeroIndex` then g := proc (x) if type(x,numericindex ) then if x = 1 then O elif x = -1 then -O elif type(x,posint) then x-1 elif type(x,negint) then x+1 else x fi else x fi end: map(g,expr) else expr fi end: `index/Riemann/symm_Riemann` := proc (ind, T) local seq_ind: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if ind[1] = 0 then if nargs = 2 then T[op(ind)] else T[op(ind)] := op(args[3]) fi elif op(1,ind) = op(2,ind) or op(3,ind) = op(4,ind) then if nargs = 2 then 0 else if op(args[3]) = 0 then T[op(ind)] := 0 else ERROR( `cannot assign non-zero to equal antisymmetric indices`) fi fi else `Riemann/Riemann_order`(op(ind),seq_ind): if nargs = 2 then ('"')*T[seq_ind] elif hastype(ind,'string') then ERROR( `cannot assign to non numeric components`) else T[seq_ind] := ('"')*op(args[3] ) fi fi end: `Riemann/codiff/expand` := proc (expr, x) local ind, ind3, ind4, S, S1, T1, ind0, ind2, x2, b, j, i, T0: global ChristoffelName, CodiffSumIndex: option `Copyright 1997 by R. Portugal. All rights reserved.`: ind4 := op(4, `Riemann/indices`(expr)): if ind4 = [] then `Riemann/codiff/symb`(expr,x) elif type(expr,'indexed') then T1 := `Riemann/codiff/numer`(expr,S): subs(S, `Riemann/codiff/symb`(T1,x)) elif type(expr,'function') then T1 := expr: ind0 := NULL: ind2 := NULL: S := NULL: for i while type(T1,'function') do T0 := op( 0,T1): if T0 = ('tdiff') or T0 = ('codiff') or T0 = ('Codiff') then ind0 := T0 , ind0: x2 := op(2,T1): if type(op(x2),numericindex) then b := readlib( `tools/gensym`)(evaln(b.i)): S := S, b = op(x2): ind2 := op(0,x2)[b], ind2 else ind2 := x2, ind2 fi: T1 := op(1,T1) else RETURN('codiff'(expr,x)) fi od: if not type(T1,'indexed') then ERROR( `wrong type of argument in nested derivative`) fi: T1 := `Riemann/codiff/numer`(T1,S1): ind := op(T1): for j to i-1 do T1 := eval(subs( ('a') = op(j,[ind0]),''a'')(T1,op(j,[ind2]))) od: subs({S, op(S1)}, `Riemann/codiff/symb`(T1,x)) else ERROR( `first argument has a type not expected`) fi end: `index/Riemann/calc_PermSymbol` := proc (ind, T) local i, A: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] elif not ( type(ind,list(contravariantnumericindex)) or type(ind,list( covariantnumericindex))) then ERROR( `all indices of the permutation symbol must be of same type`) else A := table( 'antisymmetric',[seq(i,i = 1 .. nops(ind)) = 1]): T[op(ind)] := A[op(map( `Riemann/abs`,ind))] fi else T[op(ind)] := op(args[3]) fi end: `type/numericindex` := proc (x) options remember, system, `Copyright 1995 by Renato Portugal`: if `Riemann/CoordIndices` and assigned( tensor.CoordinateName.1[0,0,1]) and (member(x,tensor.CoordinateName.1[0,0,1]) or member(-x,tensor.CoordinateName.1[0,0,1])) then true elif `Riemann/ZeroIndex` and (x = ('O') or x = -('O')) then true elif not type(x, integer) then false elif x < -Dimension or Dimension < x then ERROR( `index outside Dimension`) elif x = 0 then if `Riemann/ZeroIndex` then ERROR( `use the letter O instead of zero`) else ERROR( `zero cannot be used as index when ZeroIndex is turned off`) fi else true fi end: `Riemann/dalembertian/algebraic` := proc (expr) local u, v, i: option `Copyright 1997 by R. Portugal. All rights reserved.`: if type(expr,'constant' ) then 0 elif type(expr,tensor) then 'dalembertian'(args) elif type(expr,'name ') then if assigned(tensor.CoordinateName.1[0,0,2]) and member(expr,tensor. CoordinateName.1[0,0,1]) then 'dalembertian'(CoordinateName[subs(tensor. CoordinateName.1[0,0,2],expr)]) else 0 fi elif type(expr,`+`) then map( procname,expr) elif type(expr,`*`) then u := op(1,expr): v := expr/u: procname (u)*v+u*procname(v) elif type(expr,tensor^anything) then ERROR( `power of tensor not expected`) else 'dalembertian'(args) fi end: `Riemann/tdiff/algebraic` := proc (expr, x) local u, v, i, p, T1, ind, ind2, j : option `Copyright 1997 by R. Portugal. All rights reserved.`: if type(expr, constanttensor) then if nops(expr) = 1 and op(0,expr) = CoordinateName then if type(x,'string') then if assigned(tensor.CoordinateName.1[0,0,1]) and member(x ,tensor.CoordinateName.1[0,0,1]) then procname(expr,CoordinateName[subs(tensor.CoordinateName.1[0,0,2],x)]) else 'tdiff'(args) fi elif type({op(expr), op(x)},set( numericindex)) then if expr = x then 1 else 0 fi elif assigned(MetricName) then MetricName[op(expr),-op(x)] else 'tdiff'(args) fi elif nops(expr) = 2 and op(0,expr) = MetricName and not type(expr,covarianttensor) and not type(expr, contravarianttensor) then 0 else 'tdiff'(args) fi elif type(expr,`+`) then map (procname,expr,x) elif type(expr,`*`) then u := op(1,expr): v := expr/u: procname(u,x)*v+u*procname(v,x) elif type(expr,tensor^anything) then ERROR( `power of tensor not expected`) elif type(expr,'function') and op(0,expr) = (' tdiff') then if type(x,'string') then v := op(2,expr): if type(v,'string') then if [v, x] = sort([v, x]) then 'tdiff'(args) else 'tdiff'(tdiff(op(1,expr) ,x),v) fi elif op(0,op(1,expr)) = CoordinateName then 0 else u := `Riemann/codiff/genindex`([op(`Riemann/abs`(op(3,`Riemann/indices`('tdiff'( args))))), 'a']): tdiff(CoordinateName[u],x)*tdiff(expr,CoordinateName[u]) fi else if type(op(2,expr),'string') then 'tdiff'(args) else ind := [op(op(2,expr )), op(x)]: if ind = sort(ind) then 'tdiff'(args) else 'tdiff'(tdiff(op(1,expr ),x),op(2,expr)) fi fi fi elif type(expr,'name') then if assigned(tensor. CoordinateName.1[0,0,2]) and member(expr,tensor.CoordinateName.1[0,0,1]) then tdiff(CoordinateName[subs(tensor.CoordinateName.1[0,0,2],expr)],x) else 0 fi elif not hastype(expr,constanttensor) and type(x,'string') then diff(expr,x) elif hastype(expr,constanttensor) or assigned(tensor.CoordinateName.1[0,0,1]) and `intersect`(indets(expr,'string'),tensor.CoordinateName.1[0,0,1]) <> {} then 'tdiff'(args) elif type(x,'string') then diff(args) else 0 fi end: `index/Riemann/calc_RicciScalar` := proc (ind, T) local i, m, n, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else if `Riemann/g_is_diag` then s := sum('tensor.MetricName.2[i,i]*tensor.RicciName.2[-i,-i]',('i') = 1 .. Dimension) else s := 0: for m to Dimension do tensor.MetricName.2[m,m]: if ('" ') <> 0 then s := s+('"')*tensor.RicciName.2[-m,-m] fi: for n from m+1 to Dimension do tensor.MetricName.2[m,n]: if ('"') <> 0 then s := s+2*('"')* tensor.RicciName.2[-m,-n] fi od od fi: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/forbiddenindices` := {}: `index/Riemann/calc_w1IV` := proc (ind, T) local s, i, j, k, l, t: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension-1 do for j from i+1 to Dimension do for k from i to Dimension-1 do if k = i then t := j else t := k+1 fi: for l from t to Dimension do tensor.WeylStarVName.4[-i, -j,-k,-l]: if ('"') <> 0 then if i = k and j = l then s := s+1/2*tensor. WeylVName.4[i,j,k,l]*('"') else s := s+tensor.WeylVName.4[i,j,k,l]*('"') fi fi od od od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3 ]) fi end: `index/Riemann/calc_m2r` := proc (ind, T) local s, i, j: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension do s := s+1/16*tensor.SWName.2[-i,-i]*tensor.SWName.2[i,i]-1/16*tensor.SWStarName.2 [-i,-i]*tensor.SWStarName.2[i,i]: for j from i+1 to Dimension do s := s+1/8* tensor.SWName.2[-i,-j]*tensor.SWName.2[i,j]-1/8*tensor.SWStarName.2[-i,-j]* tensor.SWStarName.2[i,j] od od: T[] := `Riemann/simp_function`(s) fi else T[op (ind)] := op(args[3]) fi end: `type/covariantindex` := proc (x) options remember, system, `Copyright 1995 by Renato Portugal`: type(-x,{name, contravariantnumericindex} ) end: `l*a*t*e*x` := proc (x) option `Copyright 1995 by Renato Portugal`: proc (x) if `Riemann/ZeroIndex` then if x = O then RETURN(`\\mbox{}`^`0`) elif x = -O then RETURN(`\\mbox{}`[`0`]) fi fi: if x = 1 then `\\mbox{}^1` elif x = -1 then `\\mbox{}_1` elif type(x,contravariantindex) then `\\mbox{}^`.x elif type (x,covariantindex) then `\\mbox{}_`.(-x) else ERROR(x, `is not an index of correct type`) fi end: if type(x,'indexed') then map(",[op (x)]): cat(`t*e*n*s*o*r`,readlib('`tools/gensym`')(op(0,x)),op(")) elif type(x ,'function') then map(",[op(op(0,x))]): cat(`t*e*n*s*o*r`,readlib(' `tools/gensym`')(op(0,op(0,x))),op("))(op(map(procname,[op(x)]))) else x fi end: `index/Riemann/calc_LevCiv` := proc (ind, T) local i, k, s, p, z, ind1, n: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned(T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else n := nops(ind): if n <> Dimension then ERROR( `The number of indices of LevCiv must be equal to Dimension`) fi: if type(op(1 ,ind),contravariantindex) then s := 1/sqrt(-tensordet.MetricName.0[],symbolic) else for i to n while type(op(i,ind),covariantindex) do od: if i = n+1 then s := -sqrt(-tensordet.MetricName.0[],symbolic) else k := op(i-1,ind): p := `Riemann/gtableasymm`[op(subsop(i-1 = -k,ind))]: if p = 0 then s := 0 else if type(p,`*`) then z := -1: ind1 := [op(-p)] else z := 1: ind1 := [op(p)] fi: s := z*tensor.MetricName.2[k,k]*procname(ind1,T) fi fi fi: T[op(ind)] := `Riemann/simp_function`(LeviCivitaSign*s) fi else T[op(ind)] := op(args[3]) fi end: Riemann := table([(path)=proc (n, x) local _path: global `Riemann/tensor_path` , `Riemann/metric_path`, `Riemann/vierbein_path`: option `Copyright 1995 by Renato Portugal`: if nargs = 0 then if assigned( `Riemann/tensor_path`) then lprint(`path to save/read tensors: `. `Riemann/tensor_path`) else lprint(`path to save/read tensors: `. `current dir`) fi: if assigned(`Riemann/metric_path`) then lprint( `path to save/read metrics: `.`Riemann/metric_path`) else lprint( `path to save/read metrics: `.`current dir`) fi: if assigned( `Riemann/vierbein_path`) then lprint(`path to save/read vierbeins: `. `Riemann/vierbein_path`) else lprint(`path to save/read vierbeins: `. `current dir`) fi elif nargs = 1 then `Riemann/tensor_path` := n: `Riemann/metric_path` := n: `Riemann/vierbein_path` := n elif nargs = 2 then if member(x,'{tensor, metric, vierbein}') then `Riemann/`.x._path := n else ERROR(`2nd argument must be the name metric, vierbein or tensor`) fi else ERROR(`wrong number of arguments`) fi: NULL end,(calc)=proc (expr1, arg2) local expr, N, ind, tensorname, A, B, AA, BB, z, dt, T: global `Riemann/DisplayTensor`, `Riemann/DEFINED`: option `Copyright 1995 by Renato Portugal`: expr := `Riemann/ltensor/ltensor`(expr1): if type(expr,constanttensor) then z := true: if nargs = 2 then if arg2 = (' noiv') then z := false else ERROR(`2nd argument must be the name noiv`) fi fi: tensorname := `Riemann/tensorname`(expr,N): T := tensor.tensorname.N: if not assigned(T[0,1]) then ERROR(`use definetensor to define the tensor`,expr) fi: ind := `Riemann/indices`(expr): if op(1,ind) <> [] then print(`Riemann/printt` (expr)): ERROR(`cannot have summed indices in lhs`) fi: ind := op(3,ind): if ind <> [] and N <> nops(ind) then ERROR( `use all components or just one component`) fi: A := subs(tensorname = T, `Riemann/sink`(expr)): dt := `Riemann/DisplayTensor`: `Riemann/DisplayTensor` := false: `Riemann/for`(A,A,ind,true,T[0,2]): `Riemann/DisplayTensor` := dt: if `Riemann/DisplayTensor` then lprint(`Calculated `,expr) fi elif type(expr, constanttensor = algebraic) then z := true: if nargs = 2 then if arg2 = ('noiv ') then z := false else ERROR(`2nd argument must be the name noiv`) fi fi: A := op(1,expr): B := op(2,expr): tensorname := `Riemann/tensorname`(A,N): T := tensor.tensorname.N: if not assigned(T[0,1]) then ERROR( `use definetensor to define the tensor`,A) fi: ind := `Riemann/indices`(A): if op(1,ind) <> [] then print(`Riemann/printt`(expr)): ERROR( `cannot have summed indices in lhs`) fi: ind := op(3,ind): if z and {op(ind)} <> {op(op(3,`Riemann/indices`(B)))} and `Riemann/iv` then print( `Riemann/printt`(expr)): ERROR(`wrong choice of free indices`) elif ind <> [] and N <> nops(ind) then ERROR(`use all components or just one component`) fi: AA := subs(tensorname = T,`Riemann/sink`(A)): BB := `Riemann/sum`(B): if `Riemann/hastensor`(B,A) then assign([`Riemann/seq`(AA = BB,ind,T[0,2])]) else dt := `Riemann/DisplayTensor`: `Riemann/DisplayTensor` := false: `Riemann/for` (AA,BB,ind,true,T[0,2]): `Riemann/DisplayTensor` := dt fi: if `Riemann/DisplayTensor` then lprint(`Calculated `,A) fi else ERROR( `1st argument must be a tensor or tensor equation`, `with a constant tensor in lhs`) fi: `Riemann/_`(expr1): NULL end,(savemetric) =proc (name_for_metric) local path: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if not `Riemann/g_is_active` = true then ERROR(`The metric is not active`) fi: if assigned( `Riemann/metric_path`) and `Riemann/metric_path` <> `` then path := ``. `Riemann/metric_path`.`/` else path := `` fi: save Dimension, `Riemann/CoordIndices`, CoordinateName, MetricName, tensor.CoordinateName.1, tensor.MetricName.2, ``.path.name_for_metric end,(metricV)=proc () local e, i, j, k, p, q, M, Minv, n, entermetricV: global `Riemann/g_is_active`, `Riemann/eta_is_active`, `Riemann/eta_is_diag`, `Riemann/det_eta`: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if not `Riemann/x_is_active` then lprint(`*** first define the coordinates`): RETURN(NULL) fi: `Riemann/rigid_frame`(): tensor.MetricVName.2 := table(`Riemann/symm_Ricci`, `Riemann/calc_eta`,[0 = `Riemann/built-in`, (0, 1) = MetricVName, (0, 2) = (' symm[1,2]')]): tensordet.MetricVName.0 := table(`Riemann/calc_detMetricVName`, [0 = `Riemann/built-in`, (0, 1) = det.MetricVName, (0, 2) = ('nosymm')]): M := array(1 .. Dimension,1 .. Dimension,'symmetric','sparse',[]): if nargs = 0 then print(`1-> metric in orthonormal vierbein basis`): print( `2-> metric in complex null vierbein basis`): print( `3-> metric in semi-null vierbein basis`): print(`4-> other`): print( `ENTER THE OPTION`): p := cat(`option 1,2,3 or 4 ?`): e := traperror(readstat( p)): while e = lasterror do lprint(e): e := traperror(readstat(p)) od: if e = 1 then print(`CHOOSE THE SIGNATURE OF METRIC`): print( `1-> diag(1,-1,-1,-1, ...)`): print(`2-> diag(-1,1,1,1, ...)`): p := cat( `option 1 or 2 ? `): q := traperror(readstat(p)): while q = lasterror do lprint(q): q := traperror(readstat(p)) od: if q = 1 then M[1,1] := 1: for i from 2 to Dimension do M[i,i] := -1 od elif q = 2 then M[1,1] := -1: for i from 2 to Dimension do M[i,i] := 1 od else ERROR(`the option must be 1 or 2`) fi: for i to Dimension do for j from i to Dimension do tensor.MetricVName.2[-i ,-j] := M[i,j] od od: `Riemann/eta_is_diag` := true elif e = 2 then if Dimension <> 4 then ERROR(`Dimension must be 4 in this case`) fi: M[1,2] := 1: M[3,4] := -1: for i to Dimension do for j from i to Dimension do tensor. MetricVName.2[-i,-j] := M[i,j] od od: `Riemann/eta_is_diag` := false elif e = 3 then if Dimension <> 4 then ERROR(`Dimension must be 4 in this case`) fi: M[ 1,2] := 1: M[3,3] := -1: M[4,4] := -1: for i to Dimension do for j from i to Dimension do tensor.MetricVName.2[-i,-j] := M[i,j] od od: `Riemann/eta_is_diag` := false elif e = 4 then entermetricV := proc (A, i, j, g) local e, p: p := cat(`value of `,g,`[`,-i,`,`,-j,`] : `): e := traperror( readstat(p)): while e = lasterror do lprint(e): e := traperror(readstat(p)) od: if e <> NULL then A[i,j] := e else A[i,j] := 0 fi end: print( `ENTER THE DIAGONALS ELEMENTS`): for i to Dimension do entermetricV(M,i,i, MetricVName): tensor.MetricVName.2[-i,-i] := M[i,i] od: print( `ENTER THE NON DIAGONAL ELEMENTS`): for i to Dimension-1 do for j from i+1 to Dimension do entermetricV(M,i,j,MetricVName): tensor.MetricVName.2[-i,-j] := M [i,j] od od: if {seq(seq(M[i,j],j = i+1 .. Dimension),i = 1 .. Dimension-1)} = {0} then `Riemann/eta_is_diag` := true else `Riemann/eta_is_diag` := false fi else ERROR(`the option must be 1,2,3 or 4`) fi elif Dimension <= nargs and nargs <= 1/2*Dimension*(Dimension+1) then for i to Dimension do M[i,i] := args [i]: tensor.MetricVName.2[-i,-i] := '"' od: n := Dimension+1: for i to Dimension-1 do for j from i+1 to Dimension do if nargs < n then tensor. MetricVName.2[-i,-j] := 0 else M[i,j] := args[n]: tensor.MetricVName.2[-i,-j] := M[i,j]: n := n+1 fi od od: if {seq(seq(tensor.MetricVName.2[-i,-j],j = i+1 .. Dimension),i = 1 .. Dimension-1)} = {0} then `Riemann/eta_is_diag` := true else `Riemann/eta_is_diag` := false fi else ERROR(`wrong number of arguments`) fi: if `Riemann/eta_is_diag` then `Riemann/det_eta` := '`Riemann/det_eta`' else Minv := evalm(1/M): `Riemann/det_eta` := `Riemann/simp_function`(linalg[ det](M)): for i to Dimension do for j from i to Dimension do tensor. MetricVName.2[i,j] := Minv[i,j] od od fi: if has(eval(M),{seq(tensor. CoordinateName.1[k],k = 1 .. Dimension)}) then ERROR( `the components of metric must be independent of coordinates`) fi: `Riemann/eta_is_active` := true: `Riemann/g_is_active` := false: if `Riemann/DisplayTensor` then i := 'i': j := 'j': print( `The components of the metric in the rigid frame are:`): print( `Riemann/printt`(MetricVName[-i,-j]) = eval(M)) fi: NULL end,(definetensor)= proc (expr1, SYMM) local expr, ind, A, B, tensorname, Symm, SYMM1, SYMM2, N, verifyindices, calc, automatic_fcn, ind_signal: global `Riemann/dummy1`, `Riemann/dummy2`: option `Copyright 1995 by Renato Portugal`: if nargs = 0 then RETURN(NULL) elif type(expr1,list) then if not type([args],list(list)) then ERROR( `to define more than 1 tensor, the argument must be a sequence of lists`) else procname(op(args[1])): RETURN(procname(args[2 .. nargs])) fi fi: expr := `Riemann/ltensor/ltensor`(expr1): verifyindices := `Riemann/iv`: if not type( Dimension,nonnegint) then ERROR(`Dimension must be a positive integer`) elif 3 < nargs then ERROR(`the 1st argument must be a tensor or a tensor equation,`, `the 2nd the symmetry and 3rd the name noiv.`) elif nargs = 3 and args[3] <> ( 'noiv') then ERROR( `3rd argument must be the name noiv (no index verification)`) elif nargs = 2 and SYMM = ('noiv') then verifyindices := false: SYMM1 := NULL: SYMM2 := ' nosymm' elif 1 < nargs then Symm := op(0,SYMM): if type(SYMM,'indexed') and ( Symm = ('symm') or Symm = ('antisymm')) then SYMM1 := cat(`Riemann/`,Symm,op(1 ,SYMM),''_'',op(2,SYMM)): `Riemann/dummy1` := '`Riemann/dummy1`': `Riemann/dummy2` := '`Riemann/dummy2`': `index/`.SYMM1 := subs( `Riemann/dummy1` = op(SYMM),`Riemann/dummy2` = `Riemann/index_`.Symm,proc () `Riemann/dummy2`(`Riemann/dummy1`,args) end) elif SYMM = ('Riemann') or SYMM = ('riemann') then SYMM1 := 'riemann' elif member(SYMM,'{antisymmetric, antisymm , symmetric, diagonal, symm, sparse}') then SYMM1 := SYMM elif nargs = 3 then ERROR(`the 2nd argument must be a known symmetry`) else ERROR( `the 2nd argument must be a known symmetry or the name noiv`) fi: if nargs = 3 then verifyindices := false fi: if SYMM = ('symmetric') then SYMM1 := 'symm': SYMM2 := 'symm' elif SYMM = ('antisymmetric') then SYMM1 := 'antisymm': SYMM2 := 'antisymm' elif SYMM = ('sparse') then SYMM2 := 'nosymm' elif SYMM = (' Riemann') then SYMM2 := 'riemann' else SYMM2 := SYMM fi else SYMM1 := NULL: SYMM2 := 'nosymm' fi: if type(expr,constanttensor) then tensorname := `Riemann/tensorname`(expr,N): ind := `Riemann/indices`(expr): if op(1,ind) <> [] then print(`Riemann/printt`(expr)): ERROR(`cannot have summed indices`) elif nops(op(2,ind)) <> N then print(`Riemann/printt`(expr)): ERROR( `cannot have numeric indices`) fi: if member(tensorname,{CoordinateName, MetricName, MetricVName, MetricVName1, VierbeinName}) or N = 0 then calc := NULL elif `Riemann/g_is_active` = true then calc := `Riemann/calc_in_coord`: ind_signal := map(proc (x) if op(1,x) = -1 then -1 else 1 fi end,op(3,ind)) elif `Riemann/eta_is_active` = true then calc := `Riemann/calc_in_vierbein`: ind_signal := map(proc (x) if op(1,x) = -1 then -1 else 1 fi end,op(3,ind)) else calc := NULL: ind_signal := [] fi: tensor.tensorname.N := table(SYMM1, calc,[0 = `Riemann/DEFINED`, (0, 1) = tensorname, (0, 2) = SYMM2, (0, 4) = ind_signal]) elif type(expr,constanttensor = algebraic) then A := lhs(expr): B := rhs(expr): tensorname := `Riemann/tensorname`(A,N): ind := `Riemann/indices`(A): if op(1,ind) <> [] then print(`Riemann/printt`(expr)): ERROR(`cannot have summed indices in lhs`) elif nops(op(2,ind)) <> N then print(`Riemann/printt`(expr)): ERROR(`cannot have numeric indices in lhs`) elif {op(op(3,ind))} <> {op(op(3,`Riemann/indices`(B)))} and `Riemann/iv` and verifyindices then print(`Riemann/printt`(expr)): ERROR( `wrong choice of free indices`) fi: if member(tensorname,{CoordinateName, MetricName, MetricVName, MetricVName1, VierbeinName}) or N = 0 then calc := NULL elif `Riemann/g_is_active` = true then calc := `Riemann/calc_in_coord`: ind_signal := map(proc (x) if op(1,x) = -1 then -1 else 1 fi end,op(3,ind)) elif `Riemann/eta_is_active` = true then calc := `Riemann/calc_in_vierbein`: ind_signal := map(proc (x) if op(1,x) = -1 then -1 else 1 fi end,op(3,ind)) else calc := `Riemann/automatic`: ind_signal := [] fi: zip(proc (x, y) options operator, arrow: x = y end,op(2,ind),op(3,ind)): automatic_fcn := unapply(subs (",`Riemann/sum`(B)),op(op(2,ind))): tensor.tensorname.N := table(SYMM1,calc,[ 0 = `Riemann/DEFINED`, (0, 1) = tensorname, (0, 2) = SYMM2, (0, 3) = eval( automatic_fcn), (0, 4) = ind_signal]) else ERROR( `1st argument must be a constant tensor or a tensor equation`, `with a constant tensor in lhs`) fi: `Riemann/_`(expr1): `Riemann/printt`(expr ) end,(vierbein)=proc () local i, j, n, M, Minv, e_read, _is_active: global `Riemann/Vierbein_is_active`, `Riemann/v_is_active`, `Riemann/Vierbein_is_diag`, `Riemann/eta_is_active`: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if not `Riemann/eta_is_active` then lprint(`*** first define the metric (metricV command)`): RETURN(NULL) fi: if `Riemann/Vierbein_is_active` then `Riemann/rigid_frame`() fi: if `Riemann/` .MetricName._is_active = true then ERROR(MetricName, `is active. Change metric name`) fi: tensor.VierbeinName.2 := table( `Riemann/calc_Vierbein`,[0 = `Riemann/built-in`, (0, 1) = VierbeinName, (0, 2) = ('nosymm')]): M := array(1 .. Dimension,1 .. Dimension,'sparse',[]): if nargs = 0 then print(`Convention for `.VierbeinName.` indices:`): print( `First index is a vierbein index and second one is a coordinate index`): print (` `): for i to Dimension do seq(`Riemann/printt`(VierbeinName[i,-j]),j = 1 .. Dimension): print(`ENTER THE COMPONENTS`,"): e_read := traperror(readstat()): while e_read = lasterror do lprint(e_read): e_read := traperror(readstat()) od: if e_read = ('exit') then ERROR(`aborted `) elif e_read <> NULL then if whattype(e_read) = ('exprseq') and nops([e_read]) = Dimension then for j to Dimension do tensor.VierbeinName.2[i,-j] := op(j,[e_read]): M[i,j] := '"' od else ERROR(`not a sequence of`,Dimension,`elements `) fi fi od elif nargs = Dimension then for i to Dimension do for j to Dimension do if i = j then M[i,i ] := args[i]: tensor.VierbeinName.2[i,-i] := '"' else tensor.VierbeinName.2[i, -j] := 0 fi od od elif nargs = Dimension^2 then n := 1: for i to Dimension do for j to Dimension do M[i,j] := args[n]: tensor.VierbeinName.2[i,-j] := '"': n := n+1 od od else ERROR(`wrong number of arguments`) fi: if {seq(seq(tensor. VierbeinName.2[i,-j],j = i+1 .. Dimension),i = 1 .. Dimension-1), seq(seq( tensor.VierbeinName.2[i,-j],j = 1 .. i-1),i = 2 .. Dimension)} = {0} then `Riemann/Vierbein_is_diag` := true else `Riemann/Vierbein_is_diag` := false: Minv := evalm(1/M): for i to Dimension do for j to Dimension do tensor. VierbeinName.2[-i,j] := Minv[j,i] od od fi: `Riemann/v_is_active` := true: `Riemann/Vierbein_is_active` := true: if `Riemann/DisplayTensor` then i := 'i' : j := 'j': print(`The components of the vierbein are:`): show(VierbeinName[i, -j]) fi: NULL end,(entertensor)=proc (expr1::constanttensor) local tensorname, N, expr: global `Riemann/DisplayTensor`, `Riemann/history`, `Riemann/enter`: option `Copyright 1995 by Renato Portugal`: expr := subs(`t*e*n*s*o*r` = proc (x) x end,`` = proc (x) x end,expr1): tensorname := `Riemann/tensorname`(expr, N): if assigned(tensor.tensorname.N[0,1]) then clear(expr) else ERROR( `use definetensor to define the tensor `.tensorname) fi: `Riemann/history` := [[0], [0], [0]]: apply(`Riemann/enter`,expr): if `Riemann/DisplayTensor` then show(expr) fi: `Riemann/_`(expr) end,(readmetric)=proc (name_for_metric) local i, j, z, path: global `Riemann/CoordIndices`, `Riemann/metric_path`: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if assigned( `Riemann/metric_path`) then path := ``.`Riemann/metric_path`.`/` else path := `` fi: read ``.path.name_for_metric: z := `Riemann/CoordIndices`: coordinates( seq(tensor.CoordinateName.1[i],i = 1 .. Dimension)): print(` `): metric(seq( tensor.MetricName.2[-i,-i],i = 1 .. Dimension),seq(seq(tensor.MetricName.2[-i, -j],j = i+1 .. Dimension),i = 1 .. Dimension)): `Riemann/CoordIndices` := z: NULL end,(invariants)=proc (xx::string) local lgt, dt, showscalar: global `Riemann/DisplayTensor`: option `Copyright 1995 by R. Portugal`: if nargs = 0 then showscalar := 'false' elif nargs = 1 then if xx <> ('show') then ERROR( `the argument must be the name show`) fi: showscalar := 'true' elif 1 < nargs then error(`wrong number of arguments`) fi: dt := `Riemann/DisplayTensor`: `Riemann/DisplayTensor` := false: if `Riemann/g_is_active` then Riemann[calc]( RicciScalarName[]): lgt := length(tensor.RicciScalarName.0[]): if dt then if lgt = 0 or showscalar then print(RicciScalarName[] = tensor.RicciScalarName.0[ ]) else print(RicciScalarName[] = ``.lgt.` words `) fi fi: Riemann[calc]( r1Name[]): lgt := length(tensor.r1Name.0[]): if dt then if lgt = 0 or showscalar then print(r1Name[] = tensor.r1Name.0[]) else print(r1Name[] = ``. lgt.` words `) fi fi: Riemann[calc](r2Name[]): lgt := length(tensor.r2Name.0[] ): if dt then if lgt = 0 or showscalar then print(r2Name[] = tensor.r2Name.0[] ) else print(r2Name[] = ``.lgt.` words `) fi fi: Riemann[calc](r3Name[]): lgt := length(tensor.r3Name.0[]): if dt then if lgt = 0 or showscalar then print( r3Name[] = tensor.r3Name.0[]) else print(r3Name[] = ``.lgt.` words `) fi fi: Riemann[calc](w1rName[]): lgt := length(tensor.w1rName.0[]): if dt then if lgt = 0 or showscalar then print(w1rName[] = tensor.w1rName.0[]) else print( w1rName[] = ``.lgt.` words `) fi fi: Riemann[calc](w1IName[]): lgt := length( tensor.w1IName.0[]): if dt then if lgt = 0 or showscalar then print(w1IName[] = tensor.w1IName.0[]) else print(w1IName[] = ``.lgt.` words `) fi fi: Riemann[ calc](w2rName[]): lgt := length(tensor.w2rName.0[]): if dt then if lgt = 0 or showscalar then print(w2rName[] = tensor.w2rName.0[]) else print(w2rName[] = ``.lgt.` words `) fi fi: Riemann[calc](w2IName[]): lgt := length(tensor. w2IName.0[]): if dt then if lgt = 0 or showscalar then print(w2IName[] = tensor.w2IName.0[]) else print(w2IName[] = ``.lgt.` words `) fi fi: Riemann[ calc](m1rName[]): lgt := length(tensor.m1rName.0[]): if dt then if lgt = 0 or showscalar then print(m1rName[] = tensor.m1rName.0[]) else print(m1rName[] = ``.lgt.` words `) fi fi: Riemann[calc](m1IName[]): lgt := length(tensor. m1IName.0[]): if dt then if lgt = 0 or showscalar then print(m1IName[] = tensor.m1IName.0[]) else print(m1IName[] = ``.lgt.` words `) fi fi: Riemann[ calc](m2rName[]): lgt := length(tensor.m2rName.0[]): if dt then if lgt = 0 or showscalar then print(m2rName[] = tensor.m2rName.0[]) else print(m2rName[] = ``.lgt.` words `) fi fi: Riemann[calc](m2IName[]): lgt := length(tensor. m2IName.0[]): if dt then if lgt = 0 or showscalar then print(m2IName[] = tensor.m2IName.0[]) else print(m2IName[] = ``.lgt.` words `) fi fi: Riemann[ calc](m3Name[]): lgt := length(tensor.m3Name.0[]): if dt then if lgt = 0 or showscalar then print(m3Name[] = tensor.m3Name.0[]) else print(m3Name[] = ``. lgt.` words `) fi fi: Riemann[calc](m4Name[]): lgt := length(tensor.m4Name.0[] ): if dt then if lgt = 0 or showscalar then print(m4Name[] = tensor.m4Name.0[] ) else print(m4Name[] = ``.lgt.` words `) fi fi: Riemann[calc](m5rName[]): lgt := length(tensor.m5rName.0[]): if dt then if lgt = 0 or showscalar then print( m5rName[] = tensor.m5rName.0[]) else print(m5rName[] = ``.lgt.` words `) fi fi : Riemann[calc](m5IName[]): lgt := length(tensor.m5IName.0[]): if dt then if lgt = 0 or showscalar then print(m5IName[] = tensor.m5IName.0[]) else print( m5IName[] = ``.lgt.` words `) fi fi elif `Riemann/Vierbein_is_active` then Riemann[calc](RicciScalarVName[]): lgt := length(tensor.RicciScalarVName.0[]): if dt then if lgt = 0 or showscalar then print(RicciScalarVName[] = tensor. RicciScalarVName.0[]) else print(RicciScalarVName[] = ``.lgt.` words `) fi fi: Riemann[calc](r1VName[]): lgt := length(tensor.r1VName.0[]): if dt then if lgt = 0 or showscalar then print(r1VName[] = tensor.r1VName.0[]) else print( r1VName[] = ``.lgt.` words `) fi fi: Riemann[calc](r2VName[]): lgt := length( tensor.r2VName.0[]): if dt then if lgt = 0 or showscalar then print(r2VName[] = tensor.r2VName.0[]) else print(r2VName[] = ``.lgt.` words `) fi fi: Riemann[ calc](r3VName[]): lgt := length(tensor.r3VName.0[]): if dt then if lgt = 0 or showscalar then print(r3VName[] = tensor.r3VName.0[]) else print(r3VName[] = ``.lgt.` words `) fi fi: Riemann[calc](w1rVName[]): lgt := length(tensor. w1rVName.0[]): if dt then if lgt = 0 or showscalar then print(w1rVName[] = tensor.w1rVName.0[]) else print(w1rVName[] = ``.lgt.` words `) fi fi: Riemann[ calc](w1IVName[]): lgt := length(tensor.w1IVName.0[]): if dt then if lgt = 0 or showscalar then print(w1IVName[] = tensor.w1IVName.0[]) else print(w1IVName [] = ``.lgt.` words `) fi fi: Riemann[calc](w2rVName[]): lgt := length(tensor. w2rVName.0[]): if dt then if lgt = 0 or showscalar then print(w2rVName[] = tensor.w2rVName.0[]) else print(w2rVName[] = ``.lgt.` words `) fi fi: Riemann[ calc](w2IVName[]): lgt := length(tensor.w2IVName.0[]): if dt then if lgt = 0 or showscalar then print(w2IVName[] = tensor.w2IVName.0[]) else print(w2IVName [] = ``.lgt.` words `) fi fi: Riemann[calc](m1rVName[]): lgt := length(tensor. m1rVName.0[]): if dt then if lgt = 0 or showscalar then print(m1rVName[] = tensor.m1rVName.0[]) else print(m1rVName[] = ``.lgt.` words `) fi fi: Riemann[ calc](m1IVName[]): lgt := length(tensor.m1IVName.0[]): if dt then if lgt = 0 or showscalar then print(m1IVName[] = tensor.m1IVName.0[]) else print(m1IVName [] = ``.lgt.` words `) fi fi: Riemann[calc](m2rVName[]): lgt := length(tensor. m2rVName.0[]): if dt then if lgt = 0 or showscalar then print(m2rVName[] = tensor.m2rVName.0[]) else print(m2rVName[] = ``.lgt.` words `) fi fi: Riemann[ calc](m2IVName[]): lgt := length(tensor.m2IVName.0[]): if dt then if lgt = 0 or showscalar then print(m2IVName[] = tensor.m2IVName.0[]) else print(m2IVName [] = ``.lgt.` words `) fi fi: Riemann[calc](m3VName[]): lgt := length(tensor. m3VName.0[]): if dt then if lgt = 0 or showscalar then print(m3VName[] = tensor.m3VName.0[]) else print(m3VName[] = ``.lgt.` words `) fi fi: Riemann[ calc](m4VName[]): lgt := length(tensor.m4VName.0[]): if dt then if lgt = 0 or showscalar then print(m4VName[] = tensor.m4VName.0[]) else print(m4VName[] = ``.lgt.` words `) fi fi: Riemann[calc](m5rVName[]): lgt := length(tensor. m5rVName.0[]): if dt then if lgt = 0 or showscalar then print(m5rVName[] = tensor.m5rVName.0[]) else print(m5rVName[] = ``.lgt.` words `) fi fi: Riemann[ calc](m5IVName[]): lgt := length(tensor.m5IVName.0[]): if dt then if lgt = 0 or showscalar then print(m5IVName[] = tensor.m5IVName.0[]) else print(m5IVName [] = ``.lgt.` words `) fi fi else `Riemann/DisplayTensor` := dt: ERROR( `neither the metric nor the vierbein is active`) fi: `Riemann/DisplayTensor` := dt: NULL end,(amap)=proc (f::{procedure, name, numeric}, expr1) local ind, tensorname, N, expr, A, B, T: option `Copyright 1995 by Renato Portugal`: expr := `Riemann/ltensor/ltensor`(expr1): if type(expr,constanttensor) then ind := `Riemann/indices`(expr): tensorname := `Riemann/tensorname`(expr,N): T := tensor.tensorname.N: if not assigned(T[0,1]) then ERROR( `use definetensor to define the tensor`,expr) elif op(1,ind) <> [] then ERROR( `the tensor`,expr1,`cannot have summed indices`) fi: `Riemann/_`(expr1): if type(f,'string') and substring(f,1 .. 1) = ('t') then t.f else f fi: subs( tensorname = T,`Riemann/sink`(expr)), `Riemann/sum`('"'(expr,args[3 .. nargs]) ): `Riemann/for`('"',op(3,ind),true,T[0,2]) elif type(expr,constanttensor = algebraic) then A := lhs(expr): B := rhs(expr): ind := `Riemann/indices`(A): if {op(op(3,ind))} <> {op(op(3,`Riemann/indices`(B)))} and `Riemann/iv` and `Riemann/DisplayTensor` then lprint( `*** warning: the free indices do not match`) fi: tensorname := `Riemann/tensorname`(A,N): T := tensor.tensorname.N: if not assigned(T[0,1]) then ERROR(`use definetensor to define the tensor`,A) elif op(1,ind) <> [] then ERROR(`the tensor`,A,`has summed indices`) fi: `Riemann/_`(expr1): A := subs(tensorname = T,A): if type(f,'string') and substring(f,1 .. 1) = ('t') then t.f else f fi: B := `Riemann/sum`('"'(B,args[3 .. nargs])): `Riemann/for` (A,B,op(3,ind),true,T[0,2]) else ERROR( `2nd argument must be a constant tensor or a tensor equation`, `with a constant tensor in lhs`) fi end,(complist)=proc (expr1, arg2) local expr, N, ind, tensorname, A, B, SYMM: global nosymm: option `Copyright 1995 by Renato Portugal`: expr := `Riemann/ltensor/ltensor`(expr1): if type(expr,tensor) then tensorname := `Riemann/tensorname`(expr,N): ind := op(3,`Riemann/indices`(expr)): if assigned(tensor.tensorname.N[0,2]) then SYMM := tensor.tensorname.N[0,2] else SYMM := 'nosymm' fi: `Riemann/_`(expr1): `Riemann/printt`([`Riemann/seq`(`Riemann/sum`(expr),ind,SYMM)]) elif type(expr ,algebraic) then ind := op(3,`Riemann/indices`(expr)): `Riemann/_`(expr1): `Riemann/printt`([`Riemann/seq`(`Riemann/sum`(expr),ind,'nosymm')]) elif type( expr,tensor = algebraic) then A := lhs(expr): B := rhs(expr): tensorname := `Riemann/tensorname`(A,N): ind := op(3,`Riemann/indices`(A)): if {op(ind)} <> {op(op(3,`Riemann/indices`(B)))} and `Riemann/iv` then if nargs = 2 then if arg2 <> ('noiv') then ERROR(`2nd argument must be noiv`) fi else print( `Riemann/printt`(expr)): ERROR(`wrong choice of free indices`) fi fi: if assigned(tensor.tensorname.N[0,2]) then SYMM := tensor.tensorname.N[0,2] else SYMM := 'nosymm' fi: `Riemann/_`(expr1): `Riemann/printt`([`Riemann/seq`(A = `Riemann/sum`(B),ind,SYMM)]) else ERROR( `argument must be a tensor, an expression or a tensor equation `) fi end,( switches)=proc () option `Copyright 1995 by Renato Portugal`: lprint(cat( CoordIndices,` - `,`Riemann/sw`(`Riemann/CoordIndices`))): lprint(cat( DiffAlias,` - `,`Riemann/sw`(`Riemann/DiffAlias`))): lprint(cat( DisplayTensor,` - `,`Riemann/sw`(`Riemann/DisplayTensor`))): lprint(cat(iv, ` - `,`Riemann/sw`(`Riemann/iv`))): lprint(cat(latex,` - `, `Riemann/sw`(`Riemann/latex`))): lprint(cat(lptensor,` - `,`Riemann/sw`( `Riemann/lptensor`))): lprint(cat(ltensor,` - `,`Riemann/sw`( `Riemann/ltensor`))): lprint(cat(printtensor,` - `,`Riemann/sw`( `Riemann/printtensor`))): lprint(cat(ZeroIndex,` - `,`Riemann/sw`( `Riemann/ZeroIndex`))) end,(petrov)=proc () local i, j, NP_curv, spin_coeffs, Gdet, curv_info, h, coord, opt: global `tensor/petrov/simp`: option `Copyright 1997 by R. Portugal. All rights reserved.`: if Dimension <> 4 then ERROR(`Dimension must be 4.`) fi: with(tensor,[]): if nargs = 0 then opt := NULL elif nargs = 1 then if type(args[1],procedure) then `tensor/petrov/simp` := args[1]: opt := 'simp' elif type(args[1],'name') then opt := ('verify') = args[1] else ERROR(xxxxxx) fi elif nargs = 2 then if not (type(args[1], procedure) and type(args[2],'name')) then ERROR(`when called with two argument\ s, 1st must be a simplifying function and 2nd must be a name.`) else `tensor/petrov/simp` := args[1]: opt := 'simp', ('verify') = args[2] fi else ERROR(`petrov function cannot have more then 2 arguments. A null vierbein must\ have been defined before call this function using vierbein or ivierbein.`) fi : if not (assigned(tensor.CoordinateName.1) and assigned(tensor.VierbeinName.2 )) then ERROR( `The coordinates or the vierbein have not been defined properly.`) fi: coord := [seq(tensor.CoordinateName.1[i],i = 1 .. 4)]: h := tensor['create']([1, -1] ,array(1 .. 4,1 .. 4,[seq([seq(tensor.VierbeinName.2[-i,j],j = 1 .. 4)],i = 1 .. 4)])): spin_coeffs := tensor['npspin'](coord,h,'Gdet, curv_info'): NP_curv := tensor['npcurve'](spin_coeffs,curv_info): tensor['petrov'](NP_curv[Psi],opt ) end,(ivierbein)=proc () local i, j, n, M, Minv, e_read, _is_active: global `Riemann/Vierbein_is_active`, `Riemann/iv_is_active`, `Riemann/Vierbein_is_diag`, `Riemann/eta_is_active`: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if not `Riemann/eta_is_active` then lprint(`*** first define the metric (metricV command)`): RETURN(NULL) fi: if `Riemann/Vierbein_is_active` then `Riemann/rigid_frame`() fi: if `Riemann/` .MetricName._is_active = true then ERROR(MetricName, `is active. Change metric name`) fi: tensor.VierbeinName.2 := table( `Riemann/calc_Vierbein`,[0 = `Riemann/built-in`, (0, 1) = VierbeinName, (0, 2) = ('nosymm')]): M := array(1 .. Dimension,1 .. Dimension,'sparse',[]): if nargs = 0 then print(`Convention for `.VierbeinName.` indices:`): print( `First index is a vierbein index and second one is a coordinate index`): print (` `): for i to Dimension do seq(`Riemann/printt`(VierbeinName[-i,j]),j = 1 .. Dimension): print(`ENTER THE COMPONENTS`,"): e_read := traperror(readstat()): while e_read = lasterror do lprint(e_read): e_read := traperror(readstat()) od: if e_read = ('exit') then ERROR(`aborted `) elif e_read <> NULL then if whattype(e_read) = ('exprseq') and nops([e_read]) = Dimension then for j to Dimension do tensor.VierbeinName.2[-i,j] := op(j,[e_read]): M[i,j] := '"' od else ERROR(`not a sequence of`,Dimension,`elements `) fi fi od elif nargs = Dimension then for i to Dimension do for j to Dimension do if i = j then M[i,i ] := args[i]: tensor.VierbeinName.2[-i,i] := '"' else tensor.VierbeinName.2[-i ,j] := 0 fi od od elif nargs = Dimension^2 then n := 1: for i to Dimension do for j to Dimension do M[i,j] := args[n]: tensor.VierbeinName.2[-i,j] := '"': n := n+1 od od else ERROR(`wrong number of arguments`) fi: if {seq(seq(tensor. VierbeinName.2[-i,j],j = i+1 .. Dimension),i = 1 .. Dimension-1), seq(seq( tensor.VierbeinName.2[-i,j],j = 1 .. i-1),i = 2 .. Dimension)} = {0} then `Riemann/Vierbein_is_diag` := true else `Riemann/Vierbein_is_diag` := false: Minv := evalm(1/M): for i to Dimension do for j to Dimension do tensor. VierbeinName.2[i,-j] := Minv[j,i] od od fi: `Riemann/iv_is_active` := true: `Riemann/Vierbein_is_active` := true: if `Riemann/DisplayTensor` then i := 'i' : j := 'j': print(`The components of the inverse vierbein are:`): show( VierbeinName[-i,j]) fi: NULL end,(ltensor)=proc (expr) option `Copyright 1995 by Renato Portugal`: `Riemann/_`(expr): eval(subs( `t*e*n*s*o*r` = proc (x) x end,`` = proc (x) x end,expr)) end,(bintnames)=proc (x) option `Copyright 1995 by R. Portugal and S.L. Sautu`: if `Riemann/g_is_active` or nargs = 1 and x = ('coordinates') then lprint( LineElementName.` - `.LineElementName): lprint(CoordinateName.` - `. CoordinateName): lprint(MetricName.` - `.MetricName): lprint( ChristoffelName.` - `.ChristoffelName): lprint(RiemannName.` - `. RiemannName): lprint(RicciName.` - `.RicciName): lprint(EinsteinName. ` - `.EinsteinName): lprint(RicciScalarName.` - `.RicciScalarName): lprint(WeylName.` - `.WeylName): lprint(WeylStarName.` - `. WeylStarName): lprint(RieSqName.` - `.RieSqName): lprint(WeylSqName. ` - `.WeylSqName): lprint(TclRicciName.` - `.TclRicciName): lprint( RicciSqName.` - `.RicciSqName): lprint(LeviCivitaName.` - `. LeviCivitaName): lprint(PermSymbolName.` - `.PermSymbolName): lprint(r1Name. ` - `.r1Name): lprint(r2Name.` - `.r2Name): lprint(r3Name. ` - `.r3Name): lprint(w1rName.` - `.w1rName): lprint( w1IName.` - `.w1IName): lprint(w2rName.` - `.w2rName): lprint(w2IName.` - `.w2IName): lprint(m1rName.` - `.m1rName) : lprint(m1IName.` - `.m1IName): lprint(m2rName.` - `. m2rName): lprint(m2IName.` - `.m2IName): lprint(m3Name. ` - `.m3Name): lprint(m4Name.` - `.m4Name): lprint(m5rName .` - `.m5rName): lprint(m5IName.` - `.m5IName) elif `Riemann/eta_is_active` or nargs = 1 and x = ('vierbein') then lprint( LineElementVName.` - `.LineElementVName): lprint(CoordinateName.` - `. CoordinateName): lprint(MetricVName.` - `.MetricVName): lprint( MetricVName1.` - `.MetricVName1): lprint(VierbeinName.` - `. VierbeinName): lprint(RicciCoeffName.` - `.RicciCoeffName): lprint( CommutCoeffName.` - `.CommutCoeffName): lprint(RiemannVName.` - `. RiemannVName): lprint(RicciVName.` - `.RicciVName): lprint(EinsteinVName .` - `.EinsteinVName): lprint(RicciScalarVName.` - `.RicciScalarVName): lprint(WeylVName.` - `.WeylVName): lprint(WeylStarVName.` - `. WeylStarVName): lprint(RieSqVName.` - `.RieSqVName): lprint(WeylSqVName. ` - `.WeylSqVName): lprint(TclRicciVName.` - `.TclRicciVName): lprint( RicciSqVName.` - `.RicciSqVName): lprint(LeviCivitaVName.` - `. LeviCivitaVName): lprint(PermSymbolVName.` - `.PermSymbolVName): lprint( r1VName.` - `.r1VName): lprint(r2VName.` - `.r2VName): lprint(r3VName.` - `.r3VName): lprint(w1rVName.` - `.w1rVName ): lprint(w1IVName.` - `.w1IVName): lprint(w2rVName.` - `. w2rVName): lprint(w2IVName.` - `.w2IVName): lprint(m1rVName. ` - `.m1rVName): lprint(m1IVName.` - `.m1IVName): lprint( m2rVName.` - `.m2rVName): lprint(m2IVName.` - `.m2IVName): lprint(m3VName.` - `.m3VName): lprint(m4VName.` - `.m4VName) : lprint(m5rVName.` - `.m5rVName): lprint(m5IVName.` - `. m5IVName) else lprint(`coordinates: `): lprint(``): procname('coordinates'): lprint(``): lprint(`vierbein: `): lprint(``): procname('vierbein') fi end,( savevierbein)=proc (name_for_vierbein) local path: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if not `Riemann/Vierbein_is_active` = true then ERROR(`The vierbein is not active`) fi: if assigned(`Riemann/vierbein_path`) and `Riemann/vierbein_path` <> `` then path := ``.`Riemann/vierbein_path`.`/` else path := `` fi: save Dimension , `Riemann/CoordIndices`, `Riemann/v_is_active`, `Riemann/iv_is_active`, CoordinateName, MetricVName, VierbeinName, tensor.CoordinateName.1, tensor. MetricVName.2, tensor.VierbeinName.2, ``.path.name_for_vierbein end,(on)=proc (x) local SwitchSet: global `Riemann/printt`, `Riemann/CoordIndices`, `Riemann/iv`, `Riemann/DisplayTensor`, `Riemann/ZeroIndex`, `t*e*n*s*o*r`, printtensor, `Riemann/ltensor`, `Riemann/lptensor`, `Riemann/printtensor`, `Riemann/latex`, `print/diff`, `Riemann/DiffAlias`, `Riemann/CodiffIndex`: option `Copyright 1995 by Renato Portugal`: SwitchSet := '{latex, iv, DisplayTensor, DiffAlias, lptensor, printtensor, ZeroIndex, ltensor, CoordIndices, DifftAlias, CodiffIndex}': if not member(x,SwitchSet) then ERROR (`the argument must be one of the following name:`,SwitchSet) elif x = (' lptensor') then `Riemann/printt` := proc (expr) `Riemann/printt_old`(expr): lprint(eval(subs(`t*e*n*s*o*r` = proc (x) x end,`` = proc (x) x end,"))) end: printtensor := eval(`Riemann/printt`): `Riemann/ltensor` := false: `Riemann/lptensor` := true: `Riemann/printtensor` := false elif x = ('ltensor' ) then `Riemann/printt` := proc (expr) `Riemann/printt_old`(expr): eval(subs( `t*e*n*s*o*r` = proc (x) x end,`` = proc (x) x end,")) end: printtensor := eval(`Riemann/printt`): `Riemann/ltensor` := true: `Riemann/lptensor` := false : `Riemann/printtensor` := false elif x = ('printtensor') then `Riemann/printt` := eval(`Riemann/printt_old`): printtensor := eval( `Riemann/printtensor_old`): `t*e*n*s*o*r` := '`t*e*n*s*o*r`': `Riemann/ltensor` := false: `Riemann/lptensor` := false: `Riemann/printtensor` := true elif x = ('latex') then `t*e*n*s*o*r` := eval(`l*a*t*e*x`): printtensor := proc (x) `Riemann/printtensor_old`(x): latex(") end: `Riemann/printt` := proc (x) `Riemann/printt_old`(x): latex(") end: `Riemann/latex` := true elif x = ('CoordIndices') then if not `Riemann/x_is_active` = true then ERROR( `The coordinates have not been defined`) fi: `Riemann/forgetall`(): `Riemann/CoordIndices` := true elif x = ('ZeroIndex') then `Riemann/forgetall` (): `Riemann/ZeroIndex` := true elif x = ('DiffAlias') then `print/diff` := eval(`Riemann/print/diff1`): `Riemann/DiffAlias` := true elif x = ('DifftAlias ') then `print/diff` := eval(`Riemann/print/diff2`) elif x = ('CodiffIndex') then lprint( `Warning: expressions with wrong type of indices can be generated.`): `Riemann/CodiffIndex` := true else `Riemann/`.x := true fi: NULL end,(off)= proc (x) local SwitchSet: global `Riemann/printt`, `Riemann/CoordIndices`, `Riemann/iv`, `Riemann/DisplayTensor`, `Riemann/ZeroIndex`, `t*e*n*s*o*r`, printtensor, `Riemann/ltensor`, `Riemann/lptensor`, `Riemann/printtensor`, `Riemann/latex`, `print/diff`, `Riemann/DiffAlias`: option `Copyright 1995 by Renato Portugal`: SwitchSet := '{latex, iv, DisplayTensor, DiffAlias, lptensor, printtensor, ZeroIndex, ltensor, CoordIndices, DifftAlias , CodiffIndex}': if not member(x,SwitchSet) then ERROR( `the argument must be one of the following name:`,SwitchSet) elif member(x,'{ lptensor, ltensor}') then `Riemann/printt` := eval(`Riemann/printt_old`): printtensor := eval(`Riemann/printtensor_old`): `Riemann/lptensor` := false: `Riemann/ltensor` := false: `Riemann/printtensor` := true elif x = (' printtensor') then `Riemann/printt` := proc (expr) `Riemann/printt_old`(expr): eval(subs(`t*e*n*s*o*r` = proc (x) x end,`` = proc (x) x end,")) end: `Riemann/ltensor` := true: `Riemann/lptensor` := false: `Riemann/printtensor` := false elif x = ('latex') then `t*e*n*s*o*r` := '`t*e*n*s*o*r`': printtensor := eval(`Riemann/printtensor_old`): `Riemann/printt` := eval( `Riemann/printt_old`): `Riemann/latex` := false elif x = ('CoordIndices') then `Riemann/forgetall`(): `Riemann/CoordIndices` := false elif x = ('ZeroIndex') then `Riemann/forgetall`(): `Riemann/ZeroIndex` := false elif x = ('DiffAlias' ) or x = ('DifftAlias') then `print/diff` := '`print/diff`': `Riemann/DiffAlias` := false else `Riemann/`.x := false fi: NULL end,( readvierbein)=proc (name_for_vierbein) local i, j, z, path: global `Riemann/CoordIndices`, `Riemann/v_is_active`, `Riemann/iv_is_active`, `Riemann/vierbein_path`: option `Copyright 1995 by R. Portugal and S.L. Sautu` : if assigned(`Riemann/vierbein_path`) then path := ``.`Riemann/vierbein_path` .`/` else path := `` fi: read ``.path.name_for_vierbein: z := `Riemann/CoordIndices`: coordinates(seq(tensor.CoordinateName.1[i],i = 1 .. Dimension)): print(` `): metricV(seq(tensor.MetricVName.2[-i,-i],i = 1 .. Dimension),seq(seq(tensor.MetricVName.2[-i,-j],j = i+1 .. Dimension),i = 1 .. Dimension-1)): print(` `): if `Riemann/v_is_active` then vierbein(seq(seq( tensor.VierbeinName.2[i,-j],j = 1 .. Dimension),i = 1 .. Dimension)) elif `Riemann/iv_is_active` then ivierbein(seq(seq(tensor.VierbeinName.2[-i,j],j = 1 .. Dimension),i = 1 .. Dimension)) else ERROR(`vierbein saved incorrectly`) fi: `Riemann/CoordIndices` := z: NULL end,(codiff)=proc () option `Copyright 1997 by R. Portugal. All rights reserved.`: `Riemann/printt`( `Riemann/codiff/expand`(args)) end,(savetensor)=proc (expr1::constanttensor, filename::string) local expr, tensorname, N, T, p, e, Filename, path: global `Riemann/tensor_path`: option `Copyright 1995 by Renato Portugal`: expr := subs(`t*e*n*s*o*r` = proc (x) x end,`` = proc (x) x end,expr1): tensorname := `Riemann/tensorname`(expr,N): T := tensor.tensorname.N: if not assigned(T[0,1] ) then ERROR(`this tensor has not been defined`) fi: if assigned( `Riemann/tensor_path`) then path := ``.`Riemann/tensor_path`.`/` else path := `` fi: if nargs = 1 then p := `Enter the name of the file:`: e := readstat(p): while not type(e,'string') do lprint(`The filename must be a string`): e := readstat(p) od: Filename := e elif nargs = 2 then Filename := filename else ERROR(`wrong number of arguments`) fi: save tensor.tensorname.N, ``.path. Filename end,(metric)=proc () local i, j, n, M, Minv, enterentry, history: global `Riemann/detg`, `Riemann/g_is_diag`, `Riemann/g_is_active`, `Riemann/eta_is_active`: option `Copyright 1995 by R. Portugal and S.L. Sautu` : if nargs = 1 and type(args,'constanttensor') then RETURN(metric(op(complist( args)))) fi: if not `Riemann/x_is_active` and `Riemann/DisplayTensor` then lprint(`*** first define the coordinates`): RETURN(NULL) fi: `Riemann/holonomic_frame`(): tensor.MetricName.2 := table(`Riemann/symm_Ricci` ,`Riemann/calc_g`,[0 = `Riemann/built-in`, (0, 1) = MetricName, (0, 2) = (' symm[1,2]')]): tensordet.MetricName.0 := table(`Riemann/calc_detg`,[0 = `Riemann/built-in`, (0, 1) = det.MetricName, (0, 2) = ('nosymm')]): M := array (1 .. Dimension,1 .. Dimension,'symmetric','sparse'): if nargs = 0 then enterentry := proc (A, i, j, history) local e, p, tquote, dquote, quote: tquote := op(1,history): dquote := op(2,history): quote := op(3,history): p := cat(`enter component `,MetricName,`[`,-i,`,`,-j,`] :`): e := traperror( readstat(p,tquote,dquote,quote)): if e = ('exit') then ERROR( `interactive enter aborted`) fi: while e = lasterror do lprint(e): e := traperror(readstat(p,tquote,dquote,quote)) od: if e <> NULL then A[i,j] := e: tquote := dquote: dquote := quote: quote := [e] fi: [tquote, dquote, quote] end: history := [[0], [0], [0]]: print(`ENTRY THE DIAGONAL ELEMENTS`): for i to Dimension do history := enterentry(M,i,i,history): tensor.MetricName.2[-i,- i] := M[i,i] od: print(`ENTRY THE NON DIAGONAL ELEMENTS`): for i to Dimension-\ 1 do for j from i+1 to Dimension do history := enterentry(M,i,j,history): tensor.MetricName.2[-i,-j] := M[i,j] od od elif nargs = Dimension then for i to Dimension do tensor.MetricName.2[-i,-i] := args[i] od: for i to Dimension-1 do for j from i+1 to Dimension do tensor.MetricName.2[-i,-j] := 0 od od elif nargs = 1/2*Dimension*(Dimension+1) then n := 1: for i to Dimension do for j from i to Dimension do M[i,j] := args[n]: tensor.MetricName.2[-i,-j] := '"': n := n+1 od od elif nargs = Dimension^2 then for i to Dimension do for j to Dimension do M[i,j] := args[4*i-4+j]: tensor.MetricName.2[-i,-j] := '"' od od else ERROR(`wrong number (or type) of arguments`) fi: if {seq(seq(tensor. MetricName.2[-i,-j],j = i+1 .. Dimension),i = 1 .. Dimension-1)} = {0} then `Riemann/g_is_diag` := true: `Riemann/detg` := '`Riemann/detg`' else `Riemann/g_is_diag` := false: `Riemann/detg` := linalg[det](M): Minv := evalm( 1/M): for i to Dimension do for j from i to Dimension do tensor.MetricName.2[i ,j] := `Riemann/simp_function`(Minv[i,j]) od od fi: `Riemann/g_is_active` := true: `Riemann/eta_is_active` := false: if `Riemann/DisplayTensor` then i := ' i': j := 'j': print(`The components of the metric are:`): show(MetricName[-i,- j]) fi: NULL end,(apply)=proc (F, expr) local tensorname, N, ind, SYMM: option `Copyright 1995 by Renato Portugal`: if type(expr,constanttensor) then tensorname := `Riemann/tensorname`(expr,N): ind := op(3,`Riemann/indices`(expr )) elif type(expr,tensor = algebraic) then op(1,expr): tensorname := `Riemann/tensorname`(",N): ind := op(3,`Riemann/indices`("")) else ERROR( `the 2nd argument must be type constanttensor or a tensor equation`) fi: if assigned(tensor.tensorname.N[0,2]) then SYMM := tensor.tensorname.N[0,2] else SYMM := 'nosymm' fi: `Riemann/apply`(SYMM,ind,args) end,(acomp)=proc (expr1::( constanttensor = algebraic)) local expr, tensorname, N, A, B, T: option `Copyright 1995 by Renato Portugal`: if 1 < nargs then procname(expr1): RETURN (procname(args[2 .. nargs])) fi: expr := `Riemann/ltensor/ltensor`(expr1): A := op(1,expr): B := op(2,expr): if not type(op(4,`Riemann/indices`(A)),list( numericindex)) then ERROR( `the tensor in lhs must have indices of numeric type`) elif nops(op(2, `Riemann/indices`(B))) <> 0 then ERROR(`rhs cannot have free indices`) fi: tensorname := `Riemann/tensorname`(A,N): T := tensor.tensorname.N: if not assigned(T[0,1]) then ERROR(`use definetensor to define the tensor`,A) fi: assign(subs(tensorname = T,`Riemann/sink`(A) = `Riemann/sum`(B))): `Riemann/_` (expr1) end,(dalembertian)=proc (expr1::uneval) local expr: option `Copyright 1997 by R. Portugal. All rights reserved.`: if nargs <> 1 then ERROR(`expecting 1 argument, got `.nargs) fi: expr := `Riemann/ltensor/ltensor`(expr1): if type('dalembertian'(expr), tensorexpression) then `Riemann/dalembertian/algebraic`(expr) fi end,( clearbint)=proc () option `Copyright 1995 by R. Portugal and S.L. Sautu`: if `Riemann/g_is_active` then `Riemann/holonomic_frame`(): RETURN(NULL) elif `Riemann/Vierbein_is_active` then `Riemann/rigid_frame`(): RETURN(NULL) else ERROR(`neither the metric nor the vierbein are active`) fi end,(comp)=proc ( expr1::tensor) local ind, tensorname, N, expr: option `Copyright 1995 by Renato Portugal`: expr := subs(`t*e*n*s*o*r` = proc (x) x end,`` = proc (x) x end,expr1): tensorname := `Riemann/tensorname`(expr,N): ind := `Riemann/indices`(expr): if assigned(tensor.tensorname.N[0,1]) then expr := subs(tensorname = tensor.tensorname.N,`Riemann/sink`(expr)) else expr := `Riemann/sink`(expr) fi: if op(1,ind) = [] and op(3,ind) = [] then `Riemann/_`(expr1): `Riemann/printt`(eval(expr)) else ERROR(`not a component`) fi end,(evalt)=proc (expr1, arg2) local expr, N, ind, tensorname, A, B, SYMM: global nosymm: option `Copyright 1995 by Renato Portugal`: expr := `Riemann/ltensor/ltensor`(expr1): if type(expr,tensor) then tensorname := `Riemann/tensorname`(expr,N): ind := op(3,`Riemann/indices`(expr)): if assigned(tensor.tensorname.N[0,2]) then SYMM := tensor.tensorname.N[0,2] else SYMM := 'nosymm' fi: `Riemann/_`(expr1): `Riemann/sum`(expr): if ind = [] then RETURN(`Riemann/printt`(eval("))) fi: `Riemann/for`(expr,'"',ind,false,SYMM) elif type(expr,algebraic) then ind := op(3,`Riemann/indices`(expr)): `Riemann/_`(expr1): `Riemann/sum`(expr): if ind = [] then RETURN( `Riemann/printt`(eval("))) fi: `Riemann/for`(component[op(ind)],'"',ind,false, 'nosymm') elif type(expr,tensor = algebraic) then A := lhs(expr): B := rhs( expr): tensorname := `Riemann/tensorname`(A,N): ind := op(3,`Riemann/indices`( A)): if `Riemann/iv` and {op(ind)} <> {op(op(3,`Riemann/indices`(B)))} then if nargs = 2 then if arg2 <> ('noiv') then ERROR(`2nd argument must be noiv`) fi else print(`Riemann/printt`(expr)): ERROR(`wrong choice of free indices`) fi fi: if assigned(tensor.tensorname.N[0,2]) then SYMM := tensor.tensorname.N[0,2 ] else SYMM := 'nosymm' fi: `Riemann/_`(expr1): `Riemann/sum`(A), `Riemann/sum`(B): `Riemann/for`('"',ind,false,SYMM) else ERROR( `argument must be a tensor or a tensor equation `) fi end,(tdiff)=proc (expr1, x1) local expr, x: option `Copyright 1997 by R. Portugal. All rights reserved.`: if nargs < 2 then ERROR (`wrong number of arguments.`) elif 2 < nargs then args[3 .. nargs]: RETURN( Riemann[tdiff](Riemann[tdiff](expr1,x1),")) fi: if type(expr1,{set, `=`, list} ) then args[2 .. nargs]: RETURN(eval(map(''procname'',expr1,"))) fi: expr := `Riemann/ltensor/ltensor`(expr1): x := subs(tensor.CoordinateName.1 = CoordinateName,`Riemann/ltensor/ltensor`(x1)): if not (type(x,'string') or type(x,constanttensor)) or type(x,constanttensor) and (nops(x) <> 1 or `Riemann/abs`(op(x)) <> op(x) or op(0,x) <> CoordinateName) then ERROR(`second\ argument must be of the form CoordinateName[i], where i is a positive index, \ or must be a parameter`) elif type(x,constanttensor) and type(op(x),'string') and member(-op(x),`Riemann/allindices`(subs(('tdiff') = (''tdiff''),expr))) then ERROR(`wrong choice of indices`) fi: if type('tdiff'(expr,x), tensorexpression) then `Riemann/tdiff/algebraic`(expr,x) fi end,(symmetrize)= proc (expr1::uneval, SYMM::name) local expr, ind, i, symmetrize1: option `Copyright 1997 by R. Portugal. All rights reserved.`: if nargs = 0 then ERROR (`wrong number of arguments`) fi: expr := `Riemann/ltensor/ltensor`(expr1): if not type(expr,tensorexpression) then ERROR( `expecting argument to be of type tensorexpression`) fi: ind := op(3, `Riemann/indices`(expr)): if not (type(ind,list(covariantindex)) or type(ind, list(contravariantindex))) then ERROR( `expecting all indices to be covariant or contravariant`) fi: ind := `Riemann/abs`(ind): if nargs = 1 then `Riemann/printt`(`Riemann/symmetrize`( expr,[symm, ind])) elif 1 < nargs then symmetrize1 := proc (x, ind) local ind1 , symmetrize2, op0: symmetrize2 := proc (ind1, ind) local n, i: if type(ind1, list('contravariantnameindex')) then ind1 elif type(ind1,list('posint')) then n := nops(ind): for i in ind1 do if n < i then ERROR(`a number referred in the\ symmetry is bigger then the number of indices of first argument`) fi od: map( op,ind1,ind) else ERROR( `coundn't recognize the indices involved in the symmetry`) fi end: if type(x,' string') then if member(x,`Riemann/symmetrynames`) then if member(x,{'symmpair , antisymmpair'}) then ERROR(`the pair of indices is of the form `.x. `[ind1][ind2]`) else [x, ind] fi else ERROR( `the name for symmetry must belongs to the set `.(convert( `Riemann/symmetrynames`,'string'))) fi elif type(x,'indexed') then op0 := op(0 ,x): if type(op0,'indexed') then if member(op(0,op0),{'symmpair, antisymmpair' }) then [op(0,op0), symmetrize2([op(op0)],ind), symmetrize2([op(x)],ind)] else ERROR(`the symmetries with two sets of indices are symmpair[i,j,...][k,l,...] \ or antisymmpair[i,j,...][k,l,...], where i,j,k,l,... are indices or numbers`) fi elif member(op(0,x),`Riemann/symmetrynames`) then [op(0,x), symmetrize2([op (x)],ind)] elif type(op0,'string') then procname(op(0,x)) else ERROR( `coundn't recognize the symmetry`) fi else ERROR( `the symmetry is of wrong form. It must be a string or an indexed variable`) fi end: `Riemann/printt`(`Riemann/symmetrize`(expr,seq(symmetrize1(i,ind),i = args[2 .. nargs]))) fi end,(clearcomp)=proc (expr1::constanttensor) local newexpr, ind, tensorname, N, expr, n, T: option `Copyright 1995 by Renato Portugal`: if 1 < nargs then procname(args[1]): RETURN(procname(args[2 .. nargs])) fi: expr := `Riemann/ltensor/ltensor`(expr1 ): tensorname := `Riemann/tensorname`(expr,N): T := tensor.tensorname.N: ind := op(3,`Riemann/indices`(expr)): n := nops(ind): if n <> N and n <> 0 then ERROR(`all indices of tensor`,expr,`must be type numericindex or free indices` ) fi: if not assigned(T[0,1]) then ERROR(`this tensor has not been defined`) fi: newexpr := subs(tensorname = T,`Riemann/sink`(expr)): if n = 0 then assign (newexpr,newexpr) else assign(op(map(proc (y) op(1,y) = op(1,y) end,[ `Riemann/seq`(newexpr = 0,ind,T[0,2])]))) fi: `Riemann/_`(expr1) end,( viertocoord)=proc (T1::tensor) local ind, ind1, tensorname, N, T, i: option `Copyright 1995 by Renato Portugal`: T := subs(`t*e*n*s*o*r` = proc (x) x end, `` = proc (x) x end,T1): tensorname := `Riemann/tensorname`(T,N): ind := `Riemann/indices`(T): if ind[1] <> [] then ERROR(T1, `cannot have summed indices`) fi: ind := op(3,ind): if nops(ind) <> N then ERROR(T1,`cannot have numeric indices`) fi: ind1 := []: ind1 := [1]: for i to 1000 while not type(map(`Riemann/abs`,ind1),list('string')) do ind1 := map( proc (x, ind, i) `Riemann/abs`(x): x/"*``.".i end,ind,ind,i) od: if i = 1001 then ERROR(`cannot find a name to the summed indices`) fi: `Riemann/printt`( convert(zip(proc (x, y) VierbeinName[-y,x] end,ind,ind1),`*`)*tensorname[op( ind1)]) end,(tmap)=proc (f::{procedure, name, numeric}, expr1) local expr, ind , tensorname, N, SYMM, A, B, res: global `Riemann/printt`, `t*e*n*s*o*r`: option `Copyright 1995 by Renato Portugal`: expr := `Riemann/ltensor/ltensor`( expr1): if f = ('ltensor') then `Riemann/printt` := `@`(`@`(eval,proc (y) subs (`t*e*n*s*o*r` = proc (x) x end,`` = proc (x) x end,y) end),eval( `Riemann/printt_old`)): res := tmap(proc (x) x end,expr1): `Riemann/printt` := eval(`Riemann/printt_old`): res elif f = ('lptensor') then `Riemann/printt` := `@`(`@`(`@`(lprint,eval),proc (y) subs(`t*e*n*s*o*r` = proc (x) x end,`` = proc (x) x end,y) end),eval(`Riemann/printt_old`)): tmap(proc (x) x end,expr1) : `Riemann/printt` := eval(`Riemann/printt_old`): NULL elif f = ('latex') then `Riemann/printt` := proc (x) latex(x) end: tmap(proc (x) x end,expr1): `Riemann/printt` := eval(`Riemann/printt_old`): NULL elif f = ('latextensor') then `Riemann/printt` := proc (x) eval(subs(`t*e*n*s*o*r` = `l*a*t*e*x`, `Riemann/printt_old`(x))): latex(") end: tmap(proc (x) x end,expr1): `Riemann/printt` := eval(`Riemann/printt_old`): NULL elif type(expr,tensor) then ind := op(3,`Riemann/indices`(expr)): tensorname := `Riemann/tensorname`( expr,N): if assigned(tensor.tensorname.N[0,2]) then SYMM := tensor.tensorname. N[0,2] else SYMM := 'nosymm' fi: `Riemann/_`(expr1): if type(f,'string') and substring(f,1 .. 1) = ('t') then t.f else f fi: `Riemann/sum`('"'(expr,args[3 .. nargs])): if ind = [] then RETURN(`Riemann/printt`(eval("))) fi: `Riemann/for`(component[op(ind)],'"',ind,false,SYMM) elif type(expr,algebraic) then ind := op(3,`Riemann/indices`(expr)): `Riemann/_`(expr1): if type(f,' string') and substring(f,1 .. 1) = ('t') then t.f else f fi: `Riemann/sum`('"' (expr,args[3 .. nargs])): if ind = [] then RETURN(`Riemann/printt`(eval("))) fi: `Riemann/for`(component[op(ind)],'"',ind,false,'nosymm') elif type(expr, tensor = algebraic) then A := lhs(expr): B := rhs(expr): ind := op(3, `Riemann/indices`(A)): if {op(ind)} <> {op(op(3,`Riemann/indices`(B)))} and `Riemann/iv` and `Riemann/DisplayTensor` then lprint( `*** warning: the free indices do not match`) fi: tensorname := `Riemann/tensorname`(A,N): if assigned(tensor.tensorname.N[0,2]) then SYMM := tensor.tensorname.N[0,2] else SYMM := 'nosymm' fi: `Riemann/_`(expr1): if type (f,'string') and substring(f,1 .. 1) = ('t') then t.f else f fi: B := `Riemann/sum`('"'(B,args[3 .. nargs])): if ind = [] then RETURN( `Riemann/printt`(A = eval(B))) fi: `Riemann/for`(A,B,ind,false,SYMM) else ERROR(argument,expr1,`must be type tensor, algebraic or tensor=algebraic`) fi end,(init)=proc () global Dimension, ConnectionName, CoordinateName, CodiffSumIndex, `Riemann/simp_function`, `Riemann/DisplayTensor`, `Riemann/ZeroIndex`, `Riemann/CoordIndices`, `Riemann/iv`, `Riemann/ltensor`, `Riemann/lptensor`, `Riemann/printtensor`, `Riemann/latex`, `Riemann/DiffAlias`, `Riemann/x_is_active`, `Riemann/g_is_active`, `Riemann/eta_is_active`, `Riemann/g_is_diag`, `Riemann/eta_is_diag`, `Riemann/Vierbein_is_diag`, `Riemann/Vierbein_is_active`, `Riemann/v_is_active`, `Riemann/iv_is_active`, `Riemann/deteta`: option `Copyright 1997 by R. Portugal. All rights reserved.`: Dimension := 4: if assigned(nosymm) or assigned(symm) or assigned(antisymm) then ERROR( `The variables nosymm, symm and antisymm must be unassigned`) fi: protect(' nosymm, symm, antisymm'): ConnectionName := Gamma: CoordinateName := X: CodiffSumIndex := {}: `Riemann/simp_function` := normal: `Riemann/DisplayTensor` := true: `Riemann/ZeroIndex` := false: `Riemann/CoordIndices` := false: `Riemann/iv` := true: `Riemann/ltensor` := false: `Riemann/lptensor` := false: `Riemann/printtensor` := true: `Riemann/latex` := false: `Riemann/DiffAlias` := false: `Riemann/x_is_active` := false: `Riemann/g_is_active` := false: `Riemann/eta_is_active` := false: `Riemann/g_is_diag` := false: `Riemann/eta_is_diag` := false: `Riemann/Vierbein_is_diag` := false: `Riemann/x_is_active` := false: `Riemann/g_is_active` := false: `Riemann/eta_is_active` := false: `Riemann/Vierbein_is_active` := false: `Riemann/v_is_active` := false: `Riemann/iv_is_active` := false: `Riemann/deteta` := '`Riemann/deteta`': NULL end,(simpfcn)=proc (x) global `Riemann/simp_function`: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 0 then if whattype( eval(`Riemann/simp_function`,1)) = procedure then eval(`Riemann/simp_function` ) else `Riemann/simp_function` fi elif type(x,{procedure, name}) or type(x, function) and op(0,x) = `@` then `Riemann/simp_function` := x: NULL else ERROR (`wrong argument type`) fi end,(readtensor)=proc (filename::string) local path : global `Riemann/tensor_path`: option `Copyright 1995 by Renato Portugal`: if nargs = 0 then ERROR(`the argument must be the name of a file`) elif assigned( `Riemann/tensor_path`) and `Riemann/tensor_path` <> `` then path := ``. `Riemann/tensor_path`.`/` else path := `` fi: read ``.path.filename: NULL end, (cleartensor)=proc (expr1::constanttensor) local tensorname, N, T, expr: option `Copyright 1995 by Renato Portugal`: if 1 < nargs then procname(args[1] ): RETURN(procname(args[2 .. nargs])) fi: expr := `Riemann/ltensor/ltensor`( expr1): tensorname := `Riemann/tensorname`(expr,N): T := tensor.tensorname.N: tensor.tensorname.N := T: `Riemann/_`(expr1): NULL end,(lptensor)=proc (expr) option `Copyright 1995 by Renato Portugal`: `Riemann/_`(expr): lprint( `Riemann/ltensor/ltensor`(expr)) end,(clear)=proc (expr1::constanttensor) local tensorname, N, T, TT, expr, symmetries: option `Copyright 1995 by Renato Portugal`: if 1 < nargs then procname(args[1]): RETURN(procname(args[2 .. nargs])) fi: expr := `Riemann/ltensor/ltensor`(expr1 ): tensorname := `Riemann/tensorname`(expr,N): T := tensor.tensorname.N: if not assigned(T[0,1]) then ERROR(`this tensor has not been defined`) fi: TT := eval(T): symmetries := op(select(type,[op(op(T))],'string')): tensor. tensorname.N := table(symmetries,[0 = T[0], (0, 1) = T[0,1], (0, 2) = T[0,2]]) : if assigned(TT[0,3]) then T[0,3] := TT[0,3] fi: if assigned(TT[0,4]) then T[ 0,4] := TT[0,4] fi: if assigned(TT[0,0,1]) then T[0,0,1] := TT[0,0,1] fi: if assigned(TT[0,0,2]) then T[0,0,2] := TT[0,0,2] fi: if assigned(TT[0,0,3]) then T[0,0,3] := TT[0,0,3] fi: `Riemann/_`(expr1): NULL end,(sumt)=proc (expr1) local expr: option `Copyright 1995 by Renato Portugal`: expr := `Riemann/ltensor/ltensor`(expr1): if type(expr,algebraic) then `Riemann/_`( expr1): `Riemann/printt`(eval(`Riemann/sum`(expr))) elif type(expr,`=`) then map(procname,expr) else ERROR(`argument must be an expression or an equation`) fi end,(coordinates)=proc () local i, entercoord, A, coordset, `coord->number` , `number->coord`: global x, `Riemann/CoordIndices`, `Riemann/x_is_active`, CoordinateName: option `Copyright 1995 by Renato Portugal`: if not type([args] ,list('string')) then ERROR(`The coordinates must be names`) elif member( CoordinateName,{args}) then ERROR( `CoordinateName and one of the coordinates are equal`) fi: `Riemann/CoordIndices` := false: if not (assigned(CoordinateName) or assigned( x)) then CoordinateName := X fi: if nargs = 0 then entercoord := proc (A, i) local e, p: `Riemann/emerge`(i): p := `enter the coordinate `.CoordinateName. `[`.".`]:`: e := traperror(readstat(p)): if e = NULL then e := traperror( readstat(p)) fi: while not type(e,'string') do lprint(cat( `*** enter a name not a variable type `,whattype(e))): lprint(``): e := traperror(readstat(p)) od: while e = lasterror do lprint(e): e := traperror( readstat(p)) od: A[i] := e end: A := array(1 .. Dimension,[]): for i to Dimension do entercoord(A,i) od: RETURN(procname(seq(A[i],i = 1 .. Dimension)) ) fi: if nargs = Dimension then coordset := {args}: `coord->number` := {seq( args[i] = i,i = 1 .. Dimension)}: `number->coord` := array(-Dimension .. Dimension,[seq(-args[Dimension+1-i],i = 1 .. Dimension), 0, args]) else ERROR( `the number of coordinates must be equal to Dimension`) fi: tensor. CoordinateName.1 := table([0 = `Riemann/DEFINED`, (0, 1) = CoordinateName, (0, 2) = ('nosymm'), (0, 0, 1) = coordset, (0, 0, 2) = `coord->number`, (0, 0, 3) = eval(`number->coord`)]): for i to Dimension do tensor.CoordinateName.1[i] := args[i] od: if `Riemann/DisplayTensor` then print(`The coordinates are:`): for i to Dimension do print(`Riemann/printt`(``.CoordinateName[i] = args[i])) od fi: `Riemann/x_is_active` := true: on('CoordIndices'): NULL end,( antisymmetrize)=proc (expr1::uneval) local expr, ind: option `Copyright 1997 by R. Portugal. All rights reserved.`: if nargs = 0 then ERROR (`wrong number of arguments`) fi: expr := `Riemann/ltensor/ltensor`(expr1): if not type(expr,tensorexpression) then ERROR( `expecting argument to be of type tensorexpression`) fi: ind := op(3, `Riemann/indices`(expr)): if not (type(ind,list(covariantindex)) or type(ind, list(contravariantindex))) then ERROR( `expecting all indices covariant or contravariant`) fi: `Riemann/printt`( `Riemann/symmetrize`(expr,[antisymm, `Riemann/abs`(ind)])) end,(printtensor)= proc (x) option `Copyright 1995 by Renato Portugal`: `Riemann/_`(x): `Riemann/printt/rec`(`Riemann/ltensor/ltensor`(x),false) end,(show)=proc ( expr1::tensor) local ind, tensorname, N, SYMM, expr, T: option `Copyright 1995 by Renato Portugal`: expr := subs(`t*e*n*s*o*r` = proc (x) x end,`` = proc (x) x end,expr1): tensorname := `Riemann/tensorname`(expr,N): T := tensor.tensorname.N: ind := `Riemann/indices`(expr): if assigned(T[0,2]) then SYMM := T[0,2]: expr := subs(tensorname = T,`Riemann/sink`(expr)) else SYMM := 'nosymm': expr := `Riemann/sink`(expr) fi: if op(1,ind) = [] and op(3, ind) = [] then `Riemann/_`(expr1): RETURN(`Riemann/printt`(expr = eval(expr))) elif nops(op(3,ind)) = N then `Riemann/for`(expr,eval(expr),op(3,ind),false, SYMM) else ERROR(`print all components or just one component`) fi: `Riemann/_` (expr1): NULL end]): `Riemann/summedindices1` := proc (expr) local i: option `Copyright 1997 by R. Portugal. All rights reserved.`: if type(expr,'indexed') then op(op(1,`Riemann/indices`(expr))) elif type(expr,{`*`, `+`, `^`, ' function'}) then op(op(1,`Riemann/indices`(expr))), seq(procname(i),i = expr) else NULL fi end: `Riemann/for/antisymm` := proc (A, B, ind1, ind2, atrib, firstindex, p_name) local i, l1, Lind1: option `Copyright 1995 by Renato Portugal`: if ind1 = [] then `Riemann/for/`.p_name(A,B,ind2,[],atrib,1,'nosymm') else l1 := op(1,ind1) : Lind1 := subsop(1 = NULL,ind1): for i from firstindex to Dimension do procname(op(subs(l1 = i,'[A, B]')),Lind1,ind2,atrib,i+1,p_name) od fi end: `index/Riemann/calc_C` := proc (ind, T) local i, j, k, m, n, t, tt, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): k := op(3,ind): if type(k,contravariantindex) then if `Riemann/eta_is_diag` then s := tensor.MetricVName.2[k,k]*procname([i, j, - k],T) else s := 0: for m to Dimension do tensor.MetricVName.2[k,m]: if ('"') <> 0 then s := s+('"')*procname([i, j, -m],T) fi od fi elif type(j, contravariantindex) then if `Riemann/eta_is_diag` then if j < -k then s := tensor.MetricVName.2[j,j]*procname([i, -j, k],T) else s := -tensor.MetricVName .2[j,j]*procname([i, k, -j],T) fi else s := 0: for m to Dimension do if m <> - k then tensor.MetricVName.2[j,m]: if ('"') <> 0 then if m < -k then s := s+('" ')*procname([i, -m, k],T) else s := s-('"')*procname([i, k, -m],T) fi fi fi od fi elif type(i,covariantindex) then if `Riemann/eta_is_diag` then s := tensor. MetricVName.2[i,i]*procname([-i, j, k],T) else s := 0: for m to Dimension do tensor.MetricVName.2[i,-m]: if ('"') <> 0 then s := s+('"')*procname([m, j, k] ,T) fi od fi else if `Riemann/Vierbein_is_diag` then s := (tensorDvierbein3[i, j,k]-tensorDvierbein3[i,k,j])*tensor.VierbeinName.2[j,-j]*tensor.VierbeinName. 2[k,-k] else s := 0: for m to Dimension do t := tensor.VierbeinName.2[j,m]: if t <> 0 then for n to Dimension do tt := tensor.VierbeinName.2[k,n]: if tt <> 0 then s := s+(tensorDvierbein3[i,-m,-n]-tensorDvierbein3[i,-n,-m])*t*tt fi od fi od fi fi: T[i,j,k] := `Riemann/simp_function`(s) fi else T[op(ind)] := op( args[3]) fi end: `index/Riemann/calc_RicciSq` := proc (ind, T) local i, j, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension do tensor.RicciName.2[-i,-i]: if ('"') <> 0 then s := s+('"')*tensor.RicciName.2[ i,i] fi: for j from i+1 to Dimension do tensor.RicciName.2[-i,-j]: if ('"') <> 0 then s := s+2*('"')*tensor.RicciName.2[i,j] fi od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/g_is_diag` := false: `index/Riemann/calc_LineElementV` := proc (ind, T) local dd, m, n, s, t: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned(T[op(ind)]) or ind <> [] then T[op(ind)] else dd := readlib( `tools/gensym`)('d'): if `Riemann/Vierbein_is_diag` then for n to Dimension do t[n] := tensor.VierbeinName.2[n,-n]*dd(tensor.CoordinateName.1[n]) od else for n to Dimension do t[n] := sum('tensor.VierbeinName.2[n,-m]*dd(tensor. CoordinateName.1[m])',('m') = 1 .. Dimension) od fi: s := 0: if not `Riemann/eta_is_diag` then for m to Dimension do for n from m+1 to Dimension do s := s+2*tensor.MetricVName.2[-m,-n]*t[m]*t[n] od od fi: T[] := s+sum(' tensor.MetricVName.2[-m,-m]*t[m]^2',('m') = 1 .. Dimension) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/seq/antisymm` := proc (expr, ind1, ind2, firstindex, p_name) local i, l1, Lind1: option `Copyright 1995 by Renato Portugal`: if ind1 = [] then `Riemann/seq/`.p_name(expr,ind2,[],1,'nosymm') else l1 := op(1,ind1): Lind1 := subsop(1 = NULL,ind1): seq(procname(subs(l1 = i,'expr'),Lind1,ind2,i+1,p_name) ,i = firstindex .. Dimension) fi end: `Riemann/for/nosymm` := proc (A, B, ind1, ind2, atrib, firstindex, p_name) local i, l1, Lind1, x: global `Riemann/switch1`: option `Copyright 1995 by Renato Portugal`: if ind1 = [] then if ind2 = [] then x := eval(B): if `Riemann/DisplayTensor` and x <> 0 then print(`Riemann/printt`(('A ') = x)): `Riemann/switch1` := false fi: if atrib then A := x fi: NULL else `Riemann/for/`.p_name(A,B,ind2,[],atrib,1,'nosymm') fi else l1 := op(1,ind1): Lind1 := subsop(1 = NULL,ind1): for i to Dimension do procname(op(subs(l1 = i, '[A, B]')),Lind1,ind2,atrib,1,p_name) od fi end: `index/Riemann/calc_m1rV` := proc (ind, T) local s, i, j: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension do tensor.TclRicciVName.2[i,i]: if ('"') <> 0 then s := s+1/8*('"')*tensor. SWVName.2[-i,-i] fi: for j from i+1 to Dimension do tensor.TclRicciVName.2[i,j ]: if ('"') <> 0 then s := s+1/4*('"')*tensor.SWVName.2[-i,-j] fi od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/apply/nosymm` := proc (A, ind1, ind2, firstindex, p_name, F) local i, l1, Lind1: global `Riemann/switch1`: option `Copyright 1995 by Renato Portugal`: if ind1 = [] then if ind2 = [] then F(A, args[7 .. nargs]) else `Riemann/apply/`.p_name(A,ind2,[],1,'nosymm',args[6 .. nargs]) fi else l1 := op(1,ind1): Lind1 := subsop(1 = NULL,ind1): for i to Dimension do procname(subs(l1 = i,'A'),Lind1,ind2,1,p_name,args[6 .. nargs]) od fi end: `index/Riemann/calc_Riemann` := proc (ind, T) local i, j, k, l, m, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): k := op(3,ind): l := op(4,ind): if type(l, contravariantindex) then if `Riemann/g_is_diag` then s := tensor.MetricName.2[ l,l]*procname([i, j, k, -l],T) else s := 0: for m to Dimension do tensor. MetricName.2[l,m]: if ('"') <> 0 then s := s+('"')*procname([i, j, k, -m],T) fi od fi elif type(k,contravariantindex) then if `Riemann/g_is_diag` then if k < -l then s := tensor.MetricName.2[k,k]*procname([i, j, -k, l],T) else s := - tensor.MetricName.2[k,k]*procname([i, j, l, -k],T) fi else s := 0: for m to Dimension do if m <> -l then tensor.MetricName.2[k,m]: if ('"') <> 0 then if m < -l then s := s+('"')*procname([i, j, -m, l],T) else s := s-('"')*procname([i , j, l, -m],T) fi fi fi od fi elif type(j,contravariantindex) then if `Riemann/g_is_diag` then s := tensor.MetricName.2[j,j]*procname([i, -j, k, l], T) else s := 0: for m to Dimension do tensor.MetricName.2[j,m]: if ('"') <> 0 then s := s+('"')*procname([i, -m, k, l],T) fi od fi elif type(i, contravariantindex) then if `Riemann/g_is_diag` then if i < -j then s := tensor.MetricName.2[i,i]*procname([-i, j, k, l],T) else s := -tensor. MetricName.2[i,i]*procname([j, -i, k, l],T) fi else s := 0: for m to Dimension do if m <> -j then tensor.MetricName.2[i,m]: if ('"') <> 0 then if m < -j then s := s+('"')*procname([-m, j, k, l],T) else s := s-('"')*procname([j, -m, k, l ],T) fi fi fi od fi else s := 0: for m to Dimension do s := s+tensor. ChristoffelName.3[-m,i,k]*tensor.ChristoffelName.3[m,j,l]-tensor. ChristoffelName.3[-m,i,l]*tensor.ChristoffelName.3[m,j,k] od: s := RiemannSign *(s+1/2*tensorD2metric4[i,k,l,j]-1/2*tensorD2metric4[j,k,i,l]-1/2* tensorD2metric4[i,l,j,k]+1/2*tensorD2metric4[j,l,i,k]) fi: T[op(ind)] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_m3V` := proc (ind, T) local s, i, j: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension do s := s+1/16*tensor.SWVName.2[-i,-i]*tensor.SWVName.2[i,i]+1/16*tensor. SWStarVName.2[-i,-i]*tensor.SWStarVName.2[i,i]: for j from i+1 to Dimension do s := s+1/8*tensor.SWVName.2[-i,-j]*tensor.SWVName.2[i,j]+1/8*tensor. SWStarVName.2[-i,-j]*tensor.SWStarVName.2[i,j] od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/ltensor/ltensor` := proc () local i: option `Copyright 1997 by R. Portugal. All rights reserved`: seq(eval(subs( `t*e*n*s*o*r` = proc (x::uneval) x end,`` = proc (x::uneval) x end,i)),i = args) end: `type/contravariantnameindex` := proc (x) options remember, system, `Copyright 1995 by Renato Portugal`: not type(x,numericindex) and type(x,' string') end: `index/Riemann/calc_SWStar` := proc (ind, T) local i, j, m, n, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): s := 0: for m to Dimension do tensor.TclRicciName.2 [m,m]: if ('"') <> 0 then s := s+tensor.WeylStarName.4[i,-m,-m,j]*('"') fi: for n from m+1 to Dimension do tensor.TclRicciName.2[m,n]: if ('"') <> 0 then s := s+('"')*(tensor.WeylStarName.4[i,-m,-n,j]+tensor.WeylStarName.4[i,-n,-m,j ]) fi od od: T[op(ind)] := `Riemann/simp_function`(s) fi else T[op(ind)] := op (args[3]) fi end: `Riemann/iv_is_active` := false: `Riemann/printt` := proc (x) option `Copyright 1995 by Renato Portugal`: if type(x,`=`) and not hastype(op(2,x),'indexed') then procname(op(1,x)) = op(2,x ) else `Riemann/printt/rec`(x,true) fi end: `type/functiontensor` := proc (x) options remember, system, `Copyright 1995 by Renato Portugal`: type(x,'function') and type(op(0,x),' indexed') and type(x,tensorexpression) end: `Riemann/DiffAlias` := false: `Riemann/hastensor` := proc (expr, T) local tensorname, N, i: option `Copyright 1995 by Renato Portugal`: tensorname := `Riemann/tensorname`(T,N): if not has(expr,tensorname) then RETURN(false) fi: for i in indets(expr,tensor ) do if `Riemann/equal`(i,T) then RETURN(true) fi od: false end: `index/Riemann/calc_g` := proc (ind, T) local i, j: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): if type(i,covariantindex) then T[op(ind)] elif type (j,covariantindex) then if i = -j then T[op(ind)] := 1 else T[op(ind)] := 0 fi elif `Riemann/g_is_diag` then if i = j then T[op(ind)] := 1/tensor.MetricName. 2[-i,-j] else T[op(ind)] := 0 fi else T[op(ind)] fi fi else T[op(ind)] := op( args[3]) fi end: `Riemann/convert/matrix` := proc (A) local i, j, m, n, B, C, l1, l2, u1, u2, d , x, attr: option `Copyright (c) 1990 by the University of Waterloo. All rights reserved.`: if type(A,'listlist') then if _EnvLinalg95 = true then matrix(array(A),list) else array(A) fi elif type(A,'vector') then n := linalg['vectdim'](A): if _EnvLinalg95 = true and type(A,list) then attr := readlib( `linalg/getattribute`)(A): if attr = ('row') then matrix(1,n,A,list) elif attr = ('column') then matrix(n,1,map(proc (x) options operator, arrow: [x] end,A), list) else B := setattribute(A,'column'): `convert/matrix`(B) fi else if type( A,'name') then C := op(A) else C := A fi: array(1 .. linalg['vectdim'](C),1 .. 1,map(proc (x) options operator, arrow: [x] end,convert(C,list))): subs(('C') = A,"): if has(",'C') then ERROR(`unnamed matrix element`) fi: RETURN(") fi elif type(A,'transpose(vector)') then linalg['transpose'](`convert/matrix`(op( A))) elif type(A,array) then if type(A,name) then d := [op(2,op(A))] else d := [op(2,A)] fi: if type(A,name) then x := op(1,op(A)) else x := op(1,A) fi: if nops(d) <> 2 then ERROR(`invalid arguments`) fi: l1 := op(1,d[1]): u1 := op(2, d[1]): m := u1-l1+1: l2 := op(1,d[2]): u2 := op(2,d[2]): n := u2-l2+1: B := array(1 .. m,1 .. n,x): for i from l1 to u1 do for j from l2 to u2 do if assigned(A[i,j]) then B[i-l1+1,j-l2+1] := A[i,j] fi od od: op(B) else ERROR( `expecting array or list`) fi end: `Riemann/Vierbein_is_active` := false: `Riemann/seq/nosymm` := proc (expr, ind1, ind2, firstindex, p_name) local i, l1, Lind1: option `Copyright 1995 by Renato Portugal`: if ind1 = [] then if ind2 = [] then if type(expr,`=`) then op(1,expr) = eval(op(2,expr)) else eval( expr) fi else `Riemann/seq/`.p_name(expr,ind2,[],1,'nosymm') fi else l1 := op( 1,ind1): Lind1 := subsop(1 = NULL,ind1): seq(procname(subs(l1 = i,'expr'), Lind1,ind2,1,p_name),i = 1 .. Dimension) fi end: `index/Riemann/calc_WeylV` := proc (ind, T) local i, j, k, l, m, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): k := op(3,ind): l := op(4,ind): if type(l, contravariantindex) then if `Riemann/eta_is_diag` then s := tensor.MetricVName .2[l,l]*procname([i, j, k, -l],T) else s := 0: for m to Dimension do tensor. MetricVName.2[l,m]: if ('"') <> 0 then s := s+('"')*procname([i, j, k, -m],T) fi od fi elif type(k,contravariantindex) then if `Riemann/eta_is_diag` then if k < -l then s := tensor.MetricVName.2[k,k]*procname([i, j, -k, l],T) else s := -tensor.MetricVName.2[k,k]*procname([i, j, l, -k],T) fi else s := 0: for m to Dimension do if m <> -l then tensor.MetricVName.2[k,m]: if ('"') <> 0 then if m < -l then s := s+('"')*procname([i, j, -m, l],T) else s := s-('"')*procname( [i, j, l, -m],T) fi fi fi od fi elif type(j,contravariantindex) then if `Riemann/eta_is_diag` then s := tensor.MetricVName.2[j,j]*procname([i, -j, k, l],T) else s := 0: for m to Dimension do tensor.MetricVName.2[j,m]: if ('"') <> 0 then s := s+('"')*procname([i, -m, k, l],T) fi od fi elif type(i, contravariantindex) then if `Riemann/eta_is_diag` then if i < -j then s := tensor.MetricVName.2[i,i]*procname([-i, j, k, l],T) else s := -tensor. MetricVName.2[i,i]*procname([j, -i, k, l],T) fi else s := 0: for m to Dimension do if m <> -j then tensor.MetricVName.2[i,m]: if ('"') <> 0 then if m < -j then s := s+('"')*procname([-m, j, k, l],T) else s := s-('"')*procname( [j, -m, k, l],T) fi fi fi od fi else s := 0: tensor.MetricVName.2[i,k]: if ('" ') <> 0 then s := ('"')*tensor.RicciVName.2[j,l] fi: tensor.MetricVName.2[i,l] : if ('"') <> 0 then s := s-('"')*tensor.RicciVName.2[j,k] fi: tensor. MetricVName.2[j,l]: if ('"') <> 0 then s := s+('"')*tensor.RicciVName.2[i,k] fi: tensor.MetricVName.2[j,k]: if ('"') <> 0 then s := s-('"')*tensor. RicciVName.2[i,l] fi: s := tensor.RiemannVName.4[i,j,k,l]+RicciVSign/( Dimension-2)*s+RicciVSign/(Dimension-1)/(Dimension-2)*tensor.RicciScalarVName. 0[]*(tensor.MetricVName.2[i,l]*tensor.MetricVName.2[j,k]-tensor.MetricVName.2[ i,k]*tensor.MetricVName.2[j,l]) fi: T[i,j,k,l] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_m3` := proc (ind, T) local s, i, j: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension do s := s+1/16*tensor.SWName.2[-i,-i]*tensor.SWName.2[i,i]+1/16*tensor.SWStarName.2 [-i,-i]*tensor.SWStarName.2[i,i]: for j from i+1 to Dimension do s := s+1/8* tensor.SWName.2[-i,-j]*tensor.SWName.2[i,j]+1/8*tensor.SWStarName.2[-i,-j]* tensor.SWStarName.2[i,j] od od: T[] := `Riemann/simp_function`(s) fi else T[op (ind)] := op(args[3]) fi end: `index/Riemann/calc_m4` := proc (ind, T) local s, i, j, m: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for m to Dimension do for i to Dimension do tensor.TclRicciName.2[-i,-i]: if ('"') <> 0 then s := s-\ 1/32*('"')*(tensor.SWName.2[i,-m]*tensor.SWName.2[i,m]+tensor.SWStarName.2[i,- m]*tensor.SWStarName.2[i,m]) fi: for j from i+1 to Dimension do tensor. TclRicciName.2[-i,-j]: if ('"') <> 0 then s := s-1/16*('"')*(tensor.SWName.2[i ,-m]*tensor.SWName.2[j,m]+tensor.SWStarName.2[i,-m]*tensor.SWStarName.2[j,m]) fi od od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3 ]) fi end: `Riemann/printtensor_old` := proc (x) option `Copyright 1995 by Renato Portugal`: `Riemann/_`(x): `Riemann/printt/rec`( `Riemann/ltensor/ltensor`(x),false) end: `type/nametensor` := proc (x) options remember, system, `Copyright 1997 by R. Portugal. All right reserved.`: type(x,tensor) and type( op(3,`Riemann/indices`(x)),list(nameindex)) end: `index/Riemann/calc_Einstein` := proc (ind, T) local s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else s := 0 : tensor.MetricName.2[op(ind)]: if ('"') <> 0 then s := 1/2*('"')*tensor. RicciScalarName.0[] fi: T[op(ind)] := `Riemann/simp_function`(tensor.RicciName .2[op(ind)]-s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_m5rV` := proc (ind, T) local s, i, j, k, l, t: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension-1 do for j from i+1 to Dimension do tensor.WeylVName.4[i,j,i,j]: if ('"') <> 0 then s := s+1/16*('"')*(tensor.SWVName.2[-i,-j]^2-tensor.SWVName.2[-i,-i]*tensor. SWVName.2[-j,-j]+tensor.SWStarVName.2[-i,-j]^2-tensor.SWStarVName.2[-i,-i]* tensor.SWStarVName.2[-j,-j]) fi: for k from i to Dimension-1 do if k = i then t := j+1 else t := k+1 fi: for l from t to Dimension do tensor.WeylVName.4[i,j ,k,l]: if ('"') <> 0 then s := s+1/8*('"')*(tensor.SWVName.2[-i,-l]*tensor. SWVName.2[-j,-k]-tensor.SWVName.2[-i,-k]*tensor.SWVName.2[-j,-l]+tensor. SWStarVName.2[-i,-l]*tensor.SWStarVName.2[-j,-k]-tensor.SWStarVName.2[-i,-k]* tensor.SWStarVName.2[-j,-l]) fi od od od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_w2rV` := proc (ind, T) local s, i, j, k, l, t: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension-1 do for j from i+1 to Dimension do for k from i to Dimension-1 do if k = i then t := j else t := k+1 fi: for l from t to Dimension do tensor.WWVName.4[-i,-j,-k, -l]: if ('"') <> 0 then if i = k and j = l then s := s-1/4*tensor.WeylVName.4[ i,j,k,l]*('"') else s := s-1/2*tensor.WeylVName.4[i,j,k,l]*('"') fi fi od od od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/sw` := proc (z) if z then on else off fi end: `Riemann/codiff/numer` := proc (expr1, S) local p, ind, ind4, i, a, S1: option `Copyright 1997 by R. Portugal. All rights reserved.`: ind := [op(expr1)]: ind4 := select(type,ind,numericindex): S1 := NULL: for i in ind4 do if member( i,ind,'p') then a := readlib(`tools/gensym`)(a.p): if type(i, contravariantindex) then ind := subsop(p = a,ind): S1 := S1, a = i else ind := subsop(p = -a,ind): S1 := S1, a = -i fi else ERROR(`implementation error`) fi od: S := {S1}: op(0,expr1)[op(ind)] end: `Riemann/ltensor` := false: `index/symm` := proc (ind, T) local ind1: option `Copyright 1997 by R. Portugal. All rights reserved.`: if ind <> [] and ind[1] = 0 then if nargs = 2 then eval(T[op(ind)]) else T[op(ind)] := op(args[3]) fi: RETURN('"') fi: ind1 := `Riemann/ind1`(ind): if nargs = 2 then eval(T[op(ind1) ]) else T[op(ind1)] := op(args[3]) fi end: `type/tensorexpression` := proc (x) local ind, tensornames, S, x1, i: options remember, system, `Copyright 1997 by R. Portugal. All rights reserved`: if type(x,'algebraic') then if select(type,map(proc (i) options operator, arrow: op(0,i) end,indets(x,'function')),'indexed') <> {} then ERROR( `tensor function not allowed`) fi: ind := traperror(`Riemann/indices`(x)): if ind <> lasterror then if `intersect`(`Riemann/summedindices`(x),{op(op(2,ind)) }) = {} then S := indets(x,'indexed'): ind := `Riemann/abs`(select(type,map(op ,S),nameindex)): tensornames := map(proc (i) options operator, arrow: op(0,i) end,S): if `intersect`(tensornames,ind) = {} then x1 := subs({seq(op(i,S) = readlib(`tools/gensym`)(evaln(a.i)),i = 1 .. nops(S))},x): for i in ind do if has(x1,i) then ERROR(`variable and index have same name `.i) fi od: 'true' else ERROR(`tensor and index have same name`) fi else ERROR( `summed index equal to free index`) fi else ERROR(lasterror) fi else false fi end: `Riemann/codiff/usedind` := `Riemann/codiff/usedind1`: `index/Riemann/calc_SWVStar` := proc (ind, T) local i, j, m, n, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): s := 0: for m to Dimension do tensor.TclRicciVName. 2[m,m]: if ('"') <> 0 then s := s+tensor.WeylStarVName.4[i,-m,-m,j]*('"') fi: for n from m+1 to Dimension do tensor.TclRicciVName.2[m,n]: if ('"') <> 0 then s := s+('"')*(tensor.WeylStarVName.4[i,-m,-n,j]+tensor.WeylStarVName.4[i,-n,-m ,j]) fi od od: T[op(ind)] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/apply/symm` := proc (A, ind1, ind2, firstindex, p_name) local i, l1, Lind1: option `Copyright 1995 by Renato Portugal`: if ind1 = [] then `Riemann/apply/`.p_name(A,ind2,[],1,'nosymm',args[6 .. nargs]) else l1 := op(1 ,ind1): Lind1 := subsop(1 = NULL,ind1): for i from firstindex to Dimension do procname(subs(l1 = i,'A'),Lind1,ind2,i,p_name,args[6 .. nargs]) od fi end: `print/t*e*n*s*o*r` := proc (x) local printtensor_f: options remember, system, `Copyright 1995 by Renato Portugal`: printtensor_f := proc (x) if `Riemann/ZeroIndex` then if x = O then RETURN(readlib('`tools/gensym`')(``)^ `0`) elif x = -O then RETURN(readlib('`tools/gensym`')(``)[`0`]) fi fi: if x = 1 then readlib('`tools/gensym`')(``)^`1` elif x = -1 then readlib(' `tools/gensym`')(``)[`1`] elif type(x,contravariantindex) then readlib(' `tools/gensym`')(``)^x elif type(x,covariantindex) then readlib(' `tools/gensym`')(``)[-x] else ERROR(x,`is not an index of correct type`) fi end: if type(x,'indexed') then map(printtensor_f,[op(x)]): convert([readlib(' `tools/gensym`')(op(0,x)), op(")],`*`) elif type(x,'function') and type(op(0,x ),'indexed') then map(printtensor_f,[op(op(0,x))]): convert([readlib(' `tools/gensym`')(op(0,op(0,x))), op("), readlib('`tools/gensym`')(``)(op(x))], `*`) else x fi end: `index/Riemann/calc_TclRicciV` := proc (ind, T) local i, j, m, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): if type(j,contravariantindex) then if `Riemann/g_is_diag` then s := tensor.MetricVName.2[j,j]*procname([i, -j],T) else s := 0: for m to Dimension do tensor.MetricVName.2[j,m]: if ('"') <> 0 then s := s+('"')*procname([i, -m],T) fi od fi elif type(i,contravariantindex) then if `Riemann/g_is_diag` then if i < -j then s := tensor.MetricVName.2[i,i] *procname([-i, j],T) else s := tensor.MetricVName.2[i,i]*procname([j, -i],T) fi else s := 0: for m to Dimension do tensor.MetricVName.2[i,m]: if ('"') <> 0 then if m < -j then s := s+('"')*procname([-m, j],T) else s := s+('"')* procname([j, -m],T) fi fi od fi else s := tensor.RicciVName.2[i,j]-1/Dimension *tensor.MetricVName.2[i,j]*tensor.RicciScalarVName.0[] fi: T[i,j] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/ZeroIndex` := false: `Riemann/symmetrize` := proc (expr, L) local i, L_odd, L_even, ZIP, SYMM, n, sign, ind1, ind2, sp: option `Copyright 1997 by R. Portugal. All rights reserved.`: if 2 < nargs then RETURN(procname(procname(expr,L),args[3 .. nargs])) fi: SYMM := op(1,L): if nops(L) = 2 then ind1 := op(2,L) else ind1 := op(2,L): ind2 := op(3,L) fi: n := nops(ind1): if n < 2 then RETURN(expr) fi: if SYMM = cyclic or SYMM = anticyclic then ZIP := proc (L1, L2, n) local i: seq(L1[i] = L2[i],i = 1 .. n) end: L_odd := `Riemann/permute`(ind1,odd,'L_even'): if SYMM = cyclic then 2/n! *add(subs({ZIP(ind1,i,n)},expr),i = L_even) else 2/n!*add(subs({ZIP(ind1,i,n)} ,expr),i = L_odd) fi elif SYMM = symm or SYMM = antisymm then ZIP := proc (L1, L2, n) local i: seq(L1[i] = L2[i],i = 1 .. n) end: if SYMM = symm then sign := 1 else sign := -1 fi: L_odd := `Riemann/permute`(ind1,odd,'L_even'): 1/n!*(add (subs({ZIP(ind1,i,n)},expr),i = L_even)+sign*add(subs({ZIP(ind1,i,n)},expr),i = L_odd)) elif SYMM = symmpair or SYMM = antisymmpair then if n <> nops(ind2) then ERROR( `the number of indices of each set in symmpair or antisymmpair must be equal`) elif `intersect`({op(ind1)},{op(ind2)}) <> {} or n <> nops({op(ind1)}) or n <> nops({op(ind2)}) then ERROR(`expecting different indices symmpair`) fi: ZIP := proc (L1, L2, n) local i: seq(L1[i] = L2[i],i = 1 .. n) end: if SYMM = symmpair then sign := 1 else sign := -1 fi: 1/2*expr+1/2*sign*subs({ZIP(ind1, ind2,n), ZIP(ind2,ind1,n)},expr) elif SYMM = symmbvt or SYMM = antisymmbvt then if SYMM = symmbvt then sign := 1: sp := symm else sign := -1: sp := antisymm fi: if not type(n,'even') then ERROR( `number of indices to be symmetrized must be even`) fi: ind2 := [op(1/2*n+1 .. n,ind1)]: ind1 := [op(1 .. 1/2*n,ind1)]: procname(expr,[sp, ind1],[sp, ind2],[ symmpair, ind1, ind2]) elif SYMM = riemann then if nops(ind1) <> 4 then ERROR( `the number of indices in riemann symmetry must be 4`) fi: procname(expr- procname(expr,[antisymm, [op(2 .. 4,ind1)]]),[antisymmbvt, ind1]) fi end: `index/Riemann/calc_m4V` := proc (ind, T) local s, i, j, m: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for m to Dimension do for i to Dimension do tensor.TclRicciVName.2[-i,-i]: if ('"') <> 0 then s := s -1/32*('"')*(tensor.SWVName.2[i,-m]*tensor.SWVName.2[i,m]+tensor.SWStarVName.2 [i,-m]*tensor.SWStarVName.2[i,m]) fi: for j from i+1 to Dimension do tensor. TclRicciVName.2[-i,-j]: if ('"') <> 0 then s := s-1/16*('"')*(tensor.SWVName.2 [i,-m]*tensor.SWVName.2[j,m]+tensor.SWStarVName.2[i,-m]*tensor.SWStarVName.2[j ,m]) fi od od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op( args[3]) fi end: `Riemann/apply/diagonal` := proc (A, ind1, ind2, firstindex, p_name) local i, Lind1: option `Copyright 1995 by Renato Portugal`: if ind1 = [] then `Riemann/apply/`.p_name(A,ind2,[],1,'nosymm',args[6 .. nargs]) else for i to Dimension do Lind1 := map(proc (x, i) x = i end,ind1,i): procname(subs(Lind1,' A'),[],ind2,1,p_name,args[6 .. nargs]) od fi end: `Riemann/eta_is_active` := false: `Riemann/abs` := proc (x) option `Copyright 1995 by Renato Portugal`: if type( x,{'list, set'}) then map(procname,x) elif type(x,{'string', 'posint'}) then x elif type(-x,{'string', 'posint'}) then -x elif x = 0 then if `Riemann/ZeroIndex` then ERROR(`use the letter O instead of zero`) else ERROR( `zero cannot be used as index when ZeroIndex is turned off`) fi else ERROR( `wrong index type`) fi end: `Riemann/tensorname` := proc (T, N) option `Copyright 1995 by Renato Portugal` : if type(T,'indexed') then if nargs = 2 then N := nops(T) fi: op(0,T): if type('"','indexed') then cat(procname('"'),`[`,op('"'),`]`) else '"' fi elif type(T,'function') then if nargs = 2 then procname(op(0,T),N) else procname(op (0,T)) fi elif type(T,'string') then if nargs = 2 then N := 0 fi: T else ERROR (`cannot find the name of the tensor `,T) fi end: `Riemann/equal` := proc (T1, T2) local N1, N2, ind1, ind2, f: option `Copyright 1995 by Renato Portugal`: f := proc (x) if op(1,x) = -1 then -1 else 1 fi end: ind1 := map(f,op(3,`Riemann/indices`(T1))): ind2 := map(f,op(3, `Riemann/indices`(T2))): evalb(ind1 = ind2 and `Riemann/tensorname`(T1,N1) = `Riemann/tensorname`(T2,N2)) end: `index/Riemann/calc_D2metric` := proc (ind, T) local i, j, k, l: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): k := op(3,ind): l := op(4,ind): if `Riemann/Riemann_order`(i,j) and `Riemann/Riemann_order`(k,l) then T[op(ind)] := diff(tensor.D1metric.3[i,j,k],tensor.CoordinateName.1[-l]) else T[op(ind)] := diff(tensor.D1metric.3[j,i,k],tensor.CoordinateName.1[-l]) fi fi else T[op( ind)] := op(args[3]) fi end: `index/Riemann/symm_C` := proc (ind, T) local j, k: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if ind[1] = 0 then if nargs = 2 then T[op(ind)] else T[op(ind)] := op(args[3]) fi else j := op(2,ind): k := op(3,ind): if j = k then if nargs = 2 then 0 elif op(args[3]) <> 0 then ERROR( `cannot assign non-zero to equal antisymmetric indices`) else T[op(ind)] := 0 fi elif not `Riemann/Riemann_order`(j,k) then if nargs = 2 then -T[op(1,ind),k ,j] else T[op(1,ind),k,j] := -op(args[3]) fi elif nargs = 2 then T[op(ind)] else T[op(ind)] := op(args[3]) fi fi end: `index/Riemann/calc_RicciCoeff` := proc (ind, T) local i, j, k, s, m: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): k := op(3,ind): if type(k,contravariantindex) then if `Riemann/eta_is_diag` then s := tensor.MetricVName.2[k,k]*procname([i, j, - k],T) else tensor.MetricVName.2[k,m]: if ('"') <> 0 then for m to Diemnsion do s := tensor.MetricVName.2[k,m]*procname([i, j, -m],T) od fi fi elif type(j, contravariantindex) then if `Riemann/eta_is_diag` then tensor.MetricVName.2[j, j]*procname([i, -j, k],T) else s := 0: for m to Diemnsion do tensor. MetricVName.2[j,m]: if ('"') <> 0 then s := s+('"')*procname([i, -m, k],T) fi od fi elif type(i,contravariantindex) then if `Riemann/eta_is_diag` then if i < -j then s := tensor.MetricVName.2[i,i]*procname([-i, j, k],T) elif -j < i then s := -tensor.MetricVName.2[i,i]*procname([j, -i, k],T) elif i = -j then s := 0 fi else s := 0: for m to Dimension do if m <> -j then tensor.MetricVName. 2[i,m]: if ('"') <> 0 then if m < -j then s := s+('"')*procname([-m, j, k],T) else s := s-('"')*procname([j, -m, k],T) fi fi fi od fi else s := 1/2*tensor. CommutCoeffName.3[k,i,j]+1/2*tensor.CommutCoeffName.3[j,i,k]+1/2*tensor. CommutCoeffName.3[i,k,j] fi: T[i,j,k] := `Riemann/simp_function`(s) fi else T[ op(ind)] := op(args[3]) fi end: `Riemann/sink` := proc (expr) local g, expr1, ii: option `Copyright 1995 by Renato Portugal`: if `Riemann/ZeroIndex` then g := proc (x) if type(x,numericindex) then if type(x,posint) then x+1 elif type(x,negint) then x-1 elif x = O then 1 elif x = -O then -1 else x fi else x fi end: if type(expr,index) then g(expr) elif type(expr,constanttensor) then op(0,expr): subs(('ii') = op(map(g,[op(expr)])),'"[ii]') elif type(expr,functiontensor) then op(0,op(0,expr)): subs(('ii') = op(map(g,[op(op(0,expr))])),'"[ii]'(op( expr))) fi else expr fi: expr1 := '"': if `Riemann/CoordIndices` then if type( expr1,index) then subs(tensor.CoordinateName.1[0,0,2],expr1) elif type(expr, constanttensor) then op(0,expr1): subs(('ii') = op(subs(tensor.CoordinateName. 1[0,0,2],[op(expr1)])),'"[ii]') elif type(expr,functiontensor) then op(0,op(0, expr1)): subs(('ii') = op(subs(tensor.CoordinateName.1[0,0,2],[op(op(0,expr1)) ])),'"[ii]')(op(expr1)) fi else expr1 fi end: `Riemann/latex/print` := proc (e) local texlist, `,`, `[`, `]`, `{`, `}`, `\\left `, `\\right `, `\\{`, `\\}`, `(`, `)`, ee, se: global _LatexSmallFractionConstant: option `Copyright 1993 by Waterloo Maple Software`: if nargs = 0 then texlist := NULL elif 1 < nargs then texlist := `latex/latex/commalist`([args],`,`,`{`,`}`) elif type(e,'numeric') then texlist := `latex/latex/numeric`(e) elif type(e,' string') then ee := length(e): se := substring(e,1 .. 11): if 10 < ee and se = `t*e*n*s*o*r` then texlist := substring(e,12 .. ee) else texlist := `latex/latex/string`(e) fi elif type(e,'indexed') then texlist := `latex/latex/indexed`(e) elif type(e,'`+`') then texlist := `latex/latex/+`(e) elif type(e,'`*`') then texlist := `latex/latex/*`(e) elif type(e,'`^`') then texlist := `latex/latex/**`(e) elif type(e,'function') then texlist := `latex/latex/function`(e) elif type(e,'relation') then texlist := `latex/print`(op(1,e)), `latex/latex/relation`(e), `latex/print`(op(2,e)) elif type(e,'set') then texlist := `latex/latex/commalist`([op(e)],`,`,[`\\left `, `\\{`],[`\\right `, `\\}`]) elif type(e,'list') then texlist := `latex/latex/commalist`([op(e)],`,`,`[`,`]`) elif type(e,'table') then texlist := `latex/latex/table`(e) elif type(e,'procedure') and not type(e,'name') and member(operator,[op(3,e)]) and member(angle,[op(3,e)]) then texlist := `latex/latex/angleoperator`(e) elif type(e,'procedure') and not type(e,'name') and member(operator,[op(3,e)]) and member(arrow,[op(3,e)]) then texlist := `latex/latex/arrowoperator`(e) elif type(e,'series') then _LatexSmallFractionConstant := 1: texlist := `(`, `latex/latex/series`(e), `)` : _LatexSmallFractionConstant := 50 elif type(e,'range') then texlist := `latex/latex/range`(e) else ERROR('`Cannot handle type: `',whattype(e)) fi: RETURN(texlist) end: `Riemann/numtenstonametens` := proc (T, S) local i, ind, ind1, F: option `Copyright 1997 by R. Portugal. All rights reserved.`: ind := [op(T)]: F := proc (i, x) options operator, arrow: if type(x,numericindex) then readlib( `tools/gensym`)(evaln(a.i)) else x fi end: ind1 := [seq(F(i,op(i,ind)),i = 1 .. nops(ind))]: if nargs = 2 then S := {op(zip(proc (i, j) options operator, arrow: if type(i,numericindex) then j = i else NULL fi end,ind,ind1))} fi: op( 0,T)[op(ind1)] end: `index/Riemann/automatic` := proc (ind, T) option `Copyright 1995 by Renato Portugal`: if ind[1] = 0 then if nargs = 2 then eval (T[op(ind)]) else T[op(ind)] := op(args[3]) fi: RETURN('"') fi: if nargs = 2 then if not assigned(T[op(ind)]) and assigned(T[0,3]) and type(ind,list( integer)) then T[op(ind)] := eval(T[0,3](op(ind))) else eval(T[op(ind)]) fi else T[op(ind)] := op(args[3 .. nargs]) fi end: `index/Riemann/calc_SSV` := proc (ind, T) local i, j, m, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): s := 0: for m to Dimension do tensor.TclRicciVName. 2[i,-m]: if ('"') <> 0 then s := s+('"')*tensor.TclRicciVName.2[m,j] fi od: T[ i,j] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_in_vierbein` := proc (ind, T) local k, s, m, kind, SN, kSN , nind: option `Copyright 1995 by Renato Portugal`: if nargs = 2 then if assigned(T[op(ind)]) or hastype(ind,'string') or ind <> [] and ind[1] = 0 then eval(T[op(ind)]) else nind := nops(ind): SN := T[0,4]: for k from nind by -1 to 1 while op(k,SN) = proc (x) if type(x,contravariantindex) then 1 else -1 fi end(op(k,ind)) do od: if k = 0 then if assigned(T[0,3]) then T[op(ind)] := `Riemann/simp_function`(T[0,3](op(ind))) else eval(T[op(ind)]) fi else s := 0: kSN := op(k,SN): kind := op(k,ind): for m to Dimension do tensor.MetricVName.2 [kind,-kSN*m]: if ('"') <> 0 then s := s+('"')*eval(tensor.(T[0,1]).nind[op( subsop(k = kSN*m,ind))]) fi od: T[op(ind)] := `Riemann/simp_function`(s) fi fi else T[op(ind)] := op(args[3]) fi end: `Riemann/printt/rec` := proc (expr, z) local i, p, q, op0: option `Copyright 1995 by Renato Portugal`: if type(expr,'indexed') then q := op(0, expr): p := traperror(q[0,1]): if type(p,'string') and q = tensor.p.(nops(expr )) then q := p fi: if not z and `Riemann/ZeroIndex` and not `Riemann/CoordIndices` then `t*e*n*s*o*r`(subs(i = q,i[op(expr)])) else `t*e*n*s*o*r`(subs(i = q,i[op(`Riemann/emerge`([op(expr)]))])) fi elif type( expr,'function') then op0 := op(0,expr): if op0 = ('diff') or op0 = ('Diff') then op0(op(map(procname,[op(expr)],z))) elif op0 = ('tdiff') then expr elif op0 = ('codiff') then expr elif type(op0,'indexed') then procname(op0,z): op(0 ,op0)(op(op0)(op(map(procname,[op(expr)],z)))) elif has(op0,'D') then op(0,op0 )(procname(op(op0),z))(op(map(procname,[op(expr)],z))) else op0(op(map( procname,[op(expr)],z))) fi elif type(expr,{`*`, `+`, set, `=`, list}) then map(procname,expr,z) elif type(expr,`^`) then if type(op(1,expr),tensor) and op(2,expr) <> -1 then ``(procname(op(1,expr),z))^procname(op(2,expr),z) else map(procname,expr,z) fi else expr fi end: `index/Riemann/calc_m5I` := proc (ind, T) local s, i, j, k, l, t: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension-1 do for j from i+1 to Dimension do tensor.WeylStarName.4[i,j,i,j]: if ('"') <> 0 then s := s+1/16*('"')*(tensor.SWName.2[-i,-j]^2-tensor.SWName.2[-i,-i]*tensor .SWName.2[-j,-j]+tensor.SWStarName.2[-i,-j]^2-tensor.SWStarName.2[-i,-i]* tensor.SWStarName.2[-j,-j]) fi: for k from i to Dimension-1 do if k = i then t := j+1 else t := k+1 fi: for l from t to Dimension do tensor.WeylStarName.4[i, j,k,l]: if ('"') <> 0 then s := s+1/8*('"')*(tensor.SWName.2[-i,-l]*tensor. SWName.2[-j,-k]-tensor.SWName.2[-i,-k]*tensor.SWName.2[-j,-l]+tensor. SWStarName.2[-i,-l]*tensor.SWStarName.2[-j,-k]-tensor.SWStarName.2[-i,-k]* tensor.SWStarName.2[-j,-l]) fi od od od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_LevCiv4` := proc (ind, T) local i, j, k, l, s, p, z, ind1: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned(T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): k := op(3,ind): l := op(4,ind): if type(i ,contravariantindex) then s := 1/sqrt(-tensordet.MetricName.0[],symbolic) elif type(j,contravariantindex) then p := `Riemann/gtableasymm`[-i,j,k,l]: if p = 0 then s := 0 else if type(p,`*`) then z := -1: ind1 := op(-p) else z := 1: ind1 := op(p) fi: s := z*tensor.MetricName.2[i,i]*procname([ind1],T) fi elif type(k ,contravariantindex) then p := `Riemann/gtableasymm`[i,-j,k,l]: if p = 0 then s := 0 else if type(p,`*`) then z := -1: ind1 := op(-p) else z := 1: ind1 := op(p) fi: s := z*tensor.MetricName.2[j,j]*procname([ind1],T) fi elif type(l, contravariantindex) then p := `Riemann/gtableasymm`[i,j,k,-l]: if p = 0 then s := 0 else if type(p,`*`) then z := -1: ind1 := op(-p) else z := 1: ind1 := op( p) fi: s := z*tensor.MetricName.2[l,l]*procname([ind1],T) fi elif type(l, covariantindex) then s := -sqrt(-tensordet.MetricName.0[],symbolic) else ERROR (`LeviCivita tensor ill-defined`) fi: T[i,j,k,l] := `Riemann/simp_function`( LeviCivitaSign*s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_WW` := proc (ind, T) local i, j, k, l, m, n, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): k := op(3,ind): l := op(4,ind): s := 0: for m to Dimension do for n from m+1 to Dimension do tensor.WeylName.4[i,j,-m,-n]: if ( '"') <> 0 then s := s+2*tensor.WeylName.4[m,n,k,l]*('"') fi od od: T[op(ind)] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/riemann` := proc (ind, T) local nind, seq_ind: option `Copyright 1995 by Renato Portugal`: if ind[1] = 0 then if nargs = 2 then eval (T[op(ind)]) else T[op(ind)] := op(args[3]) fi: RETURN('"') fi: nind := nops( ind): if op(1,ind) = op(2,ind) or op(3,ind) = op(4,ind) then if nargs = 2 then 0 else if op(args[3]) <> 0 then ERROR( `cannot assign non-zero to equal antisymmetric indices`) else T[op(ind)] := 0 fi fi else `Riemann/Riemann_order`(op(1 .. 4,ind),seq_ind): if nargs = 2 then "*T[seq_ind,op(5 .. nind,ind)] elif hastype(ind,'string') then ERROR( `cannot assign to non numeric components`) else T[seq_ind,op(5 .. nind,ind)] := "*op(args[3]) fi fi end: `Riemann/Riemann_order_ind1` := proc (ind, ind1) local n: options remember, system, `Copyright 1995 by R. Portugal`: n := `Riemann/gtableasymm`[op(ind)]: if n = 0 then 0 else `Riemann/gtableasymm`[op(ind1)]: if n = ('"') then 1 elif n = -('"') then -1 else ERROR( `INTERNAL ERROR: indices expected to be either covariant or contravariant`) fi fi end: `Riemann/forget` := proc (x::string) x := subsop(4 = NULL,eval(x)): NULL end: `print/tdiff` := proc (expr, x) local tdiff, ind: option `Copyright 1997 by R. Portugal. All rights reserved.`: if type(x,'indexed') then if type(expr,constanttensor) then tdiff[`Riemann/emerge`(op(x))]( `print/t*e*n*s*o*r`(expr)) else tdiff[`Riemann/emerge`(op(x))](expr) fi elif type(expr,constanttensor) then Diff(`print/t*e*n*s*o*r`(expr),x) else Diff( expr,x) fi end: `type/tensor` := proc (x) options remember, system, `Copyright 1997 by R. Portugal. All rights reserved`: (type(x,'indexed') or type(x,'function') and type(op(0,x),'indexed')) and type(x,tensorexpression) end: `Riemann/apply/antisymm` := proc (A, ind1, ind2, firstindex, p_name) local i, l1, Lind1: option `Copyright 1995 by Renato Portugal`: if ind1 = [] then `Riemann/apply/`.p_name(A,ind2,[],1,'nosymm',args[6 .. nargs]) else l1 := op(1 ,ind1): Lind1 := subsop(1 = NULL,ind1): for i from firstindex to Dimension do procname(subs(l1 = i,'A'),Lind1,ind2,i+1,p_name,args[6 .. nargs]) od fi end: `index/Riemann/calc_WeylSq` := proc (ind, T) local s, i, j, k, l, t: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension-1 do for j from i+1 to Dimension do for k from i to Dimension-1 do if k = i then t := j else t := k+1 fi: for l from t to Dimension do tensor.WeylName.4[-i,-j,-k ,-l]: if ('"') <> 0 then if i = k and j = l then s := s+4*tensor.WeylName.4[i, j,k,l]*('"') else s := s+8*tensor.WeylName.4[i,j,k,l]*('"') fi fi od od od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/CoordIndices` := false: `index/Riemann/calc_Christoffel` := proc (ind, T) local i, j, k, s, m, F, g: option `Copyright 1997 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned(T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else g := tensor.MetricName.2: k := op(1,ind): i := op(2,ind): j := op(3,ind): if type(k,contravariantindex) then if `Riemann/g_is_diag` then if i < j then s := g[k,k]*procname([-k, i, j],T) else s := g[k,k]*procname([-k, j, i],T) fi else F := proc (m, k) if g[m,k] = 0 then NULL else m fi end: if i < j then s := add(g[m,k]*procname([-m, i, j],T),m = seq(F(m,k),m = 1 .. Dimension)) else s := add(g[m,k]*procname([-m, j, i],T),m = seq(F(m,k),m = 1 .. Dimension)) fi fi elif k = i or k = j then s := 1/2*tensorD1metric3[k,k,-k+i+j] elif `Riemann/g_is_diag` then if i = j then s := -1/2*tensorD1metric3[i,j,k] else s := 0 fi else s := 1/2*tensorD1metric3[i,k,j]+1/2*tensorD1metric3[j,k,i]-1/2* tensorD1metric3[i,j,k] fi: T[op(ind)] := `Riemann/simp_function`(s) fi else T[ op(ind)] := op(args[3]) fi end: `Riemann/for/symm_seq` := proc (expr, L, firstindex) local i, L1: option `Copyright 1995 by Renato Portugal`: if nops(L) = 0 then eval(expr) else L1 := subsop(1 = NULL,L): seq(procname(subs(L[1] = i,'expr'),L1,i),i = firstindex .. Dimension) fi end: `Riemann/index_symm` := proc (i, j, ind, T) local m, n: option `Copyright 1995 by Renato Portugal`: if ind[1] = 0 then if nargs = 4 then eval (T[op(ind)]) else T[op(ind)] := op(args[5]) fi: RETURN('"') fi: m := op(i,ind) : n := op(j,ind): if `Riemann/Riemann_order`(m,n) then if nargs = 4 then eval( T[op(ind)]) else T[op(ind)] := op(args[5 .. nargs]) fi else op(subsop(i = n,j = m,ind)): if nargs = 4 then T["] else T["] := op(args[5 .. nargs]) fi fi end: `index/Riemann/calc_RicciScalarV` := proc (ind, T) local i, m, n, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else if `Riemann/eta_is_diag` then s := sum('tensor.MetricVName.2[i,i]*tensor.RicciVName.2[-i,-i]',('i') = 1 .. Dimension) else s := 0: for m to Dimension do tensor.MetricVName.2[m,m]: if (' "') <> 0 then s := s+('"')*tensor.RicciVName.2[-m,-m] fi: for n from m+1 to Dimension do tensor.MetricVName.2[m,n]: if ('"') <> 0 then s := s+2*('"')* tensor.RicciVName.2[-m,-n] fi od od fi: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_w1rV` := proc (ind, T) local s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 1/8*tensor.WeylSqVName.0[]: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_TclRicci` := proc (ind, T) local i, j, m, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): if type(j,contravariantindex) then if `Riemann/g_is_diag` then s := tensor.MetricName.2[j,j]*procname([i, -j],T) else s := 0: for m to Dimension do tensor.MetricName.2[j,m]: if ('"') <> 0 then s := s+('"')*procname([i, -m],T) fi od fi elif type(i,contravariantindex) then if `Riemann/g_is_diag` then if i < -j then s := tensor.MetricName.2[i,i]* procname([-i, j],T) else s := tensor.MetricName.2[i,i]*procname([j, -i],T) fi else s := 0: for m to Dimension do tensor.MetricName.2[i,m]: if ('"') <> 0 then if m < -j then s := s+('"')*procname([-m, j],T) else s := s+('"')* procname([j, -m],T) fi fi od fi else s := tensor.RicciName.2[i,j]-1/Dimension* tensor.MetricName.2[i,j]*tensor.RicciScalarName.0[] fi: T[i,j] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/ind1` := proc (ind) options remember, system, `Copyright 1995 by R. Portugal`: [op(sort(select(type,ind,contravariantindex)) ), op(map(proc (x) -x end,sort(map(proc (x) -x end,select(type,ind, covariantindex)))))] end: `index/Riemann/calc_LevCivV` := proc (ind, T) local i, k, s, p, z, ind1, n: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned(T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else n := nops(ind): if n <> Dimension then ERROR( `The number of indices of LevCiv must be equal to Dimension`) fi: if type(op(1 ,ind),contravariantindex) then s := 1/sqrt(-tensordet.MetricVName.0[],symbolic ) else for i to n while type(op(i,ind),covariantindex) do od: if i = n+1 then s := -sqrt(-tensordet.MetricVName.0[],symbolic) else k := op(i-1,ind): p := `Riemann/gtableasymm`[op(subsop(i-1 = -k,ind))]: if p = 0 then s := 0 else if type(p,`*`) then z := -1: ind1 := [op(-p)] else z := 1: ind1 := [op(p)] fi: s := z*tensor.MetricVName.2[k,k]*procname(ind1,T) fi fi fi: T[op(ind)] := `Riemann/simp_function`(LeviCivitaSign*s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/rigid_frame` := proc () global LineElementVName, tensorDRicciCoeff4, VierbeinName, MetricVName, MetricVName1, CommutCoeffName, RicciCoeffName, RiemannVName, RicciVName, RicciScalarVName, EinsteinVName, WeylVName, WeylStarVName, TclRicciVName, RieSqVName, WeylSqVName, `Riemann/vierbein_path` , `Riemann/simp_function`, RiemannVSign, RicciVSign, PermSymbolName, LeviCivitaSign, LeviCivitaVName, r1VName, RicciSqVName, SSVName, r2VName, r3VName, w1rVName, w1IVName, WWVName, w2rVName, w2IVName, SWVName, SWStarVName , m1rVName, m1IVName, m2rVName, m2IVName, m3VName, m4VName, m5rVName, m5IVName : option `Copyright 1995 by R. Portugal and S.L. Sautu`: if not assigned( `Riemann/simp_function`) then `Riemann/simp_function` := normal fi: if not assigned(RiemannVSign) then RiemannVSign := 1 fi: if not assigned(RicciVSign) then RicciVSign := 1 fi: if not assigned(LeviCivitaSign) then LeviCivitaSign := 1 fi: if not assigned(LineElementVName) then LineElementVName := ds2 fi: if not assigned(VierbeinName) then VierbeinName := omega fi: if not assigned( MetricVName) then MetricVName := eta fi: if not assigned(MetricVName1) then MetricVName1 := g fi: if not assigned(CommutCoeffName) then CommutCoeffName := C fi: if not assigned(RicciCoeffName) then RicciCoeffName := gamma fi: if not assigned(RiemannVName) then RiemannVName := R fi: if not assigned(RicciVName) then RicciVName := R fi: if not assigned(RicciScalarVName) then RicciScalarVName := R fi: if not assigned(EinsteinVName) then EinsteinVName := G fi: if not assigned(WeylVName) then WeylVName := C fi: if not assigned( WeylStarVName) then WeylStarVName := Cstar fi: if not assigned(TclRicciVName) then TclRicciVName := S fi: if not assigned(RieSqVName) then RieSqVName := RieSq fi: if not assigned(WeylSqVName) then WeylSqVName := WeylSq fi: if not assigned(PermSymbolName) then PermSymbolName := Epsilon fi: if not assigned( LeviCivitaVName) then LeviCivitaVName := epsilon fi: if not assigned(r1VName) then r1VName := r1 fi: if not assigned(RicciSqVName) then RicciSqVName := RicciSq fi: if not assigned(r2VName) then r2VName := r2 fi: if not assigned( r3VName) then r3VName := r3 fi: if not assigned(w1rVName) then w1rVName := w1r fi: if not assigned(w1IVName) then w1IVName := w1I fi: if not assigned( w2rVName) then w2rVName := w2r fi: if not assigned(w2IVName) then w2IVName := w2I fi: if not assigned(m1rVName) then m1rVName := m1r fi: if not assigned( m1IVName) then m1IVName := m1I fi: if not assigned(m2rVName) then m2rVName := m2r fi: if not assigned(m2IVName) then m2IVName := m2I fi: if not assigned( m3VName) then m3VName := m3 fi: if not assigned(m4VName) then m4VName := m4 fi : if not assigned(m5rVName) then m5rVName := m5r fi: if not assigned(m5IVName) then m5IVName := m5I fi: tensor.LineElementVName.0 := table( `Riemann/calc_LineElementV`,[0 = `Riemann/built-in`, (0, 1) = LineElementVName , (0, 2) = ('nosymm')]): tensor.MetricVName1.2 := table(`Riemann/symm_Ricci`, `Riemann/calc_MetricVName1`,[0 = `Riemann/built-in`, (0, 1) = MetricVName1, (0 , 2) = ('symm[1,2]')]): tensordet.MetricVName1.0 := table( `Riemann/calc_detMetricVName1`,[0 = `Riemann/built-in`, (0, 1) = det. MetricVName1, (0, 2) = ('nosymm')]): tensor.Dvierbein.3 := table( `Riemann/calc_Dvierbein`,[0 = `Riemann/built-in`, (0, 1) = Dvierbein, (0, 2) = ('nosymm')]): tensor.CommutCoeffName.3 := table(`Riemann/symm_C`, `Riemann/calc_C`,[0 = `Riemann/built-in`, (0, 1) = CommutCoeffName, (0, 2) = ( 'antisymm[2,3]')]): tensor.RicciCoeffName.3 := table(`Riemann/symm_RicciCoeff` ,`Riemann/calc_RicciCoeff`,[0 = `Riemann/built-in`, (0, 1) = RicciCoeffName, ( 0, 2) = ('antisymm[1,2]')]): tensor.DRicciCoeff.4 := table( `Riemann/calc_DRicciCoeff`,[0 = `Riemann/built-in`, (0, 1) = DRicciCoeff, (0, 2) = ('antisymm[1,2]')]): tensor.RiemannVName.4 := table( `Riemann/symm_Riemann`,`Riemann/calc_RiemannV`,[0 = `Riemann/built-in`, (0, 1) = RiemannVName, (0, 2) = ('riemann')]): tensor.RicciVName.2 := table( `Riemann/symm_Ricci`,`Riemann/calc_RicciV`,[0 = `Riemann/built-in`, (0, 1) = RicciVName, (0, 2) = ('symm[1,2]')]): tensor.RicciScalarVName.0 := table( `Riemann/calc_RicciScalarV`,[0 = `Riemann/built-in`, (0, 1) = RicciScalarVName , (0, 2) = ('nosymm')]): tensor.EinsteinVName.2 := table(`Riemann/symm_Ricci`, `Riemann/calc_EinsteinV`,[0 = `Riemann/built-in`, (0, 1) = EinsteinVName, (0, 2) = ('symm[1,2]')]): tensor.WeylVName.4 := table(`Riemann/symm_Riemann`, `Riemann/calc_WeylV`,[0 = `Riemann/built-in`, (0, 1) = WeylVName, (0, 2) = riemann]): tensor.WeylStarVName.4 := table(`Riemann/symm_Riemann`, `Riemann/calc_WeylStarV`,[0 = `Riemann/built-in`, (0, 1) = WeylStarVName, (0, 2) = riemann]): tensor.TclRicciVName.2 := table(`Riemann/symm_Ricci`, `Riemann/calc_TclRicciV`,[0 = `Riemann/built-in`, (0, 1) = TclRicciVName, (0, 2) = ('symm[1,2]')]): tensor.RieSqVName.0 := table(`Riemann/calc_RieSqV`,[0 = `Riemann/built-in`, (0, 1) = RieSqVName, (0, 2) = ('nosymm')]): tensor. WeylSqVName.0 := table(`Riemann/calc_WeylSqV`,[0 = `Riemann/built-in`, (0, 1) = WeylSqVName, (0, 2) = ('nosymm')]): tensor.PermSymbolName.Dimension := table (`Riemann/calc_PermSymbol`,[0 = `Riemann/built-in`, (0, 1) = PermSymbolName, ( 0, 2) = ('antisymm')]): if Dimension = 4 then tensor.LeviCivitaVName.4 := table('antisymmetric',`Riemann/calc_LevCivV4`,[0 = `Riemann/built-in`, (0, 1) = LeviCivitaVName, (0, 2) = ('antisymm')]) else tensor.LeviCivitaVName. Dimension := table('antisymmetric',`Riemann/calc_LevCivV`,[0 = `Riemann/built-in`, (0, 1) = LeviCivitaVName, (0, 2) = ('antisymm')]) fi: tensor.r1VName.0 := table(`Riemann/calc_r1V`,[0 = `Riemann/built-in`, (0, 1) = r1VName, (0, 2) = ('nosymm')]): tensor.RicciSqVName.0 := table( `Riemann/calc_RicciSqV`,[0 = `Riemann/built-in`, (0, 1) = RicciSqVName, (0, 2) = ('nosymm')]): tensor.SSVName.2 := table(`Riemann/symm_Ricci`, `Riemann/calc_SSV`,[0 = `Riemann/built-in`, (0, 1) = SSVName, (0, 2) = ('symm[ 1,2]')]): tensor.r2VName.0 := table(`Riemann/calc_r2V`,[0 = `Riemann/built-in` , (0, 1) = r2VName, (0, 2) = ('nosymm')]): tensor.r3VName.0 := table( `Riemann/calc_r3V`,[0 = `Riemann/built-in`, (0, 1) = r3VName, (0, 2) = (' nosymm')]): tensor.w1rVName.0 := table(`Riemann/calc_w1rV`,[0 = `Riemann/built-in`, (0, 1) = w1rVName, (0, 2) = ('nosymm')]): tensor.w1IVName. 0 := table(`Riemann/calc_w1IV`,[0 = `Riemann/built-in`, (0, 1) = w1IVName, (0, 2) = ('nosymm')]): tensor.WWVName.4 := table(`Riemann/symm_Riemann`, `Riemann/calc_WWV`,[0 = `Riemann/built-in`, (0, 1) = WWVName, (0, 2) = Riemann ]): tensor.w2rVName.0 := table(`Riemann/calc_w2rV`,[0 = `Riemann/built-in`, (0 , 1) = w2rVName, (0, 2) = ('nosymm')]): tensor.w2IVName.0 := table( `Riemann/calc_w2IV`,[0 = `Riemann/built-in`, (0, 1) = w2IVName, (0, 2) = (' nosymm')]): tensor.SWVName.2 := table(`Riemann/symm_Ricci`,`Riemann/calc_SWV`, [0 = `Riemann/built-in`, (0, 1) = SWVName, (0, 2) = ('symm[1,2]')]): tensor. SWStarVName.2 := table(`Riemann/symm_Ricci`,`Riemann/calc_SWVStar`,[0 = `Riemann/built-in`, (0, 1) = SWStarVName, (0, 2) = ('symm[1,2]')]): tensor. m1rVName.0 := table(`Riemann/calc_m1rV`,[0 = `Riemann/built-in`, (0, 1) = m1rVName, (0, 2) = ('nosymm')]): tensor.m1IVName.0 := table( `Riemann/calc_m1IV`,[0 = `Riemann/built-in`, (0, 1) = m1IVName, (0, 2) = (' nosymm')]): tensor.m2rVName.0 := table(`Riemann/calc_m2rV`,[0 = `Riemann/built-in`, (0, 1) = m2rVName, (0, 2) = ('nosymm')]): tensor.m2IVName. 0 := table(`Riemann/calc_m2IV`,[0 = `Riemann/built-in`, (0, 1) = m2IVName, (0, 2) = ('nosymm')]): tensor.m3VName.0 := table(`Riemann/calc_m3V`,[0 = `Riemann/built-in`, (0, 1) = m3VName, (0, 2) = ('nosymm')]): tensor.m4VName.0 := table(`Riemann/calc_m4V`,[0 = `Riemann/built-in`, (0, 1) = m4VName, (0, 2) = ('nosymm')]): tensor.m5rVName.0 := table(`Riemann/calc_m5rV`,[0 = `Riemann/built-in`, (0, 1) = m5rVName, (0, 2) = ('nosymm')]): tensor.m5IVName. 0 := table(`Riemann/calc_m5IV`,[0 = `Riemann/built-in`, (0, 1) = m5IVName, (0, 2) = ('nosymm')]): NULL end: `Riemann/seq/symm` := proc (expr, ind1, ind2, firstindex, p_name) local i, l1, Lind1: option `Copyright 1995 by Renato Portugal`: if ind1 = [] then `Riemann/seq/`.p_name(expr,ind2,[],1,'nosymm') else l1 := op(1,ind1): Lind1 := subsop(1 = NULL,ind1): seq(procname(subs(l1 = i,'expr'),Lind1,ind2,i,p_name),i = firstindex .. Dimension) fi end: `index/Riemann/calc_m5r` := proc (ind, T) local s, i, j, k, l, t: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension-1 do for j from i+1 to Dimension do tensor.WeylName.4[i,j,i,j]: if ('"') <> 0 then s := s+1/16*('"')*(tensor.SWName.2[-i,-j]^2-tensor.SWName.2[-i,-i]*tensor. SWName.2[-j,-j]+tensor.SWStarName.2[-i,-j]^2-tensor.SWStarName.2[-i,-i]*tensor .SWStarName.2[-j,-j]) fi: for k from i to Dimension-1 do if k = i then t := j+ 1 else t := k+1 fi: for l from t to Dimension do tensor.WeylName.4[i,j,k,l]: if ('"') <> 0 then s := s+1/8*('"')*(tensor.SWName.2[-i,-l]*tensor.SWName.2[-j ,-k]-tensor.SWName.2[-i,-k]*tensor.SWName.2[-j,-l]+tensor.SWStarName.2[-i,-l]* tensor.SWStarName.2[-j,-k]-tensor.SWStarName.2[-i,-k]*tensor.SWStarName.2[-j,- l]) fi od od od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op (args[3]) fi end: `Riemann/x_is_active` := false: `type/constanttensor` := proc (x) options remember, system, `Copyright 1995 by Renato Portugal`: type(x,'indexed') and type(x, tensorexpression) end: `index/Riemann/calc_WeylStarV` := proc (ind, T) local i, j, k, l, m, n, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned(T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): k := op(3,ind): l := op(4,ind): if type(l ,contravariantindex) then if `Riemann/g_is_diag` then s := tensor.MetricVName. 2[l,l]*procname([i, j, k, -l],T) else s := 0: for m to Dimension do tensor. MetricVName.2[l,m]: if ('"') <> 0 then s := s+('"')*procname([i, j, k, -m],T) fi od fi elif type(k,contravariantindex) then if `Riemann/g_is_diag` then if k < -l then s := tensor.MetricVName.2[k,k]*procname([i, j, -k, l],T) else s := - tensor.MetricVName.2[k,k]*procname([i, j, l, -k],T) fi else s := 0: for m to Dimension do if m <> -l then tensor.MetricVName.2[k,m]: if ('"') <> 0 then if m < -l then s := s+('"')*procname([i, j, -m, l],T) else s := s-('"')*procname( [i, j, l, -m],T) fi fi fi od fi elif type(j,contravariantindex) then if `Riemann/g_is_diag` then s := tensor.MetricVName.2[j,j]*procname([i, -j, k, l] ,T) else s := 0: for m to Dimension do tensor.MetricVName.2[j,m]: if ('"') <> 0 then s := s+('"')*procname([i, -m, k, l],T) fi od fi elif type(i, contravariantindex) then if `Riemann/g_is_diag` then if i < -j then s := tensor.MetricVName.2[i,i]*procname([-i, j, k, l],T) else s := -tensor. MetricVName.2[i,i]*procname([j, -i, k, l],T) fi else s := 0: for m to Dimension do if m <> -j then tensor.MetricVName.2[i,m]: if ('"') <> 0 then if m < -j then s := s+('"')*procname([-m, j, k, l],T) else s := s-('"')*procname( [j, -m, k, l],T) fi fi fi od fi elif Dimension = 4 then `minus`({1, 2, 3, 4},{ -i, -j}): m := "[1]: n := ""[2]: s := tensor.LeviCivitaVName.4[i,j,-m,-n]* tensor.WeylVName.4[m,n,k,l] else ERROR(`Dimension must be 4`) fi: T[op(ind)] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_RieSqV` := proc (ind, T) local s, i, j, k, l, t: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension-1 do for j from i+1 to Dimension do for k from i to Dimension-1 do if k = i then t := j else t := k+1 fi: for l from t to Dimension do tensor.RiemannVName.4[-i,- j,-k,-l]: if ('"') <> 0 then if i = k and j = l then s := s+4*tensor. RiemannVName.4[i,j,k,l]*('"') else s := s+8*tensor.RiemannVName.4[i,j,k,l]*('" ') fi fi od od od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/Latin_Alphabet` := {O, (-1)^(1/2), D, X, A, B, C, E, F, G, H, J, K, L , M, N, P, Q, R, S, T, U, V, W, Z}: `type/contravariantindex` := proc (x) options remember, system, `Copyright 1995 by Renato Portugal`: type(x,{name, contravariantnumericindex}) end: `Riemann/for/Riemann` := proc (A, B, ind1, ind2, atrib, firstindex, p_name) local i, j, k, l, t, l1, l2, l3, l4: option `Copyright 1995 by Renato Portugal`: l1 := op(1,ind1): l2 := op(2,ind1): l3 := op(3,ind1): l4 := op(4,ind1): for i to Dimension-1 do for j from i+1 to Dimension do for k from i to Dimension-1 do if k = i then t := j else t := k+1 fi: for l from t to Dimension do `Riemann/for/`.p_name(op(subs({l1 = i, l2 = j , l4 = l, l3 = k},'[A, B]')),ind2,[],atrib,1,'nosymm') od od od od end: `index/Riemann/calc_LineElement` := proc (ind, T) local dd, m, n, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else dd := readlib(`tools/gensym`)('d '): s := 0: if not `Riemann/g_is_diag` then for m to Dimension do for n from m +1 to Dimension do s := s+2*tensor.MetricName.2[-m,-n]*dd(tensor. CoordinateName.1[m])*dd(tensor.CoordinateName.1[n]) od od fi: T[] := s+sum(' tensor.MetricName.2[-m,-m]*dd(tensor.CoordinateName.1[m])^2',('m') = 1 .. Dimension) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/print/diff1` := proc (f, x) option `Copyright 1995 by Renato Portugal`: if type(f,'function') then op(0,f)[`, `.x ] elif type(f,'indexed') then op(0,f)[op(f),x] else 'diff'(f,x) fi end: `Riemann/seq` := proc (expr, ind, SYMM) local ind1, ind2, i, j, k, l, L, Symm: option `Copyright 1995 by Renato Portugal`: if SYMM = ('nosymm') then ind1 := map(`Riemann/abs`,ind): `Riemann/seq/nosymm`(expr,ind1,[],1,'nosymm') elif SYMM = ('symm') then ind1 := select(type,ind,contravariantindex): ind2 := map( `Riemann/abs`,select(type,ind,covariantindex)): `Riemann/seq/symm`(expr,ind1, ind2,1,'symm') elif SYMM = ('antisymm') then ind1 := select(type,ind, contravariantindex): ind2 := map(`Riemann/abs`,select(type,ind,covariantindex) ): `Riemann/seq/antisymm`(expr,ind1,ind2,1,'antisymm') elif SYMM = ('riemann') then ind1 := [op(1 .. 4,ind)]: ind2 := map(`Riemann/abs`,[op(5 .. nops(ind), ind)]): L := map(proc (x) options operator, arrow: if op(1,x) = -1 then -1 else 1 fi end,ind1): ind1 := map(`Riemann/abs`,ind1): i := op(1,ind1): j := op (2,ind1): k := op(3,ind1): l := op(4,ind1): if member(L,{[1, 1, 1, 1], [-1, -1 , -1, -1]}) then `Riemann/seq/Riemann`(expr,ind1,ind2,1,'nosymm') elif member( L,{[1, -1, -1, -1], [-1, 1, -1, -1], [1, -1, 1, 1], [-1, 1, 1, 1]}) then `Riemann/seq/antisymm`(expr,[k, l],[i, j, op(ind2)],1,'nosymm') elif member(L, {[1, 1, -1, -1], [-1, -1, 1, 1]}) and ind2 = [] then `Riemann/seq/antisymm`( expr,[i, j],[k, l],1,'antisymm') elif member(L,{[1, 1, 1, -1], [1, 1, -1, 1], [-1, -1, 1, -1], [-1, -1, -1, 1]}) then `Riemann/seq/antisymm`(expr,[i, j],[k, l, op(ind2)],1,'nosymm') elif member(L,{[1, -1, 1, -1], [-1, 1, -1, 1]}) and ind2 = [] then `Riemann/seq/symm`(expr,[i, k],[j, l],1,'symm') else `Riemann/seq/nosymm`(expr,[op(ind1), op(ind2)],[],1,'nosymm') fi elif type( SYMM,'indexed') then Symm := op(0,SYMM): i := op(1,SYMM): j := op(2,SYMM): k := op(i,ind): l := op(j,ind): if op(1,k*l) = -1 then `Riemann/seq/nosymm`(expr ,map(`Riemann/abs`,ind),[],1,'nosymm') else ind1 := [`Riemann/abs`(k), `Riemann/abs`(l)]: ind2 := map(`Riemann/abs`,subsop(i = NULL,j = NULL,ind)): `Riemann/seq/`.Symm(expr,ind1,ind2,1,'nosymm') fi elif SYMM = ('diagonal') or SYMM = ('identity') then `Riemann/seq/diagonal`(expr,map(`Riemann/abs`,ind),[] ,1,'nosymm') else ERROR(`wrong symmetry name`) fi end: `Riemann/print/diff2` := proc (f, x) option `Copyright 1995 by Renato Portugal`: if type(f,'function') then if nops(f) = 1 and op(f) = ('t') then cat(op(0,f),`'`) else op(0,f)[`, `.x] fi elif type(f,' indexed') then op(0,f)[op(f),x] elif type(f,'string') then cat(f,`'`) else ' diff'(f,x) fi end: `index/Riemann/calc_m2IV` := proc (ind, T) local s, i, j: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension do tensor.SWVName.2[-i,-i]: if ('"') <> 0 then s := s+1/8*('"')*tensor. SWStarVName.2[i,i] fi: for j from i+1 to Dimension do tensor.SWVName.2[-i,-j]: if ('"') <> 0 then s := s+1/4*('"')*tensor.SWStarVName.2[i,j] fi od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_detg` := proc (ind, T) option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] elif `Riemann/g_is_diag` then T[] := `Riemann/simp_function`(product('tensor.MetricName.2[-i,-i]',('i') = 1 .. Dimension)) else if assigned(`Riemann/detg`) then T[] := `Riemann/simp_function`(`Riemann/detg`) else T[] fi fi else T[op(ind)] := op( args[3]) fi end: `index/Riemann/calc_Ricci` := proc (ind, T) local i, j, m, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): if type(j,contravariantindex) then if `Riemann/g_is_diag` then s := tensor.MetricName.2[j,j]*procname([i, -j],T) else s := 0: for m to Dimension do tensor.MetricName.2[j,m]: if ('"') <> 0 then s := s+('"')*procname([i, -m],T) fi od fi elif type(i,contravariantindex) then if `Riemann/g_is_diag` then if i < -j then s := tensor.MetricName.2[i,i]* procname([-i, j],T) else s := tensor.MetricName.2[i,i]*procname([j, -i],T) fi else s := 0: for m to Dimension do tensor.MetricName.2[i,m]: if ('"') <> 0 then if m < -j then s := s+('"')*procname([-m, j],T) else s := s+('"')* procname([j, -m],T) fi fi od fi else s := RicciSign*add(tensor.RiemannName.4[m ,i,j,-m],m = 1 .. Dimension) fi: T[i,j] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/holonomic_frame` := proc () global LineElementName, tensorD1metric3, tensorD2metric4, CoordinateName, MetricName, ChristoffelName, RiemannName, RicciName, EinsteinName, RicciScalarName, WeylName, WeylStarName, TclRicciName , RieSqName, WeylSqName, `Riemann/metric_path`, `Riemann/simp_function`, RiemannSign, RicciSign, PermSymbolName, LeviCivitaSign, LeviCivitaName, r1Name , RicciSqName, SSName, r2Name, r3Name, w1rName, w1IName, WWName, w2rName, w2IName, SWName, SWStarName, m1rName, m1IName, m2rName, m2IName, m3Name, m4Name, m5rName, m5IName: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if not assigned( `Riemann/simp_function`) then `Riemann/simp_function` := normal fi: if not assigned(RiemannSign) then RiemannSign := 1 fi: if not assigned(RicciSign) then RicciSign := 1 fi: if not assigned(LeviCivitaSign) then LeviCivitaSign := 1 fi: if not assigned(LineElementName) then LineElementName := ds2 fi: if not assigned(CoordinateName) then CoordinateName := X fi: if not assigned( MetricName) then MetricName := g fi: if not assigned(ChristoffelName) then ChristoffelName := Gamma fi: if not assigned(RiemannName) then RiemannName := R fi: if not assigned(RicciName) then RicciName := R fi: if not assigned( EinsteinName) then EinsteinName := G fi: if not assigned(RicciScalarName) then RicciScalarName := R fi: if not assigned(WeylName) then WeylName := C fi: if not assigned(WeylStarName) then WeylStarName := Cstar fi: if not assigned( TclRicciName) then TclRicciName := S fi: if not assigned(RieSqName) then RieSqName := RieSq fi: if not assigned(WeylSqName) then WeylSqName := WeylSq fi: if not assigned(PermSymbolName) then PermSymbolName := Epsilon fi: if not assigned(LeviCivitaName) then LeviCivitaName := epsilon fi: if not assigned( r1Name) then r1Name := r1 fi: if not assigned(RicciSqName) then RicciSqName := RicciSq fi: if not assigned(r2Name) then r2Name := r2 fi: if not assigned( r3Name) then r3Name := r3 fi: if not assigned(w1rName) then w1rName := w1r fi: if not assigned(w1IName) then w1IName := w1I fi: if not assigned(w2rName) then w2rName := w2r fi: if not assigned(w2IName) then w2IName := w2I fi: if not assigned(m1rName) then m1rName := m1r fi: if not assigned(m1IName) then m1IName := m1I fi: if not assigned(m2rName) then m2rName := m2r fi: if not assigned(m2IName) then m2IName := m2I fi: if not assigned(m3Name) then m3Name := m3 fi: if not assigned(m4Name) then m4Name := m4 fi: if not assigned( m5rName) then m5rName := m5r fi: if not assigned(m5IName) then m5IName := m5I fi: tensor.LineElementName.0 := table(`Riemann/calc_LineElement`,[0 = `Riemann/built-in`, (0, 1) = LineElementName, (0, 2) = ('nosymm')]): tensorD1metric3 := table(`Riemann/calc_D1metric`,[0 = `Riemann/built-in`, (0, 1) = D1metric, (0, 2) = ('symm[1,2]')]): tensor.ChristoffelName.3 := table( `Riemann/symm_Christoffel`,`Riemann/calc_Christoffel`,[0 = `Riemann/built-in`, (0, 1) = ChristoffelName, (0, 2) = ('symm[2,3]')]): tensorD2metric4 := table( `Riemann/calc_D2metric`,[0 = `Riemann/built-in`, (0, 1) = D2metric, (0, 2) = ( 'symm[1,2]')]): tensor.RiemannName.4 := table(`Riemann/symm_Riemann`, `Riemann/calc_Riemann`,[0 = `Riemann/built-in`, (0, 1) = RiemannName, (0, 2) = riemann]): tensor.RicciName.2 := table(`Riemann/symm_Ricci`, `Riemann/calc_Ricci`,[0 = `Riemann/built-in`, (0, 1) = RicciName, (0, 2) = (' symm[1,2]')]): tensor.RicciScalarName.0 := table(`Riemann/calc_RicciScalar`,[0 = `Riemann/built-in`, (0, 1) = RicciScalarName, (0, 2) = ('nosymm')]): tensor. EinsteinName.2 := table(`Riemann/symm_Ricci`,`Riemann/calc_Einstein`,[0 = `Riemann/built-in`, (0, 1) = EinsteinName, (0, 2) = ('symm[1,2]')]): tensor. WeylName.4 := table(`Riemann/symm_Riemann`,`Riemann/calc_Weyl`,[0 = `Riemann/built-in`, (0, 1) = WeylName, (0, 2) = riemann]): tensor.WeylStarName .4 := table(`Riemann/symm_Riemann`,`Riemann/calc_WeylStar`,[0 = `Riemann/built-in`, (0, 1) = WeylStarName, (0, 2) = riemann]): tensor. TclRicciName.2 := table(`Riemann/symm_Ricci`,`Riemann/calc_TclRicci`,[0 = `Riemann/built-in`, (0, 1) = TclRicciName, (0, 2) = ('symm[1,2]')]): tensor. RieSqName.0 := table(`Riemann/calc_RieSq`,[0 = `Riemann/built-in`, (0, 1) = RieSqName, (0, 2) = ('nosymm')]): tensor.WeylSqName.0 := table( `Riemann/calc_WeylSq`,[0 = `Riemann/built-in`, (0, 1) = WeylSqName, (0, 2) = ( 'nosymm')]): tensor.PermSymbolName.Dimension := table( `Riemann/calc_PermSymbol`,[0 = `Riemann/built-in`, (0, 1) = PermSymbolName, (0 , 2) = ('antisymm')]): if Dimension = 4 then tensor.LeviCivitaName.4 := table( 'antisymmetric',`Riemann/calc_LevCiv4`,[0 = `Riemann/built-in`, (0, 1) = LeviCivitaName, (0, 2) = ('antisymm')]) else tensor.LeviCivitaName.4 := table( 'antisymmetric',`Riemann/calc_LevCiv`,[0 = `Riemann/built-in`, (0, 1) = LeviCivitaName, (0, 2) = ('antisymm')]) fi: tensor.r1Name.0 := table( `Riemann/calc_r1`,[0 = `Riemann/built-in`, (0, 1) = r1Name, (0, 2) = ('nosymm' )]): tensor.RicciSqName.0 := table(`Riemann/calc_RicciSq`,[0 = `Riemann/built-in`, (0, 1) = RicciSqName, (0, 2) = ('nosymm')]): tensor.SSName .2 := table(`Riemann/symm_Ricci`,`Riemann/calc_SS`,[0 = `Riemann/built-in`, (0 , 1) = SSName, (0, 2) = ('symm[1,2]')]): tensor.r2Name.0 := table( `Riemann/calc_r2`,[0 = `Riemann/built-in`, (0, 1) = r2Name, (0, 2) = ('nosymm' )]): tensor.r3Name.0 := table(`Riemann/calc_r3`,[0 = `Riemann/built-in`, (0, 1 ) = r3Name, (0, 2) = ('nosymm')]): tensor.w1rName.0 := table( `Riemann/calc_w1r`,[0 = `Riemann/built-in`, (0, 1) = w1rName, (0, 2) = (' nosymm')]): tensor.w1IName.0 := table(`Riemann/calc_w1I`,[0 = `Riemann/built-in`, (0, 1) = w1IName, (0, 2) = ('nosymm')]): tensor.WWName.4 := table(`Riemann/symm_Riemann`,`Riemann/calc_WW`,[0 = `Riemann/built-in`, (0, 1) = WWName, (0, 2) = Riemann]): tensor.w2rName.0 := table(`Riemann/calc_w2r`, [0 = `Riemann/built-in`, (0, 1) = w2rName, (0, 2) = ('nosymm')]): tensor. w2IName.0 := table(`Riemann/calc_w2I`,[0 = `Riemann/built-in`, (0, 1) = w2IName, (0, 2) = ('nosymm')]): tensor.SWName.2 := table(`Riemann/symm_Ricci`, `Riemann/calc_SW`,[0 = `Riemann/built-in`, (0, 1) = SWName, (0, 2) = ('symm[1, 2]')]): tensor.SWStarName.2 := table(`Riemann/symm_Ricci`, `Riemann/calc_SWStar`,[0 = `Riemann/built-in`, (0, 1) = SWStarName, (0, 2) = ( 'symm[1,2]')]): tensor.m1rName.0 := table(`Riemann/calc_m1r`,[0 = `Riemann/built-in`, (0, 1) = m1rName, (0, 2) = ('nosymm')]): tensor.m1IName.0 := table(`Riemann/calc_m1I`,[0 = `Riemann/built-in`, (0, 1) = m1IName, (0, 2) = ('nosymm')]): tensor.m2rName.0 := table(`Riemann/calc_m2r`,[0 = `Riemann/built-in`, (0, 1) = m2rName, (0, 2) = ('nosymm')]): tensor.m2IName.0 := table(`Riemann/calc_m2I`,[0 = `Riemann/built-in`, (0, 1) = m2IName, (0, 2) = ('nosymm')]): tensor.m3Name.0 := table(`Riemann/calc_m3`,[0 = `Riemann/built-in`, (0, 1) = m3Name, (0, 2) = ('nosymm')]): tensor.m4Name.0 := table(`Riemann/calc_m4`,[0 = `Riemann/built-in`, (0, 1) = m4Name, (0, 2) = (' nosymm')]): tensor.m5rName.0 := table(`Riemann/calc_m5r`,[0 = `Riemann/built-in`, (0, 1) = m5rName, (0, 2) = ('nosymm')]): tensor.m5IName.0 := table(`Riemann/calc_m5I`,[0 = `Riemann/built-in`, (0, 1) = m5IName, (0, 2) = ('nosymm')]): NULL end: `index/Riemann/calc_DRicciCoeff` := proc (ind, T) local l, s, m: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else l := op(4,ind): if `Riemann/Vierbein_is_diag` then T[op(ind)] := diff(tensor. RicciCoeffName.3[op(1 .. 3,ind)],tensor.CoordinateName.1[-l])*tensor. VierbeinName.2[l,-l] else s := 0: for m to Dimension do tensor.VierbeinName.2[ l,m]: if ('"') <> 0 then s := s+diff(tensor.RicciCoeffName.3[op(1 .. 3,ind)], tensor.CoordinateName.1[m])*('"') fi od: T[op(ind)] := s fi fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_w1I` := proc (ind, T) local s, i, j, k, l, t: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension-1 do for j from i+1 to Dimension do for k from i to Dimension-1 do if k = i then t := j else t := k+1 fi: for l from t to Dimension do tensor.WeylStarName.4[-i,- j,-k,-l]: if ('"') <> 0 then if i = k and j = l then s := s+1/2*tensor. WeylName.4[i,j,k,l]*('"') else s := s+tensor.WeylName.4[i,j,k,l]*('"') fi fi od od od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3 ]) fi end: `type/contravarianttensor` := proc (x) options remember, system, `Copyright 1997 by R. Portugal. All right reserved.`: type(x,tensor) and type( map(op,[op(3 .. 4,`Riemann/indices`(x))]),list(contravariantindex)) end: `index/Riemann/calc_eta` := proc (ind, T) local i, j: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): if type(i,covariantindex) then T[op(ind)] elif type (j,covariantindex) then if i = -j then T[op(ind)] := 1 else T[op(ind)] := 0 fi elif `Riemann/eta_is_diag` then if i = j then T[op(ind)] := 1/tensor. MetricVName.2[-i,-j] else T[op(ind)] := 0 fi else T[op(ind)] fi fi else T[op( ind)] := op(args[3]) fi end: `index/Riemann/calc_D1metric` := proc (ind, T) local i, j, k: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): k := op(3,ind): if `Riemann/Riemann_order`(i,j) then T[op(ind)] := diff(tensor.MetricName.2[i,j],tensor.CoordinateName.1[-k]) else T[j,i,k] := diff(tensor.MetricName.2[j,i],tensor.CoordinateName.1[-k]) fi fi else T[op(ind)] := op(args[3]) fi end: `Riemann/printtensor` := true: `Riemann/g_is_active` := false: `Riemann/allindices` := proc (expr, T) local r: option `Copyright 1997 by R. Portugal. All rights reserved.`: r := indets(expr,' indexed'): if nargs = 2 then T := map(proc (x) options operator, arrow: op(0,x ) end,r) fi: map(op,r) end: `index/Riemann/calc_Weyl` := proc (ind, T) local i, j, k, l, m, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): k := op(3,ind): l := op(4,ind): if type(l, contravariantindex) then if `Riemann/g_is_diag` then s := tensor.MetricName.2[ l,l]*procname([i, j, k, -l],T) else s := 0: for m to Dimension do tensor. MetricName.2[l,m]: if ('"') <> 0 then s := s+('"')*procname([i, j, k, -m],T) fi od fi elif type(k,contravariantindex) then if `Riemann/g_is_diag` then if k < -l then s := tensor.MetricName.2[k,k]*procname([i, j, -k, l],T) else s := - tensor.MetricName.2[k,k]*procname([i, j, l, -k],T) fi else s := 0: for m to Dimension do if m <> -l then tensor.MetricName.2[k,m]: if ('"') <> 0 then if m < -l then s := s+('"')*procname([i, j, -m, l],T) else s := s-('"')*procname([i , j, l, -m],T) fi fi fi od fi elif type(j,contravariantindex) then if `Riemann/g_is_diag` then s := tensor.MetricName.2[j,j]*procname([i, -j, k, l], T) else s := 0: for m to Dimension do tensor.MetricName.2[j,m]: if ('"') <> 0 then s := s+('"')*procname([i, -m, k, l],T) fi od fi elif type(i, contravariantindex) then if `Riemann/g_is_diag` then if i < -j then s := tensor.MetricName.2[i,i]*procname([-i, j, k, l],T) else s := -tensor. MetricName.2[i,i]*procname([j, -i, k, l],T) fi else s := 0: for m to Dimension do if m <> -j then tensor.MetricName.2[i,m]: if ('"') <> 0 then if m < -j then s := s+('"')*procname([-m, j, k, l],T) else s := s-('"')*procname([j, -m, k, l ],T) fi fi fi od fi else s := 0: tensor.MetricName.2[i,k]: if ('"') <> 0 then s := ('"')*tensor.RicciName.2[j,l] fi: tensor.MetricName.2[i,l]: if ('"') <> 0 then s := s-('"')*tensor.RicciName.2[j,k] fi: tensor.MetricName.2[j,l]: if ('" ') <> 0 then s := s+('"')*tensor.RicciName.2[i,k] fi: tensor.MetricName.2[j,k] : if ('"') <> 0 then s := s-('"')*tensor.RicciName.2[i,l] fi: s := tensor. RiemannName.4[i,j,k,l]+RicciSign/(Dimension-2)*s+RicciSign/(Dimension-1)/( Dimension-2)*tensor.RicciScalarName.0[]*(tensor.MetricName.2[i,l]*tensor. MetricName.2[j,k]-tensor.MetricName.2[i,k]*tensor.MetricName.2[j,l]) fi: T[i,j ,k,l] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_WeylStar` := proc (ind, T) local i, j, k, l, m, n, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned(T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): k := op(3,ind): l := op(4,ind): if type(l ,contravariantindex) then if `Riemann/g_is_diag` then s := tensor.MetricName.2 [l,l]*procname([i, j, k, -l],T) else s := 0: for m to Dimension do tensor. MetricName.2[l,m]: if ('"') <> 0 then s := s+('"')*procname([i, j, k, -m],T) fi od fi elif type(k,contravariantindex) then if `Riemann/g_is_diag` then if k < -l then s := tensor.MetricName.2[k,k]*procname([i, j, -k, l],T) else s := - tensor.MetricName.2[k,k]*procname([i, j, l, -k],T) fi else s := 0: for m to Dimension do if m <> -l then tensor.MetricName.2[k,m]: if ('"') <> 0 then if m < -l then s := s+('"')*procname([i, j, -m, l],T) else s := s-('"')*procname([i , j, l, -m],T) fi fi fi od fi elif type(j,contravariantindex) then if `Riemann/g_is_diag` then s := tensor.MetricName.2[j,j]*procname([i, -j, k, l], T) else s := 0: for m to Dimension do tensor.MetricName.2[j,m]: if ('"') <> 0 then s := s+('"')*procname([i, -m, k, l],T) fi od fi elif type(i, contravariantindex) then if `Riemann/g_is_diag` then if i < -j then s := tensor.MetricName.2[i,i]*procname([-i, j, k, l],T) else s := -tensor. MetricName.2[i,i]*procname([j, -i, k, l],T) fi else s := 0: for m to Dimension do if m <> -j then tensor.MetricName.2[i,m]: if ('"') <> 0 then if m < -j then s := s+('"')*procname([-m, j, k, l],T) else s := s-('"')*procname([j, -m, k, l ],T) fi fi fi od fi elif Dimension = 4 then `minus`({1, 2, 3, 4},{-i, -j}): m := "[1]: n := ""[2]: s := tensor.LeviCivitaName.4[i,j,-m,-n]*tensor.WeylName.4 [m,n,k,l] else ERROR(`Dimension must be 4`) fi: T[op(ind)] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_MetricVName1` := proc (ind, T) local i, j, m, n, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): if type(i,covariantindex) then if `Riemann/eta_is_diag` then s := 0: for m to Dimension do s := s+tensor. MetricVName.2[-m,-m]*tensor.VierbeinName.2[m,i]*tensor.VierbeinName.2[m,j] od elif `Riemann/Vierbein_is_diag` then s := tensor.MetricVName.2[i,j]*tensor. VierbeinName.2[-i,i]*tensor.VierbeinName.2[-j,j] else s := 0: for m to Dimension do for n to Dimension do tensor.MetricVName.2[-m,-n]: if ('"') <> 0 then s := s+('"')*tensor.VierbeinName.2[m,i]*tensor.VierbeinName.2[n,j] fi od od fi: T[op(ind)] := `Riemann/simp_function`(s) elif type(j,contravariantindex ) then if `Riemann/eta_is_diag` then s := 0: for m to Dimension do s := s+ tensor.MetricVName.2[m,m]*tensor.VierbeinName.2[-m,i]*tensor.VierbeinName.2[-m ,j] od elif `Riemann/Vierbein_is_diag` then s := tensor.MetricVName.2[i,j]* tensor.VierbeinName.2[-i,i]*tensor.VierbeinName.2[-j,j] else s := 0: for m to Dimension do for n to Dimension do tensor.MetricVName.2[m,n]: if ('"') <> 0 then s := s+('"')*tensor.VierbeinName.2[-m,i]*tensor.VierbeinName.2[-n,j] fi od od fi: T[op(ind)] := `Riemann/simp_function`(s) elif i = -j then T[op(ind)] := 1 else T[op(ind)] := 0 fi fi else T[op(ind)] := op(args[3]) fi end: `Riemann/sum` := proc (expr) local op0, ind, N, tensorname, i: option `Copyright 1995 by Renato Portugal`: if type(expr,'indexed') then ind := `Riemann/indices`(expr): tensorname := `Riemann/tensorname`(expr,N): if assigned(tensor.tensorname.N[0,1]) then subs(tensorname = tensor.tensorname.N, `Riemann/sink`(expr)): `Riemann/sum/sum`('"',op(1,ind)) else `Riemann/sink`( expr): `Riemann/sum/sum`('"',op(1,ind)) fi elif type(expr,'function') then op0 := op(0,expr): if type(op0,'indexed') then procname(op0)(op(expr)) elif type( op0,'function') then op(0,op0): if " = ('D') then 'D'(procname(op(op0)))(op( expr)) elif type(",'indexed') and op(0,") = ('D') then `Riemann/sum/sum`('"'( procname(op(op0)))(op(expr)),op(1,`Riemann/indices`(expr))) fi elif type(op0,' string') and substring(op0,1 .. 1) = ('t') and op0 <> ('tdiff') then substring (op0,2 .. length(op0)): `Riemann/sum/sum`('"'(seq(procname(i),i = expr)),op(1, `Riemann/indices`(expr))) else `Riemann/sum/sum`('"'(seq(procname(i),i = expr) ),op(1,`Riemann/indices`(expr))) fi elif type(expr,`*`) then `Riemann/sum/sum` (map(procname,expr),op(1,`Riemann/indices`(expr))) elif type(expr,{`+`, `^`}) then map(procname,expr) else expr fi end: `index/Riemann/calc_Dvierbein` := proc (ind, T) option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else T[op( ind)] := diff(tensor.VierbeinName.2[op(1 .. 2,ind)],tensor.CoordinateName.1[- op(3,ind)]) fi else T[op(ind)] := op(args[3]) fi end: `type/index` := proc (x) options remember, system, `Copyright 1995 by Renato Portugal`: type(x,{numericindex, nameindex}) end: `type/contravariantnumericindex` := proc (x) options remember, system, `Copyright 1995 by Renato Portugal`: if `Riemann/CoordIndices` and assigned( tensor.CoordinateName.1[0,0,1]) and member(x,tensor.CoordinateName.1[0,0,1]) then true elif `Riemann/ZeroIndex` and x = O then true elif not type(x, nonnegint) then false elif x < -Dimension or Dimension < x then ERROR( `index outside Dimension`) elif x = 0 then if `Riemann/ZeroIndex` then ERROR( `use the letter O instead of zero`) else ERROR( `zero cannot be used as index when ZeroIndex is turned off`) fi else true fi end: `Riemann/codiff/goodindex` := proc (x, S) local r: global `Riemann/codiff/usedind`: option `Copyright 1995 by Renato Portugal`: if assigned(tensor.CoordinateName.1[0,0,1]) then r := type(x,'string') and not has(S,x) and not assigned(x) and not member(x,tensor.CoordinateName.1[0,0,1]) else r := type(x,'string') and not has(S,x) and not assigned(x) fi: if r and not member(x,`Riemann/codiff/usedind`) and not member(x, `Riemann/forbiddenindices`) then if `Riemann/usedindices_max` < nops( `Riemann/codiff/usedind`) then `Riemann/codiff/usedind` := op(remove(proc (x) options operator, arrow: x = eval(`Riemann/codiff/usedind`,1) end,'{ `Riemann/codiff/usedind1`, `Riemann/codiff/usedind2`}')): assign(eval( `Riemann/codiff/usedind`,1),{}) fi: assign(eval(`Riemann/codiff/usedind`,1),{ op(`Riemann/codiff/usedind`), x}): 'true' else 'false' fi end: `index/Riemann/calc_w1r` := proc (ind, T) local s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 1/8*tensor.WeylSqName.0[]: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/forgetall` := proc () option `Copyright 1995 by Renato Portugal`: `Riemann/forget`(`type/tensorexpression`): `Riemann/forget`(`type/tensor`): `Riemann/forget`(`type/constanttensor`): `Riemann/forget`(`type/nametensor`): `Riemann/forget`(`type/functiontensor`): `Riemann/forget`(`type/numerictensor` ): `Riemann/forget`(`type/index`): `Riemann/forget`(`type/numericindex`): `Riemann/forget`(`type/nameindex`): `Riemann/forget`( `type/contravariantnameindex`): `Riemann/forget`(`type/covariantnameindex`): `Riemann/forget`(`type/contravariantnumericindex`): `Riemann/forget`( `type/covariantnumericindex`): `Riemann/forget`(`type/contravariantindex`): `Riemann/forget`(`type/covariantindex`): `Riemann/forget`(`Riemann/indices`): `Riemann/forget`(`Riemann/indices/rec`): `Riemann/forget`( `Riemann/Riemann_order`): `Riemann/forget`(`index/antisymm`): `Riemann/forget` (`Riemann/ind1`): `Riemann/forget`(`Riemann/Riemann_order_ind1`): `Riemann/forget`(`print/t*e*n*s*o*r`): `Riemann/forget`(`Riemann/printt/rec`): `Riemann/forget`(`Riemann/tensorname`): `Riemann/forget`(`Riemann/equal`) end: `Riemann/codiff/genindex` := proc (S, R) local i, j: option `Copyright 1995 by Renato Portugal`: if nargs = 2 and type(R,{'set', 'list'}) then for j to nops(R) do i := op(j,R): if `Riemann/codiff/goodindex`(i,S) then RETURN(i) fi od fi: if member(op(1,S),`Riemann/Greek_Alphabet`) then for j in `Riemann/Greek_Alphabet` do if type(eval(j),'string') and `Riemann/codiff/goodindex`(j,S) then if `Riemann/CodiffIndex` = ('true') then RETURN(j) else RETURN(_.j) fi fi od: for j while not `Riemann/codiff/goodindex`(evaln(Xi.j),S) do od: if `Riemann/CodiffIndex` = ( 'true') then RETURN(Xi.j) else RETURN(_Xi.j) fi fi: if member(op(1,S), `Riemann/greek_alphabet`) then for j in `Riemann/greek_alphabet` do if type( eval(j),'string') and `Riemann/codiff/goodindex`(j,S) then if `Riemann/CodiffIndex` = ('true') then RETURN(j) else RETURN(_.j) fi fi od: for j while not `Riemann/codiff/goodindex`(evaln(xi.j),S) do od: if `Riemann/CodiffIndex` = ('true') then RETURN(xi.j) else RETURN(_xi.j) fi fi: j := op(1,S): if type(j,'string') then i := substring(j,1 .. 1): if i = ('_') then i := traperror(substring(j,2 .. 2)) fi else i := 'a' fi: if member(i, `Riemann/latin_alphabet`) then for j in `Riemann/latin_alphabet` do if type( eval(j),'string') and `Riemann/codiff/goodindex`(j,S) then if `Riemann/CodiffIndex` = ('true') then RETURN(j) else RETURN(_.j) fi fi od: for j while not `Riemann/codiff/goodindex`(evaln(k.j),S) do od: if `Riemann/CodiffIndex` = ('true') then RETURN(k.j) else RETURN(_k.j) fi elif member(i,`Riemann/Latin_Alphabet`) then for j in `Riemann/Latin_Alphabet` do if type(eval(j),'string') and `Riemann/codiff/goodindex`(j,S) then if `Riemann/CodiffIndex` = ('true') then RETURN(j) else RETURN(_.j) fi fi od: for j while not `Riemann/codiff/goodindex`(evaln(K.j),S) do od: if `Riemann/CodiffIndex` = ('true') then RETURN(K.j) else RETURN(_K.j) fi else ERROR(`cound't find a good summed index for codiff. Try give some indices, see\ \?CodiffSumIndex.`) fi end: `index/Riemann/calc_Vierbein` := proc (ind, T) local i, j, m, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): if i*j < 0 then if `Riemann/Vierbein_is_diag` then if i = -j then T[op(ind)] := 1/tensor.VierbeinName.2[-i,-j] else T[op(ind)] := 0 fi else T[op(ind)] fi elif `Riemann/Vierbein_is_diag` then T[op(ind)] := tensor.MetricVName.2[i,j]*tensor.VierbeinName.2[-j,j] elif `Riemann/eta_is_diag` then T[op(ind)] := tensor.MetricVName.2[i,i]*tensor. VierbeinName.2[-i,j] elif type(i,contravariantindex) then s := 0: for m to Dimension do s := s+tensor.MetricVName.2[i,m]*tensor.VierbeinName.2[-m,j] od: T[op(ind)] := `Riemann/simp_function`(s) elif type(i,covariantindex) then s := 0: for m to Dimension do s := s+tensor.MetricVName.2[i,-m]*tensor.VierbeinName .2[m,j] od: T[op(ind)] := `Riemann/simp_function`(s) else T[op(ind)] fi fi else T[op(ind)] := op(args[3]) fi end: `Riemann/index_antisymm` := proc (i, j, ind, T) local m, n: option `Copyright 1995 by Renato Portugal`: if ind[1] = 0 then if nargs = 4 then eval (T[op(ind)]) else T[op(ind)] := op(args[5]) fi: RETURN('"') fi: m := op(i,ind) : n := op(j,ind): if m = n then if nargs = 4 then 0 else if op(args[5]) <> 0 then ERROR(`cannot assign non-zero to equal antisymmetric indices`) else T[op( ind)] := 0 fi fi elif `Riemann/Riemann_order`(m,n) then if nargs = 4 then eval (T[op(ind)]) else T[op(ind)] := op(args[5 .. nargs]) fi else op(subsop(i = n,j = m,ind)): if nargs = 4 then -T["] else T["] := -op(args[5 .. nargs]) fi fi end: `Riemann/Greek_Alphabet` := {Pi, Beta, Chi, Psi, Eta, Mu, Nu, Xi, Rho, Tau, Phi, Zeta, Gamma, Epsilon, Iota, Kappa, Lambda, Omicron, Sigma, Upsilon, Omega , Theta, Delta, Alpha}: `Riemann/Vierbein_is_diag` := false: `Riemann/sum/sum` := proc (expr, s) option `Copyright 1995 by Renato Portugal` : if s = [] then expr else procname(sum(''expr'',s[1] = 1 .. Dimension),subsop (1 = NULL,s)) fi end: `type/covarianttensor` := proc (x) options remember, system, `Copyright 1997 by R. Portugal. All right reserved.`: type(x,tensor) and type( map(op,[op(3 .. 4,`Riemann/indices`(x))]),list(covariantindex)) end: `index/Riemann/calc_w2I` := proc (ind, T) local s, i, j, k, l, t: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension-1 do for j from i+1 to Dimension do for k from i to Dimension-1 do if k = i then t := j else t := k+1 fi: for l from t to Dimension do tensor.WWName.4[-i,-j,-k,- l]: if ('"') <> 0 then if i = k and j = l then s := s-1/4*tensor.WeylStarName. 4[i,j,k,l]*('"') else s := s-1/2*tensor.WeylStarName.4[i,j,k,l]*('"') fi fi od od od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/codiff/symb` := proc (expr, x) local Christff, l, ind, m, deriv, i, conn: global ChristoffelName, CodiffSumIndex: option `Copyright 1997 by R. Portugal. All rights reserved.`: ind := op(3, `Riemann/indices`(expr)): l := op(x): if `Riemann/g_is_active` = true then conn := ChristoffelName: deriv := tdiff(subs(('codiff') = (' `Riemann/codiff/symb`'),expr),x) elif `Riemann/Vierbein_is_active` = true then conn := RicciCoeffName: m := `Riemann/codiff/genindex`([op(map(`Riemann/abs`, ind)), l, op(0,x), expr],CodiffSumIndex): deriv := 'tdiff'(expr,subs(l = m,x)) *VierbeinName[-l,m] else conn := ConnectionName: deriv := tdiff(subs(('codiff' ) = ('`Riemann/codiff/symb`'),expr),x) fi: m := `Riemann/codiff/genindex`([op( map(`Riemann/abs`,ind)), l, op(0,x), expr],CodiffSumIndex): Christff := proc ( i, m, l, expr, conn) if type(i,contravariantindex) then conn[i,-m,-l]*subs(i = m,expr) elif type(i,covariantindex) then -conn[m,i,-l]*subs(-i = m,expr) else ERROR(`expecting a covariant or a contravariant index`) fi end: deriv+add( Christff(i,m,l,expr,conn),i = ind) end: `Riemann/printt_old` := proc (x) option `Copyright 1995 by Renato Portugal`: if type(x,`=`) and not hastype(op(2,x),'indexed') then procname(op(1,x)) = op( 2,x) else `Riemann/printt/rec`(x,true) fi end: `Riemann/symmetrynames` := {antisymmpair, antisymm, symm, riemann, symmpair, cyclic, symmbvt, anticyclic, antisymmbvt}: `Riemann/indices/rec` := proc (expr) local i, ind, ind1, op0, n: option `Copyright 1997 by R. Portugal. All rights reserved.`: if type(expr,'indexed') then op(expr) elif type(expr,'function') then op0 := op(0,expr): if member(op0 ,'{diff, Diff, tdiff, codiff, Codiff}') then ind := `Riemann/indices`(op(1, expr)): ind1 := procname(op(2,expr)): if ind1 = NULL then op(op(1,ind)), op( map(proc (x) -x end,op(1,ind))), op(op(3,ind)), op(op(4,ind)) elif 1 < nops([ ind1]) or type(ind1,covariantindex) or type(-ind1,'string') and has(ind,-ind1) then ERROR(`wrong choice of indices in derivative`) else op(op(1,ind)), op(map (proc (x) -x end,op(1,ind))), op(op(3,ind)), op(op(4,ind)), -ind1 fi elif type (op0,'function') then op(0,op0): if " = ('D') then ind := `Riemann/indices`(op (op0)): op(op(3,ind)), op(op(4,ind)) elif type(",'indexed') and op(0,") = ('D' ) then if hastype(",covariantindex) then ERROR( `wrong choice of indices in D operator`) fi: ind := `Riemann/indices`(op(op0)) : op(op(3,ind)), op(op(4,ind)), op(map(proc (x) options operator, arrow: -x end,[op(")])) elif not hastype(",'indexed') then NULL else ERROR( `NOT IMPLEMENTED`) fi elif nops(expr) = 1 then ind := seq(op(i),i = op(3 .. 4, `Riemann/indices`(op(expr)))): if ind = NULL then NULL else userinfo(1,' Riemann',`assuming than function `.op0.` is linear in its argument`): ind fi elif 1 < nops(expr) then if hastype(expr,constanttensor) then ind := seq(op(i) ,i = op(3 .. 4,`Riemann/indices`(op(1,expr)))): if ind = NULL then NULL else userinfo(1,'Riemann',`assuming than function `.op0. ` has tensors in its 1st argument only`): ind fi else NULL fi else NULL fi elif type(expr,`*`) then ind1 := seq(`Riemann/indices`(i),i = expr): ind := seq(op(op(3,i)),i = ind1): if `intersect`({seq(op(op(1,i)),i = ind1)},{seq( `Riemann/abs`(i),i = ind)}) <> {} then ERROR( `summed index equal to free index`) fi: ind, seq(op(op(4,i)),i = ind1) elif type(expr,`+`) then ind := map(proc (x) op(3 .. 4,`Riemann/indices`(x)) end,[ op(expr)]): n := 1/2*nops(ind): if not nops({seq({op(op(2*i-1,ind))},i = 1 .. n)}) = 1 then `Riemann/printt`(expr): ERROR( `free indices do not match or summing tensors of different type`) fi: procname (op(1,expr)) elif type(expr,`^`) then ind := map(`Riemann/indices`,[op(expr)]) : if op(3,op(1,ind)) = [] and op(3,op(2,ind)) = [] then NULL else `Riemann/printt`(expr): ERROR(`free indices in power`) fi elif assigned(tensor .CoordinateName.1[0,0,2]) and member(expr,tensor.CoordinateName.1[0,0,1]) then subs(tensor.CoordinateName.1[0,0,2],expr) else NULL fi end: `index/Riemann/calc_LevCivV4` := proc (ind, T) local i, j, k, l, s, p, z, ind1 : option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned(T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): k := op(3,ind): l := op(4,ind): if type(i ,contravariantindex) then s := 1/sqrt(-tensordet.MetricVName.0[],symbolic) elif type(j,contravariantindex) then p := `Riemann/gtableasymm`[-i,j,k,l]: if p = 0 then s := 0 else if type(p,`*`) then z := -1: ind1 := op(-p) else z := 1 : ind1 := op(p) fi: s := z*tensor.MetricVName.2[i,i]*procname([ind1],T) fi elif type(k,contravariantindex) then p := `Riemann/gtableasymm`[i,-j,k,l]: if p = 0 then s := 0 else if type(p,`*`) then z := -1: ind1 := op(-p) else z := 1 : ind1 := op(p) fi: s := z*tensor.MetricVName.2[j,j]*procname([ind1],T) fi elif type(l,contravariantindex) then p := `Riemann/gtableasymm`[i,j,k,-l]: if p = 0 then s := 0 else if type(p,`*`) then z := -1: ind1 := op(-p) else z := 1 : ind1 := op(p) fi: s := z*tensor.MetricVName.2[l,l]*procname([ind1],T) fi elif type(l,covariantindex) then s := -sqrt(-tensordet.MetricVName.0[], symbolic) else ERROR(`LeviCivita tensor ill-defined`) fi: T[i,j,k,l] := `Riemann/simp_function`(LeviCivitaSign*s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/indices` := proc (expr) local nameind, repeated, ind, numind: options remember, system, `Copyright 1995 by Renato Portugal`: if nargs = 0 then RETURN([[], [], []]) fi: ind := [`Riemann/indices/rec`(expr)]: nameind := select(type,ind,nameindex): numind := select(type,ind,numericindex): if assigned(tensor.CoordinateName.1[0,0,2]) then numind := subs(tensor. CoordinateName.1[0,0,2],numind) fi: if nops(numind)+nops(nameind) <> nops(ind) then ERROR(`index of wrong type`) fi: if nops({op(nameind)}) <> nops(nameind) then print(`Riemann/printt`(expr)): ERROR( `wrong choice of indices in the expression above`) fi: map(proc (x) x = 0 end, {op(convert(nameind,`+`))}): repeated := select(type,subs(0 = NULL,subs(", nameind)),'string'): subs(0 = NULL,subs(map(proc (x) x = 0 end,"),nameind)): [ repeated, map(`Riemann/abs`,"), ", numind] end: `index/Riemann/calc_r1V` := proc (ind, T) local i, m, n, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else if `Riemann/g_is_diag` then s := 1/4*sum('tensor.MetricVName.2[i,i]*tensor.SSVName.2[-i,-i]',('i') = 1 .. Dimension) else s := 0: for m to Dimension do tensor.MetricVName.2[m,m]: if (' "') <> 0 then s := s+1/4*('"')*tensor.SSVName.2[-m,-m] fi: for n from m+1 to Dimension do tensor.MetricVName.2[m,n]: if ('"') <> 0 then s := s+1/2*('"')* tensor.SSVName.2[-m,-n] fi od od fi: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/alltensors` := proc (expr) option `Copyright 1997 by R. Portugal. All rights reserved.`: indets(expr,tensor) end : `index/Riemann/calc_RiemannV` := proc (ind, T) local i, j, k, l, m, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): k := op(3,ind): l := op(4,ind): if type(l, contravariantindex) then if `Riemann/eta_is_diag` then s := tensor.MetricVName .2[l,l]*procname([i, j, k, -l],T) else s := 0: for m to Dimension do tensor. MetricVName.2[l,m]: if ('"') <> 0 then s := s+('"')*procname([i, j, k, -m],T) fi od fi elif type(k,contravariantindex) then if `Riemann/eta_is_diag` then if k < -l then s := tensor.MetricVName.2[k,k]*procname([i, j, -k, l],T) else s := -tensor.MetricVName.2[k,k]*procname([i, j, l, -k],T) fi else s := 0: for m to Dimension do if m <> -l then tensor.MetricVName.2[k,m]: if ('"') <> 0 then if m < -l then s := s+('"')*procname([i, j, -m, l],T) else s := s-('"')*procname( [i, j, l, -m],T) fi fi fi od fi elif type(j,contravariantindex) then if `Riemann/eta_is_diag` then s := tensor.MetricVName.2[j,j]*procname([i, -j, k, l],T) else s := 0: for m to Dimension do tensor.MetricVName.2[j,m]: if ('"') <> 0 then s := s+('"')*procname([i, -m, k, l],T) fi od fi elif type(i, contravariantindex) then if `Riemann/eta_is_diag` then if i < -j then s := tensor.MetricVName.2[i,i]*procname([-i, j, k, l],T) else s := -tensor. MetricVName.2[i,i]*procname([j, -i, k, l],T) fi else s := 0: for m to Dimension do if m <> -j then tensor.MetricVName.2[i,m]: if ('"') <> 0 then if m < -j then s := s+('"')*procname([-m, j, k, l],T) else s := s-('"')*procname( [j, -m, k, l],T) fi fi fi od fi else s := 0: for m to Dimension do s := s+ tensor.RicciCoeffName.3[m,j,l]*tensor.RicciCoeffName.3[i,-m,k]-tensor. RicciCoeffName.3[m,j,k]*tensor.RicciCoeffName.3[i,-m,l]-tensor.CommutCoeffName .3[m,k,l]*tensor.RicciCoeffName.3[i,j,-m] od: if -i < -j then s := - RiemannVSign*(s+tensorDRicciCoeff4[i,j,l,k]-tensorDRicciCoeff4[i,j,k,l]) else s := -RiemannVSign*(s-tensorDRicciCoeff4[j,i,l,k]+tensorDRicciCoeff4[j,i,k,l]) fi fi: T[op(ind)] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[ 3]) fi end: `print/codiff` := proc (expr, x) local codiff: option `Copyright 1997 by R. Portugal. All rights reserved.`: if type(expr, constanttensor) then codiff[`Riemann/emerge`(op(x))](`print/t*e*n*s*o*r`(expr) ) else codiff[`Riemann/emerge`(op(x))](expr) fi end: `Riemann/latin_alphabet` := {a, b, c, e, d, f, g, h, i, j, k, l, m, n, o, p, q , r, s, t, u, v, w, x, z}: `index/Riemann/calc_m1IV` := proc (ind, T) local s, i, j: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension do tensor.TclRicciVName.2[i,i]: if ('"') <> 0 then s := s+1/8*('"')*tensor. SWStarVName.2[-i,-i] fi: for j from i+1 to Dimension do tensor.TclRicciVName.2 [i,j]: if ('"') <> 0 then s := s+1/4*('"')*tensor.SWStarVName.2[-i,-j] fi od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end : `Riemann/permute` := proc (l::list, x, result::name) local nl, f1, f2, rodd, reven, oddresult, evenresult, l1: option `Copyright 1997 by R. Portugal. All rights reserved.`: nl := nops(l): if nl < 2 then ERROR(`1st arg must have at least 2 elements`) elif nl = 2 then if x = ('odd') then if nargs = 3 then result := [l] fi: [[l[2], l[1]]] elif x = (' even') then if nargs = 3 then result := [[l[2], l[1]]] fi: [l] else ERROR( `2nd arg must be the name odd or even`) fi else f1 := proc (l, nl, l1) local i : seq([op(1 .. 2*i,l), l1, op(2*i+1 .. nl-1,l)],i = 0 .. iquo(nl-1,2)) end: f2 := proc (l, nl, l1) local i: seq([op(1 .. 2*i+1,l), l1, op(2*i+2 .. nl-1,l)],i = 0 .. iquo(nl-2,2)) end: l1 := l[1]: subsop(1 = NULL,l): rodd := procname(",' odd'): reven := procname("",'even'): oddresult := [op(map(f1,rodd,nl,l1)), op( map(f2,reven,nl,l1))]: evenresult := [op(map(f1,reven,nl,l1)), op(map(f2,rodd, nl,l1))]: if x = ('odd') then if nargs = 3 then result := evenresult fi: oddresult elif x = ('even') then if nargs = 3 then result := oddresult fi: evenresult else FAIL fi fi end: `type/covariantnameindex` := proc (x) options remember, system, `Copyright 1995 by Renato Portugal`: not type(x,numericindex) and type(-x,' string') end: `index/Riemann/calc_w2r` := proc (ind, T) local s, i, j, k, l, t: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension-1 do for j from i+1 to Dimension do for k from i to Dimension-1 do if k = i then t := j else t := k+1 fi: for l from t to Dimension do tensor.WWName.4[-i,-j,-k,- l]: if ('"') <> 0 then if i = k and j = l then s := s-1/4*tensor.WeylName.4[i, j,k,l]*('"') else s := s-1/2*tensor.WeylName.4[i,j,k,l]*('"') fi fi od od od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end : `index/antisymm` := proc (ind, T) local sign, ind1: options remember, `Copyright 1995 by R. Portugal`: if ind <> [] and ind[1] = 0 then if nargs = 2 then eval(T[op(ind)]) else T[op(ind)] := op(args[3]) fi: RETURN('"') fi: ind1 := `Riemann/ind1`(ind): sign := `Riemann/Riemann_order_ind1`(ind,ind1): if nargs = 2 then eval(sign*T[op(ind1)]) else if sign = 0 and op(args[3]) <> 0 then ERROR(`cannot assign non-zero to equal antisymmetric indices`) else T[op( ind1)] := sign*op(args[3]) fi fi end: `Riemann/for/Riemann_seq` := proc (expr, L) local i, j, k, l, t, L1, s: option `Copyright 1995 by Renato Portugal`: L1 := L[5 .. nops(L)]: s := NULL: for i to Dimension-1 do for j from i+1 to Dimension do for k from i to Dimension-1 do if k = i then t := j else t := k+1 fi: for l from t to Dimension do s := s, `Riemann/for/seq`(subs({L[1] = i, L[2] = j, L[3] = k, L[4] = l},expr),L1) od od od od end: `index/Riemann/calc_EinsteinV` := proc (ind, T) local i, j, m, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): if type(j,contravariantindex) then if `Riemann/eta_is_diag` then s := tensor.MetricVName.2[j,j]*procname([i, -j],T) else s := 0: for m to Dimension do tensor.MetricVName.2[j,m]: if ('"') <> 0 then s := s+('"')*procname([i, -m],T) fi od fi elif type(i,contravariantindex) then if `Riemann/eta_is_diag` then if i < -j then s := tensor.MetricVName.2[i, i]*procname([-i, j],T) else s := tensor.MetricVName.2[i,i]*procname([j, -i],T) fi else s := 0: for m to Dimension do tensor.MetricVName.2[i,m]: if ('"') <> 0 then if m < -j then s := s+('"')*procname([-m, j],T) else s := s+('"')* procname([j, -m],T) fi fi od fi else s := tensor.RicciVName.2[i,j]-1/2*tensor. MetricVName.2[i,j]*tensor.RicciScalarVName.0[] fi: T[i,j] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/tdiff/xs` := proc (expr) option `Copyright 1997 by R. Portugal. All rights reserved.`: if type(expr,'function' ) then if op(0,expr) = ('tdiff') and type(op(2,expr),constanttensor) then op(2 ,expr), procname(op(1,expr)) else expr fi else expr fi end: `Riemann/enter` := proc (A) local i, ff, e, p, tquote, dquote, quote: global `Riemann/history`: option `Copyright 1995 by Renato Portugal`: ff := proc (x) if `Riemann/CoordIndices` and type(-x,'string') then cat(`-`,-x) elif `Riemann/ZeroIndex` and x = -O then cat(`-`,O) else x fi end: tquote := op(1, eval(`Riemann/history`,1)): dquote := op(2,eval(`Riemann/history`,1)): quote := op(3,eval(`Riemann/history`,1)): p := cat(`enter component `,op(0,A),`[`,ff (`Riemann/emerge`(op(1,A))),seq(cat(`,`,ff(`Riemann/emerge`(op(i,A)))),i = 2 .. nops(A)),`] :`): e := traperror(readstat(p,tquote,dquote,quote)): while e = lasterror do lprint(e): e := traperror(readstat(p,tquote,dquote,quote)) od: if e <> NULL then assign('cat'(tensor,op(0,A),nops(A))[op(A)] = e): tquote := dquote: dquote := quote: quote := [e] fi: `Riemann/history` := [tquote, dquote , quote]: NULL end: `index/Riemann/calc_detMetricVName` := proc (ind, T) option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] elif `Riemann/eta_is_diag` then T[] := `Riemann/simp_function`(product('tensor.MetricVName.2[-i,-i]',('i') = 1 .. Dimension)) else if assigned(`Riemann/det_eta`) then T[] := `Riemann/simp_function`(`Riemann/det_eta`) else T[] fi fi else T[op(ind)] := op(args[3]) fi end: `Riemann/gtableasymm` := table(antisymmetric,[]): `type/covariantnumericindex` := proc (x) options remember, system, `Copyright 1995 by Renato Portugal`: if `Riemann/CoordIndices` and assigned( tensor.CoordinateName.1[0,0,1]) and member(-x,tensor.CoordinateName.1[0,0,1]) then true elif `Riemann/ZeroIndex` and x = -O then true elif not type(-x, nonnegint) then false elif x < -Dimension or Dimension < x then ERROR( `index outside Dimension`) elif x = 0 then if `Riemann/ZeroIndex` then ERROR( `use the letter O instead of zero`) else ERROR( `zero cannot be used as index when ZeroIndex is turned off`) fi else true fi end: `index/Riemann/calc_m5IV` := proc (ind, T) local s, i, j, k, l, t: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension-1 do for j from i+1 to Dimension do tensor.WeylStarVName.4[i,j,i,j]: if ('"') <> 0 then s := s+1/16*('"')*(tensor.SWVName.2[-i,-j]^2-tensor.SWVName.2[-i,-i]* tensor.SWVName.2[-j,-j]+tensor.SWStarVName.2[-i,-j]^2-tensor.SWStarVName.2[-i, -i]*tensor.SWStarVName.2[-j,-j]) fi: for k from i to Dimension-1 do if k = i then t := j+1 else t := k+1 fi: for l from t to Dimension do tensor. WeylStarVName.4[i,j,k,l]: if ('"') <> 0 then s := s+1/8*('"')*(tensor.SWVName. 2[-i,-l]*tensor.SWVName.2[-j,-k]-tensor.SWVName.2[-i,-k]*tensor.SWVName.2[-j,- l]+tensor.SWStarVName.2[-i,-l]*tensor.SWStarVName.2[-j,-k]-tensor.SWStarVName. 2[-i,-k]*tensor.SWStarVName.2[-j,-l]) fi od od od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_w2IV` := proc (ind, T) local s, i, j, k, l, t: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension-1 do for j from i+1 to Dimension do for k from i to Dimension-1 do if k = i then t := j else t := k+1 fi: for l from t to Dimension do tensor.WWVName.4[-i,-j,-k, -l]: if ('"') <> 0 then if i = k and j = l then s := s-1/4*tensor. WeylStarVName.4[i,j,k,l]*('"') else s := s-1/2*tensor.WeylStarVName.4[i,j,k,l] *('"') fi fi od od od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/eta_is_diag` := false: `Riemann/for` := proc (A, B, ind, atrib, SYMM) local ind1, ind2, i, j, k, l, L , Symm: global `Riemann/switch1`: option `Copyright 1995 by Renato Portugal`: `Riemann/switch1` := true: if SYMM = ('nosymm') then ind1 := map(`Riemann/abs` ,ind): `Riemann/for/nosymm`(A,B,ind1,[],atrib,1,'nosymm') elif SYMM = ('symm') then ind1 := select(type,ind,contravariantindex): ind2 := map(`Riemann/abs`, select(type,ind,covariantindex)): `Riemann/for/symm`(A,B,ind1,ind2,atrib,1,' symm') elif SYMM = ('antisymm') then ind1 := select(type,ind, contravariantindex): ind2 := map(`Riemann/abs`,select(type,ind,covariantindex) ): `Riemann/for/antisymm`(A,B,ind1,ind2,atrib,1,'antisymm') elif SYMM = (' riemann') then ind1 := [op(1 .. 4,ind)]: ind2 := map(`Riemann/abs`,[op(5 .. nops(ind),ind)]): L := map(proc (x) if op(1,x) = -1 then -1 else 1 fi end,ind1 ): ind1 := map(`Riemann/abs`,ind1): i := op(1,ind1): j := op(2,ind1): k := op( 3,ind1): l := op(4,ind1): if member(L,{[1, 1, 1, 1], [-1, -1, -1, -1]}) then `Riemann/for/Riemann`(A,B,ind1,ind2,atrib,1,'nosymm') elif member(L,{[1, -1, -\ 1, -1], [-1, 1, -1, -1], [1, -1, 1, 1], [-1, 1, 1, 1]}) then `Riemann/for/antisymm`(A,B,[k, l],[i, j, op(ind2)],atrib,1,'nosymm') elif member(L,{[1, 1, -1, -1], [-1, -1, 1, 1]}) and ind2 = [] then `Riemann/for/antisymm`(A,B,[i, j],[k, l],atrib,1,'antisymm') elif member(L,{[1 , 1, 1, -1], [1, 1, -1, 1], [-1, -1, 1, -1], [-1, -1, -1, 1]}) then `Riemann/for/antisymm`(A,B,[i, j],[k, l, op(ind2)],atrib,1,'nosymm') elif member(L,{[1, -1, 1, -1], [-1, 1, -1, 1]}) and ind2 = [] then `Riemann/for/symm`(A,B,[i, k],[j, l],atrib,1,'symm') else `Riemann/for/nosymm` (A,B,[op(ind1), op(ind2)],[],atrib,1,'nosymm') fi elif type(SYMM,'indexed') then Symm := op(0,SYMM): i := op(1,SYMM): j := op(2,SYMM): k := op(i,ind): l := op(j,ind): if op(1,k*l) = -1 then `Riemann/for/nosymm`(A,B,map( `Riemann/abs`,ind),[],atrib,1,'nosymm') else ind1 := [`Riemann/abs`(k), `Riemann/abs`(l)]: ind2 := map(`Riemann/abs`,subsop(i = NULL,j = NULL,ind)): `Riemann/for/`.Symm(A,B,ind1,ind2,atrib,1,'nosymm') fi elif SYMM = ('diagonal' ) or SYMM = ('identity') then `Riemann/for/diagonal`(A,B,map(`Riemann/abs`,ind ),[],atrib,1,'nosymm') else ERROR(`wrong symmetry name`) fi: if `Riemann/switch1` and `Riemann/DisplayTensor` then print(`Riemann/printt`(A) = 0) fi end: `Riemann/apply` := proc (SYMM, ind, F, A) local ind1, ind2, i, j, k, l, L, Symm: option `Copyright 1995 by Renato Portugal`: if SYMM = ('nosymm') then ind1 := map(`Riemann/abs`,ind): `Riemann/apply/nosymm`(A,ind1,[],1,'nosymm',F, args[5 .. nargs]) elif SYMM = ('symm') then ind1 := select(type,ind, contravariantindex): ind2 := map(`Riemann/abs`,select(type,ind,covariantindex) ): `Riemann/apply/symm`(A,ind1,ind2,1,symm,F,args[5 .. nargs]) elif SYMM = (' antisymm') then ind1 := select(type,ind,contravariantindex): ind2 := map( `Riemann/abs`,select(type,ind,covariantindex)): `Riemann/apply/antisymm`(A, ind1,ind2,1,'antisymm',F,args[5 .. nargs]) elif SYMM = ('riemann') then ind1 := [op(1 .. 4,ind)]: ind2 := map(`Riemann/abs`,[op(5 .. nops(ind),ind)]): L := map(proc (x) if op(1,x) = -1 then -1 else 1 fi end,ind1): ind1 := map( `Riemann/abs`,ind1): i := op(1,ind1): j := op(2,ind1): k := op(3,ind1): l := op(4,ind1): if member(L,{[1, 1, 1, 1], [-1, -1, -1, -1]}) then `Riemann/apply/Riemann`(A,ind1,ind2,1,'nosymm',F,args[5 .. nargs]) elif member (L,{[1, -1, -1, -1], [-1, 1, -1, -1], [1, -1, 1, 1], [-1, 1, 1, 1]}) then `Riemann/apply/antisymm`(A,[k, l],[i, j, op(ind2)],1,'nosymm',F,args[5 .. nargs]) elif member(L,{[1, 1, -1, -1], [-1, -1, 1, 1]}) and ind2 = [] then `Riemann/apply/antisymm`(A,[i, j],[k, l],1,'antisymm',F,args[5 .. nargs]) elif member(L,{[1, 1, 1, -1], [1, 1, -1, 1], [-1, -1, 1, -1], [-1, -1, -1, 1]}) then `Riemann/apply/antisymm`(A,[i, j],[k, l, op(ind2)],1,'nosymm',F,args[5 .. nargs]) elif member(L,{[1, -1, 1, -1], [-1, 1, -1, 1]}) and ind2 = [] then `Riemann/apply/symm`(A,[i, k],[j, l],1,'symm',F,args[5 .. nargs]) else `Riemann/apply/nosymm`(A,[op(ind1), op(ind2)],[],1,'nosymm',F,args[5 .. nargs] ) fi elif type(SYMM,'indexed') then Symm := op(0,SYMM): i := op(1,SYMM): j := op(2,SYMM): k := op(i,ind): l := op(j,ind): if op(1,k*l) = -1 then `Riemann/apply/nosymm`(A,map(`Riemann/abs`,ind),[],1,'nosymm',F,args[5 .. nargs]) else ind1 := [`Riemann/abs`(k), `Riemann/abs`(l)]: ind2 := map( `Riemann/abs`,subsop(i = NULL,j = NULL,ind)): `Riemann/apply/`.Symm(A,ind1, ind2,1,'nosymm',F,args[5 .. nargs]) fi elif SYMM = ('diagonal') or SYMM = (' identity') then `Riemann/apply/diagonal`(A,map(`Riemann/abs`,ind),[],1,'nosymm ',F,args[5 .. nargs]) else ERROR(`wrong symmetry name`) fi end: `Riemann/for/symm` := proc (A, B, ind1, ind2, atrib, firstindex, p_name) local i, l1, Lind1: option `Copyright 1995 by Renato Portugal`: if ind1 = [] then `Riemann/for/`.p_name(A,B,ind2,[],atrib,1,'nosymm') else l1 := op(1,ind1): Lind1 := subsop(1 = NULL,ind1): for i from firstindex to Dimension do procname (op(subs(l1 = i,'[A, B]')),Lind1,ind2,atrib,i,p_name) od fi end: `index/Riemann/calc_r1` := proc (ind, T) local i, m, n, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else if `Riemann/g_is_diag` then s := 1/4*sum('tensor.MetricName.2[i,i]*tensor.SSName.2[-i,-i]',('i') = 1 .. Dimension) else s := 0: for m to Dimension do tensor.MetricName.2[m,m]: if ('" ') <> 0 then s := s+1/4*('"')*tensor.SSName.2[-m,-m] fi: for n from m+1 to Dimension do tensor.MetricName.2[m,n]: if ('"') <> 0 then s := s+1/2*('"')* tensor.SSName.2[-m,-n] fi od od fi: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_SS` := proc (ind, T) local i, j, m, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): s := 0: for m to Dimension do tensor.TclRicciName.2 [i,-m]: if ('"') <> 0 then s := s+('"')*tensor.TclRicciName.2[m,j] fi od: T[i, j] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_r2` := proc (ind, T) local m, n, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for m to Dimension do tensor.TclRicciName.2[m,m]: if ('"') <> 0 then s := s-1/8*('"')*tensor.SSName. 2[-m,-m] fi: for n from m+1 to Dimension do tensor.TclRicciName.2[m,n]: if ('" ') <> 0 then s := s-1/4*('"')*tensor.SSName.2[-m,-n] fi od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/symm_Christoffel` := proc (ind, T) local i, j: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if ind[1] = 0 then if nargs = 2 then T[op(ind)] else T[op(ind)] := op(args[3]) fi else i := op(2,ind): j := op(3,ind): if not type([i, j],list(covariantindex)) then ERROR( `the last 2 indices of Christoffel symbols must be covariant`) elif not `Riemann/order`(i,j) then if nargs = 2 then T[op(1,ind),j,i] else T[op(1,ind), j,i] := op(args[3]) fi elif nargs = 2 then T[op(ind)] else T[op(ind)] := op( args[3]) fi fi end: `index/Riemann/calc_r3` := proc (ind, T) local i, j, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension do tensor.SSName.2[-i,-i]: if ('"') <> 0 then s := s+1/16*('"')*tensor.SSName.2[i ,i] fi: for j from i+1 to Dimension do tensor.SSName.2[-i,-j]: if ('"') <> 0 then s := s+1/8*('"')*tensor.SSName.2[i,j] fi od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `convert/matrix` := proc (A1::uneval) local A, ind, r: option `Copyright 1997 by R. Portugal. All rights reserved.`: A := `Riemann/ltensor/ltensor`(A1): if type(A,tensor) then ind := `Riemann/indices` (A): if map(nops,ind) = [0, 2, 2, 0] then linalg[matrix](Dimension,Dimension, `Riemann/printt`([`Riemann/seq`(`Riemann/sum`(A),op(2,ind),'nosymm')])) else ERROR(`wrong number or type of indices in conversion to matrix`) fi else r := traperror(`Riemann/convert/matrix`(A)): if r = `expecting array or list` then ``.r.` or tensor` else ERROR(lasterror) fi fi end: `Riemann/codiff/usedind1` := {}: `index/Riemann/symm_RicciCoeff` := proc (ind, T) local i, j: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if ind[1] = 0 then if nargs = 2 then T[op(ind)] else T[op(ind)] := op(args[3]) fi else i := op(1,ind): j := op(2,ind): if i = j then if nargs = 2 then 0 elif op(args[3]) <> 0 then ERROR( `cannot assign non-zero to equal antisymmetric indices`) else T[op(ind)] := 0 fi elif not `Riemann/Riemann_order`(i,j) then if nargs = 2 then -T[j,i,op(3, ind)] else T[j,i,op(3,ind)] := -op(args[3]) fi elif nargs = 2 then T[op(ind)] else T[op(ind)] := op(args[3]) fi fi end: `index/Riemann/calc_m1I` := proc (ind, T) local s, i, j: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for i to Dimension do tensor.TclRicciName.2[i,i]: if ('"') <> 0 then s := s+1/8*('"')*tensor. SWStarName.2[-i,-i] fi: for j from i+1 to Dimension do tensor.TclRicciName.2[i ,j]: if ('"') <> 0 then s := s+1/4*('"')*tensor.SWStarName.2[-i,-j] fi od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/codiff/usedind2` := {}: `index/Riemann/calc_SW` := proc (ind, T) local i, j, m, n, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or hastype(ind,'string') or ind[1] = 0 then T[op(ind)] else i := op(1,ind): j := op(2,ind): s := 0: for m to Dimension do tensor.TclRicciName.2 [m,m]: if ('"') <> 0 then s := s+tensor.WeylName.4[i,-m,-m,j]*('"') fi: for n from m+1 to Dimension do tensor.TclRicciName.2[m,n]: if ('"') <> 0 then s := s +('"')*(tensor.WeylName.4[i,-m,-n,j]+tensor.WeylName.4[i,-n,-m,j]) fi od od: T [op(ind)] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `index/Riemann/calc_r2V` := proc (ind, T) local m, n, s: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if nargs = 2 then if assigned( T[op(ind)]) or ind <> [] then T[op(ind)] else s := 0: for m to Dimension do tensor.TclRicciVName.2[m,m]: if ('"') <> 0 then s := s-1/8*('"')*tensor. SSVName.2[-m,-m] fi: for n from m+1 to Dimension do tensor.TclRicciVName.2[m,n ]: if ('"') <> 0 then s := s-1/4*('"')*tensor.SSVName.2[-m,-n] fi od od: T[] := `Riemann/simp_function`(s) fi else T[op(ind)] := op(args[3]) fi end: `Riemann/usedindices_max` := 12: `Riemann/DisplayTensor` := true: Dimension := 4: `index/Riemann/symm_Ricci` := proc (ind, T) local i, j: option `Copyright 1995 by R. Portugal and S.L. Sautu`: if ind[1] = 0 then if nargs = 2 then T[op(ind)] else T[op(ind)] := op(args[3]) fi else i := op(1,ind): j := op(2,ind): if not `Riemann/Riemann_order`(i,j) then if nargs = 2 then T[j,i] else T[j,i] := op(args[3]) fi elif nargs = 2 then T[op(ind)] else T[op(ind)] := op(args[3]) fi fi end: ############################################################################## with(Riemann); ########################## THE END #########################################