-- electromagnetic tensor demo -- u for up index, d for down index gdd = ((1,0,0,0),(0,-1,0,0),(0,0,-1,0),(0,0,0,-1)) guu = inv(gdd) A = (Ax(),Ay(),Az()) Au = (phi(),Ax(),Ay(),Az()) Ad = dot(gdd,Au) B = curl(A) E = -d(phi(),(x,y,z)) - d(A,t) Bx = B[1] By = B[2] Bz = B[3] Ex = E[1] Ey = E[2] Ez = E[3] X = (t,x,y,z) Add = d(Ad,X) Fdd = transpose(Add) - Add Fdd T = ((0, Ex, Ey, Ez), (-Ex, 0, -Bz, By), (-Ey, Bz, 0, -Bx), (-Ez, -By, Bx, 0)) check(Fdd == T) Fuu = dot(guu,Fdd,guu) T = contract(dot(transpose(Fdd),Fuu)) check(T == 2 dot(B,B) - 2 dot(E,E)) check(det(Fdd) == dot(B,E)^2) check(det(Fuu) == dot(B,E)^2) Ju = contract(d(Fuu,X),1,3) check(contract(d(Ju,X)) == 0) Jx = Ju[2] Jy = Ju[3] Jz = Ju[4] J = (Jx,Jy,Jz) check(J == curl(B) - d(E,t)) "ok"
Run