# how to re-order factors

I have

 x,y, dx, dy= var("x, y, dx, dy");
def iD(f): return diff(f, x)*dx + diff(f,y)*dy;


iD(x^3*y^5) returns

5*dy*x^3*y^4 + 3*dx*x^2*y^5


is there a way to have it return the differentials always at the end as in

5*x^3*y^4*dy + 3*x^2*y^5*dx


thank you

edit retag close merge delete

Sort by ยป oldest newest most voted

Hello;

You would better use differential forms directly

 sage: x, y, z = var('x, y, z')
sage: U = CoordinatePatch((x, y, z))
sage: F = DifferentialForms(U)
sage: form0 = DifferentialForm(F, 0, x^3*y^5)
sage: form0
x^3*y^5
sage: form0.diff()
3*x^2*y^5*dx + 5*x^3*y^4*dy


The exterior product is also implemented

sage: dx = DifferentialForm(F,0,x).diff()
sage: dy = DifferentialForm(F,0,y).diff()
sage: dx*dy
dx/\dy
sage: dy*dx
-1*dx/\dy


You can access the documentation by typing

sage: DifferentialForm?


and then press enter. Alternatively, you can have a look to differential forms in the reference manual.

more

very nice thank you! its perfect!

( 2015-02-16 20:32:06 +0100 )edit