with guv=diagonal{1,1,1,-1}, lowering an index of tXY just switches the sign of tXY[[4,4]]: tXy=diagonal{a,b,c,-d} the trace of this matrix is a+b+c-d Note: the trace of the original tXY would be an improper sum...we always sum a pair of raised/lowered indices, hence the need to lower an index before taking the trace uR={Sqrt[x^2+y^2+z^2], ArcTan[Sqrt[x^2+y^2]/z], ArcTan[y/x],t} uX={x,y,z,t} aP=ConstantArray[0,{4,4}] Do[aP[[i,j]]=D[ uR[[i]],uX[[j]]] ,{i,4},{j,4}] aP=FullSimplify[Evaluate[aP /. {x-> r Sin[t] Cos[p], y->r Sin[t] Sin[p], z->r Cos[t]}],{Sin[t]>0,r>0}] MatrixForm[aP] Out[6]//MatrixForm= Cos[p] Sin[t] Sin[p] Sin[t] Cos[t] 0 Cos[p] Cos[t] Cos[t] Sin[p] Sin[t] ------------- ------------- -(------) r r r 0 Csc[t] Sin[p] Cos[p] Csc[t] -(-------------) ------------- r r 0 0 0 0 0 1 Note: first index of aP is uR, second is uX; we will be summing on the second index --- If you do the inverse (and you probably DO NOT want to) uR={r,t,p,ti} uX={r Sin[t] Cos[p], r Sin[t] Sin[p], r Cos[t],ti} ap=ConstantArray[0,{4,4}] Do[ap[[i,j]]=D[ uX[[i]],uR[[j]]] ,{i,4},{j,4}] MatrixForm[ap] Out[17]//MatrixForm= Cos[p] Sin[t] r Cos[p] Cos[t] -(r Sin[p] Sin[t]) 0 Sin[p] Sin[t] r Cos[t] Sin[p] r Cos[p] Sin[t] 0 Cos[t] -(r Sin[t]) 0 0 0 0 0 1 --- tXY=DiagonalMatrix[{a,b,c,d}] tRP=ConstantArray[0,{4,4}] Do[ tRP[[i,j]]=Sum[aP[[i,a1]] aP[[j,b1]] tXY[[a1,b1]],{a1,4},{b1,4}],{i,4},{j,4}] tRP=FullSimplify[tRP,Sin[t]>0] grp=DiagonalMatrix[{1,r^2,r^2 Sin[t]^2,-1}] FullSimplify[Tr[tRP.grp]] Out[11]= a + b + c - d ---alt--- it is easier (for people) to find the reverse transformation matrix (ap) with derivatives of x,y,z,time wrt r,t,p,time and then recognize that the desired matrix (aP) is the inverse of that matrix. You do need to keep careful track of what is in columns/rows rX={r Cos[p] Sin[t], r Sin[p] Sin[t], r Cos[t],ti} ap=ConstantArray[0,{4,4}] ap={ D[rX,r], D[rX,t], D[rX,p], D[rX,ti]} Note: columns are x,y,z,ti; rows are r,t,p,ti if you take the Inverse of this matrix, rows are x,y,z,ti; columns are r,t,p,ti This is the reverse of the above aP aP2=FullSimplify[Inverse[ap]] tRP2=ConstantArray[0,{4,4}] Do[ tRP2[[i,j]]=Sum[aP2[[a1,i]] aP2[[b1,j]] tXY[[a1,b1]],{a1,4},{b1,4}],{i,4},{j,4}] tRP2=FullSimplify[tRP2,Sin[t]>0] this is the same as above tRP 2 2 2 2 2 2 Cos[t] (-c + a Cos[p] + b Sin[p] ) Sin[t] Out[41]= {{c Cos[t] + (a Cos[p] + b Sin[p] ) Sin[t] , ------------------------------------------, r 2 2 (-a + b) Cos[p] Sin[p] Cos[t] (-c + a Cos[p] + b Sin[p] ) Sin[t] > ----------------------, 0}, {------------------------------------------, r r 2 2 2 2 Cos[t] (a Cos[p] + b Sin[p] ) + c Sin[t] (-a + b) Cos[p] Cot[t] Sin[p] > -------------------------------------------, -----------------------------, 0}, 2 2 r r 2 2 2 (-a + b) Cos[p] Sin[p] (-a + b) Cos[p] Cot[t] Sin[p] Csc[t] (b Cos[p] + a Sin[p] ) > {----------------------, -----------------------------, -------------------------------, 0}, r 2 2 r r > {0, 0, 0, d}} Remark: tRP is much simplier if tXY is spacially symmetric, i.e., a=b=c FullSimplify[%] 2 a a Csc[t] Out[45]= {{a, 0, 0, 0}, {0, --, 0, 0}, {0, 0, ---------, 0}, {0, 0, 0, d}} 2 2 r r