# I can't find any mistake in my code! [closed]

Clear[coord,metric,inversemetric,affine,riemann,ricci,scalar,r,θ,ϕ]
n = 3

coord = {r,θ,ϕ}

metric = {{(1 - ((r^2)/3) - ((2 m)/r))^(-1), 0, 0}, {0, r^2, 0},
{0, 0, r^2*(sin[θ])^2}}

MatrixForm[metric]

inversemetric = Simplify[Inverse[metric]]

MatrixForm[inversemetric]

affine = Simplify[
Table[(1/2)*
Sum[(inversemetric[[i, s]])*(D[metric[[s, j]], coord[[k]]] +
D[metric[[s, k]], coord[[j]]] -
D[metric[[j, k]], coord[[s]]]), {s, 1, n}], {i, 1, n}, {j, 1,
n}, {k, 1, n}]]

listaffine :=
Table[If[UnsameQ[affine[[i, j, k]],
0], {ToString[Γ[i, j, k]], affine[[i, j, k]]}], {i,
1, n}, {j, 1, n}, {k, 1, j}]

TableForm[Partition[DeleteCases[Flatten[listaffine], Null], 2],
TableSpacing -> {2, 2}]

riemann = Simplify[Table[
D[affine[[ i,j,l]],coord[[k]]]-
D[affine[[ i,j,k]],coord[[l]]]+Sum[affine[[ s,j,l]]affine[[i,k,s]]-
affine[[s,j,k]]affine[[i,l,s]],{s,1,n}],{i,1,n},{j,1,n},{k,1,n},{l,1,n}]]

listriemann:=Table[If[UnsameQ[riemann[[i,j,k,l]],0],{ToString[R[
i,j,k,l]],riemann[[i,j,k,l]]}],{i,1,n},{j,1,n},{k,1,n},{l,1,k - 1}]

TableForm[Partition[DeleteCases[Flatten[listriemann],Null],2],TableSpacing
->{2,2}]


Output:

ricci=Simplify[Table[Sum[riemann[ [i,j,i,l]],{i,1,n}],{j,1,n},
{l,1,n}]]

listricci:=Table[If[UnsameQ[ ricci[[ j, l]], 0], {ToString[
R[j,l]],ricci[[j,l]]}],{j,1,n},{l, 1, j}]

TableForm[Partition [DeleteCases[ Flatten[ listricci], Null],2],TableSpacing
-> {2, 2}]


Output:

scalar = Simplify[
Sum[inversemetric [[i, j]] ricci [[i, j]], {i, 1, n}, {j, 1, n}]]


Output:

By using these results, I found that the metric is not Einstein, but someone said to me that my calculation was wrong, and the metric was supposed to be Einstein. So I think maybe there's something wrong with my code, but I just can't find any. Please someone help me to figure it out, thanks!

• related by OP on physics.SE: physics.stackexchange.com/q/420798/84967 Aug 5 '18 at 13:43
• You've been told, by several users already, that your metric is not Einstein. I'm not sure why you insist. It is not. And if you do believe it is Einstein, then you'll have to include a reputable reference where it is claimed that it is. "someone said to me" is useless. Aug 5 '18 at 13:44
• That being said, there are several problems with your code. For one thing, you should use Sin instead of sin, the former being the sine function, the latter being undefined. Basic differential geometry operations are defined in Compute covariant derivative in Mathematica. In particular, I used that code when I said to you, on physics.SE, that your metric is not Einstein. Please do check it for yourself. Aug 5 '18 at 13:47
• I checked this metric with my code. All calculations are the same. There are no errors in your code. Of course, we must take Sin[] instead of a sin, but it is not necessary. And so everything is clear. Aug 5 '18 at 14:11
• @AccidentalFourierTransform I do believe that the metric is not Einstein. I just want to make sure that my calculation is not wrong. Thank you I will check it. Aug 5 '18 at 14:17