load(ctensor);

load(vector);

ct_coords:[t,x,y,z];

E : transpose(matrix([E_x,E_y,E_z]));

ESq_from_E : transpose(E) . E;

B : transpose(matrix([B_x,B_y,B_z]));

BSq_from_B : transpose(B) . B;

S : transpose(matrix([S_x,S_y,S_z]));

S . transpose(S);

E cross B$
matrix(%[1][1], %[1][2], %[1][3])$
S_from_E_B : %;

transpose(S) . S;
subst([S_x=S_from_E_B[1,1],S_y=S_from_E_B[2,1],S_z=S_from_E_B[3,1]],%);
ratsimp(%);
SSq_from_E_B : %;

S_from_E_B . transpose(S_from_E_B)$
ratsimp(%);

gEM : E . transpose(E) + B . transpose(B) + ident(3);

determinant(gEM);
ratsimp(%);
det_gEM : %;

det_gEM - SSq_from_E_B - ESq_from_E - BSq_from_B - 1;
ratsimp(%);

invert(gEM) * det_gEM$
ratsimp(%);
% - S_from_E_B . transpose(S_from_E_B) + S . transpose(S)$
ratsimp(%);

lg : genmatrix(lambda([i,j],
        if i=1 and j=1 then -1
        /*else if i > 1 and j > 1 then -(gEM[i-1,j-1] + (if i=j then 1 else 0))*/
        else if i=j then 1
        else 0 ),4,4);

cmetric();

lg;

ug;

christof(mcs);

lriemann(mcs);

ricci(mcs);

scurvature();

rinvariant();