2 (if get('itensor,'version)=false then load(itensor),done);
8 decsym(s,2,0,[sym(all)],[]);
10 canform(s([i,j],[])-s([j,i],[]));
12 decsym(a,2,0,[anti(all)],[]);
14 canform(a([i,j],[])+a([j,i],[]));
18 canform(a([i,j],[])-a([j,i],[]));
22 rename(a([i,j1],[])*b([],[j1,k])+a([i,j2],[])*b([],[j2,k]));
23 2*a([i,%1],[])*b([],[%1,k]);
25 (kill(h),remcomps(h));
27 components(h([],[i,j]),e([],[i,j])/p([],[]));
31 (kill(h),remcomps(h));
36 contract(e([a],[b])*f([b],[c]));
40 contract(kdelta([a],[b])*kdelta([b],[a]));
44 contract(g([i,j],[])*g([],[j,k]));
46 /* Curvature and covariant derivatives */
47 (flipflag:false,rename(icurvature([s,u,n],[y])));
48 ichr2([s,u],[y],n)-ichr2([s,n],[y],u)+ichr2([%1,n],[y])*ichr2([s,u],[%1])-ichr2([%1,u],[y])*ichr2([s,n],[%1]);
49 canform(icurvature([l,j,k],[i])+icurvature([k,l,j],[i])+icurvature([j,k,l],[i]));
51 canform(covdiff(icurvature([j,m,k],[i]),l)+covdiff(icurvature([j,l,m],[i]),k)+covdiff(icurvature([j,k,l],[i]),m));
53 contract(expand(kdels([i,j,k],[l,m,n])*kdelta([l,m,n],[i1,i2,i3])));
56 levi_civita([i,j,j],[]);
57 kdelta([i,j,j],[1,2,3]);
60 contract(expand(lc2kdt('levi_civita([i,j,k],[])*a([],[j])*'levi_civita([],[k,l,n])*b([l],[])*c([n],[]))));
61 a([],[n])*b([i],[])*c([n],[])-a([],[l])*c([i],[])*b([l],[]);
62 contract(expand(lc2kdt('levi_civita([i,j,k],[])*a([],[j])*b([],[k])*'levi_civita([],[i,l,n])*c([l],[])*u([n],[]))));
63 a([],[l])*b([],[n])*c([l],[])*u([n],[])-b([],[l])*a([],[n])*c([l],[])*u([n],[]);
64 canform(contract(expand(applyb1('levi_civita([],[i,j,k])*a([j])*a([k]),lc_l,lc_u))));
66 /* Frames, derivatives */
69 idiff(idiff(v([i],[]),k),l)-idiff(idiff(v([i],[]),l),k);
73 idiff(idiff(v([i],[]),k),l)-idiff(idiff(v([i],[]),l),k);
74 v([i],[],k,l)-v([i],[],l,k);
78 'idiff(v([i],[]),k,1);
80 (g([j,k],[],i)+g([i,k],[],j)-g([i,j],[],k))/2;
81 rename(ichr2([i,j],[k]));
82 g([],[k,%1])*(g([j,%1],[],i)-g([i,j],[],%1)+g([i,%1],[],j))/2;
83 (remove(a,constant),rename(covdiff(a([j,k],[i]),i)));
84 a([j,k],[%1],%1)+a([j,k],[%2])*ichr2([%2,%1],[%1])-a([j,%2],[%1])*ichr2([k,%1],[%2])-a([%2,k],[%1])*ichr2([j,%1],[%2]);
85 canform(factor(canform(covdiff(v([],[i]),k,l)-covdiff(v([],[i]),l,k)))-v([],[j])*icurvature([j,k,l],[i]));
87 /* TODO: flush & relatives, lorentz, conmetderiv */
88 /* Exterior algebra */
90 (a([i],[])*b([j],[])-a([j],[])*b([i],[]))/2;
91 decsym(p,2,0,[anti(all)],[]);
93 factor(canform(extdiff(p([j,k]),i)));
94 (p([j,k],[],i)-p([i,k],[],j)+p([i,j],[],k))/3;
95 extdiff(a([j])~b([k]),k);
97 factor(a([i1])~b([i2])|a+a([i2])~b([i1])|a);
99 canform(liediff(v,extdiff(a([i1]),i2))-extdiff(liediff(v,a([i1])),i2));
101 decsym(g,2,0,[sym(all)],[]);
103 decsym(g,0,2,[],[sym(all)]);
105 canform(g([a,d],[])*g([b,e],[])*g([],[b,a],c));
106 g([%1,e],[])*g([%2,d],[])*g([],[%1,%2],c);
107 canform(g([],[a,d])*g([],[b,e])*g([b,a],[]));
108 g([],[%1,e])*g([],[%2,d])*g([%1,%2],[]);
109 canform(g([],[a,b])*A([a],[],c)*A([b],[],d));
110 g([],[%1,%2])*A([%1],[],d)*A([%2],[],c);
111 canform(g([],[a,b])*A([a],[],d)*A([b],[],c));
112 g([],[%1,%2])*A([%1],[],d)*A([%2],[],c);
113 decsym(a,0,2,[],[anti(all)]);
115 canform(a([A,B],[])*a([],[B,C]));
116 -a([],[%1,C])*a([%1,A],[]);
117 canform(a([A,B],[])*a([],[C,B]));
118 a([],[%1,C])*a([%1,A],[]);
119 det(H):=block([idx1:makelist(idummy(),i,1,dim),idx2:makelist(idummy(),i,1,dim)],'kdelta(idx1,idx2)*product(H([idx2[i]],[idx1[i]]),i,1,dim)/dim!);
120 det(H):=block([idx1:makelist(idummy(),i,1,dim),idx2:makelist(idummy(),i,1,dim)],'kdelta(idx1,idx2)*product(H([idx2[i]],[idx1[i]]),i,1,dim)/dim!);
121 components(H([],[]),H([i],[i]));
125 apply(ev,[contract(apply(ev,[contract(apply(ev,[det(H),nouns,expand])),nouns])),nouns]);
127 /* ic_convert: In recent versions, this test 'fails' with the correct result */
128 /*ic_convert(f([a],[b])=g([],[b,c])*(B([a],[],c)-C([],[d])*g([a,d],[],c)));
129 for a thru dim do (for b thru dim do f[a,b]:sum(ug[b,c]*diff(B[a],ct_coords[c]),c,1,dim)-sum(sum(ug[b,c]*C[d]*diff(lg[a,d],ct_coords[c]),c,1,dim),d,1,dim));*/
130 /* TODO: torsion, nonmetricity tensors, connection coeffs */