# Why does sage fail to detect the symmetry here?

M = Manifold(4, 'M')
CM.<u,r,θ,φ> = M.chart(r'u r:(0,+oo) θ:(0,pi) φ:(0,2*pi)')
e = CM.coframe()
du = e[0]
dr = e[1]
dθ = e[2]
dφ = e[3]
V = function('V')
β = function('β')
γ = function('γ')
δ = function('δ')

(dθ * dφ + dφ * dθ).symmetries()
(dθ * dφ + dφ * dθ).symmetrize() == (dθ * dφ + dφ * dθ)

I want to define a (degenerate) metric:

g = M.metric('g')
g.set(dθ * dφ + dφ * dθ)

this fails because Sage does not believe the tensor field to be symmetric.

edit retag close merge delete

Sort by » oldest newest most voted

When one writes dθ * dφ + dφ * dθ, Sage first computes a = dθ * dφ and b = dφ * dθ; it then performs a + b and, at this stage, there is no way to detect (without any extra computation) that the output must be symmetric. The only case where the symmetry is set automatically is for expressions like dθ * dθ. So you should initialize the metric as

g = M.metric('g')
g.set((dθ * dφ + dφ * dθ).symmetrize())

An equivalent way, which avoids to introduce explicitly the 1-forms and , is

g = M.metric('g')
g[2,3] = 1
more

Thanks, this works of course. Just find it odd that g.set(...) does not explicitly check that the argument is symmetric. But I can understand that this may be a performance consideration.

( 2023-06-24 16:07:25 +0200 )edit