Ask Your Question

Revision history [back]

You can do it like this:

E = PolynomialRing(QQ, 2, names='x')
x = E.gens()
M = E.derivation_module()
ddx = M.gens()
f=x[1]*ddx[0]
g=x[0]*ddx[1]
f.bracket(g)

Output:

-x0*d/dx0 + x1*d/dx1

You can pass names a list if you want to be more picky (and then you can omit the number of variables, 2 above, because it will be the length of the list).