Ask Your Question

Revision history [back]

It's a terrible hack, but perhaps this will help you as a workaround:

sage: x, y, z = var('x, y, z')
sage: U = CoordinatePatch((x, y, z))
sage: F = DifferentialForms(U)
sage: f = F(x^2 + y + sin(z)); f
(x^2 + y + sin(z))
sage: g = f.diff(); g 
cos(z)*dz + 2*x*dx + dy

That's what you have already. Now, we convert g to a string and parse it as a new symbolic expression:

sage: t = SR(str(g))
sage: t.operands()
[2*dx*x, dz*cos(z), dy]
sage: t.variables()
(dx, dy, dz, x, z)