I am a Python user who has made minor use of Maxima on occasion. I am
trying to make the switch to Sage. I have a piece of Maxima
functionality that I am struggling to make work in Sage. I need to
declare that two variables x1 and x2 depend on t. I don't yet know
their expressions. For now, I just need to be able to take their
derivatives with respect to t and get \dot{x1} and \dot{x2}. Maxima
allows this through the depends function. I think I have this more or
less working in Sage:
Maxima code:
depends(x1,t);
diff(x1,t);
result: $$\frac{d}{d\,t}\,x1$$ (x1 dot, basically)
My Sage attempt:
x1 = var('x1')
x2 = var('x2')
t = var('t')
diff(x1,t)#returns 0
x1.maxima_methods().depends(t)
diff(x1,t)#still returns 0
x1b = x1.maxima_methods().depends(t)[0]
x1b.diff(t)
D[0](x1)(t)#<-- I think this basically means x1 dot.
This seems to basically work, but is this the right approach? Is
there an easier way?
The main thing that is counter-intuitive to me is this line:
x1b = x1.maxima_methods().depends(t)[0]
I don't know if I can always grab the zeroth element of the return
list and I would prefer that this alter x1 rather than require a new
variable be created (but this may be really difficult - I know nothing
about the Sage<-->Maxima interface). Obviously,
x1 = x1.maxima_methods().depends(t)[0]
sort of avoids creating a new variable, but if I forget to do the
assignment, x1 is unaltered and won't depend on t.
Thanks,
Ryan
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org