defining polar Minkowski metric (with indecies down in polar coordinates) as
gdd = {{-1, 0, 0, 0},{0, 1, 0, 0},{0, 0, r^2, 0},{0, 0, 0, r^2 Sin[\[Theta]]^2}}
and using the code in Covariant derivative given Christoffel symbols we define Affine connection
Γudd[aa_, bb_, cc_] := (1/2)*Sum[guu[[aa,dd]]*(D[gdd[[dd,cc]], clist[[bb]]] + D[gdd[[dd,bb]], clist[[cc]]] -
D[gdd[[bb,cc]], clist[[dd]]]), {dd, 1, Length[gdd]}]
Then the covariant derivative
covDu[A_, a_, b_] := D[A[[a]], clist[[b]]] + Sum[Γudd[a, b, c]*A[[c]], {c, 1, Length[gdd]}];
Along with coordiantes and inverse metric
clist = {t, r, θ, ϕ};
gUU = Simplify[Inverse[gdd]];
Now if we consider the vector (with indices up)
EmU = {0,Er[r, θ, ϕ],Eθ[r, θ, ϕ],Eϕ[r, θ, ϕ]}
We can calculate the divergence, but this divergence isn't the same as Mathematica's divergence
Sum[covDu[Em, a, a], {a, Length[gdd]}] == Div[{Er[r, θ, ϕ],Eθ[r, θ, ϕ],Eϕ[r, θ, ϕ]}, "Spherical"]
We get non-zero output. How come? Shouldn't they be the same? Note that this happened when I defined my own Christoffel Symbols and covariant derivative.
Sum[covDu[Em, a, a], {a, Length[gdd]}]that you gave,Emis undefined. so either this is a mistake, or we are missing some code in the OP. – bmf Mar 23 '22 at 16:11Div[{Er[r, θ, φ], Eθ[r, θ, φ], Eφ[r, θ, φ]}, "Polar"]as you have written, it returns unevaluated. You need to specify the coordinate system according to the documentation ofDiv. In simple terms you should have something likeDiv[{Er[r, θ, φ], Eθ[r, θ, φ], Eφ[r, θ, φ]}, {r, θ, φ} ,"Polar"]. This gives the output – bmf Mar 23 '22 at 16:14guuis ALSO unevaluated, so even with the proper definition ofEmMathematicawould make her complaints. – bmf Mar 23 '22 at 16:16"Cylindrical"rather than"Polar". – bmf Mar 23 '22 at 16:32