Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

It's true that the global function diff applies only to symbolic expressions, not to coordinate functions as defined in SageManifolds. But you can use the method diff on them:

sage: Lx[3].diff(th)

Note that the result is still a coordinate function:

sage: type(Lx[3].diff(th))
<class 'sage.manifolds.coord_func_symb.CoordFunctionSymb'>

To get a symbolic expression, use the method expr():

sage: Lx[3].diff(th).expr()
sage: type(Lx[3].diff(th).expr())
<type 'sage.symbolic.expression.Expression'>

Another solution is to invoke expr() prior to the global function diff:

sage: diff(Lx[3].expr(), th)
-cos(th)^2*sin(ph)/sin(th)^2 - sin(ph)

Note that in this case, the result is not automatically simplified (this is one of the differences between symbolic expressions and coordinate functions).