ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 28 Jun 2016 17:16:13 +0200Derivation of a sagemanifold vector (possible bug)https://ask.sagemath.org/question/33951/derivation-of-a-sagemanifold-vector-possible-bug/ I'm using sage v7.1 with sagemanifold v0.9 to calculate Lie derivatives.
<h2>The problem</h2>
I define my manifold, with a chart and the vectors which define the symmetry,
M = Manifold(4, 'M', latex_name=r"\mathcal{M}")
X.<t,r,th,ph> = M.chart(r't r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi')
Lx = M.vector_field('Lx')
Lx[:] = [ 0, 0, -cos(ph), cot(th)*sin(ph) ]
Ly = M.vector_field('Ly')
Ly[:] = [ 0, 0, sin(ph), cot(th)*cos(ph) ]
Lz = M.vector_field('Lz')
Lz[:] = [ 0, 0, 0, 1]
Lt = M.vector_field('Lt')
Lt[:] = [ 1, 0, 0, 0]
However, if I call the derivative of a component of the vector like
diff( Lx[3], th )
I get a `TypeError`, because
type( Lx[3] )
<class 'sage.manifolds.coord_func_symb.CoordFunctionSymb'>
and it seems that the function `diff` only acts on SR expressions.
<h2>My bypass</h2>
Although I was able to bypass the situation, it would be nice if a solution was provided *out of the box*, but in case anyone else needs a solution:
I defined my vectors in a Sage way
xi0 = [ 1, 0, 0, 0]
xi1 = [ 0, 0, -cos(ph), cot(th)*sin(ph) ]
xi2 = [ 0, 0, sin(ph), cot(th)*cos(ph) ]
xi3 = [ 0, 0, 0, 1]
and then assigned them to the SageManifolds vector_field
Lx = M.vector_field('Lx')
Lx[:] = xi1
Ly = M.vector_field('Ly')
Ly[:] = xi2
Lz = M.vector_field('Lz')
Lz[:] = xi3
Lt = M.vector_field('Lt')
Lt[:] = xi0
So, when I need the derivative of a component of the vector, I calculate
diff(xi1[3], th)
Cheers.DoxTue, 28 Jun 2016 17:16:13 +0200https://ask.sagemath.org/question/33951/