1 | initial version |
Try :
sage: var("x, y, r")
(x, y, r)
sage: theta(x,y)=atan2(y,x)
sage: dx=var("dx", latex_name=r"\mathrm{d}\,x")
sage: dy=var("dy", latex_name=r"\mathrm{d}\,y")
sage: foo = vector(map(lambda u,v:u*v, derivative(theta)(x,y).subs(x^2+y^2==r^2), vector([dx, dy]))).subs(x^2+y^2==r^2)
foo
should be :
$$ \left(-\frac{{\mathrm{d}\,x} y}{r^{2}},\,\frac{{\mathrm{d}\,y} x}{r^{2}}\right) $$
and foo.norm()
should be
$$ \sqrt{{\left| \frac{{\mathrm{d}\,y} x}{r^{2}} \right|}^{2} + {\left| \frac{{\mathrm{d}\,x} y}{r^{2}} \right|}^{2}} $$
unless you assume rhat all the variable are real, in which case you should get :
sage: with assuming(x,y,dx,dy,r,"real"): foo.norm()
sqrt(dy^2*x^2/r^4 + dx^2*y^2/r^4)
whose Sage's latex
ing is ... questionable :
$$ \sqrt{\frac{{\mathrm{d}\,y}^{2} x^{2}}{r^{4}} + \frac{{\mathrm{d}\,x}^{2} y^{2}}{r^{4}}} $$
HTH,
2 | No.2 Revision |
Try :
sage: var("x, y, r")
(x, y, r)
sage: theta(x,y)=atan2(y,x)
sage: dx=var("dx", latex_name=r"\mathrm{d}\,x")
sage: dy=var("dy", latex_name=r"\mathrm{d}\,y")
sage: foo = vector(map(lambda u,v:u*v, derivative(theta)(x,y).subs(x^2+y^2==r^2), vector([dx, dy]))).subs(x^2+y^2==r^2)
dy])))
foo
should be :
$$ \left(-\frac{{\mathrm{d}\,x} y}{r^{2}},\,\frac{{\mathrm{d}\,y} x}{r^{2}}\right) $$
and foo.norm()
should be
$$ \sqrt{{\left| \frac{{\mathrm{d}\,y} x}{r^{2}} \right|}^{2} + {\left| \frac{{\mathrm{d}\,x} y}{r^{2}} \right|}^{2}} $$
unless you assume rhat all the variable are real, in which case you should get :
sage: with assuming(x,y,dx,dy,r,"real"): foo.norm()
sqrt(dy^2*x^2/r^4 + dx^2*y^2/r^4)
whose Sage's latex
ing is ... questionable :
$$ \sqrt{\frac{{\mathrm{d}\,y}^{2} x^{2}}{r^{4}} + \frac{{\mathrm{d}\,x}^{2} y^{2}}{r^{4}}} $$
HTH,