The above four lines would be translated as:
In [1]: from sympy import *
In [2]: var("t")
Out[2]: t
In [3]: x = Function("x")(t)
In [4]: z = x**2/2
In [5]: xdot = diff(x, t)
In [6]: zdot = diff(z, t)
In [7]: xdot
Out[7]: D(x(t), t)
In [8]: zdot
Out[8]: x(t)*D(x(t), t)
> D[z*zdot,xdot]
In [11]: diff((z*zdot).subs(xdot, s), s)
Out[11]: 1/2*x(t)**3
Currently our diff can only differentiate with respect to a symbol, so
you need to use the substitution above. We should enhance that.
>
> out: 1/2 q[t]^3
This agrees.
Let us know if you have further questions.
Ondrej
You need to put here this line to introduce the "s" variable:
In [9]: var("s")
Out[9]: s
>
> In [11]: diff((z*zdot).subs(xdot, s), s)
> Out[11]: 1/2*x(t)**3
Ondrej
On Mon, Oct 20, 2008 at 6:05 PM, Scott <scott...@yahoo.com> wrote:
>
> Ondrej
>
>
> Thank you for the tip to use the subs function, I was expecting it to
> exist but I had trouble finding it.
>
> I will be working with 2-d arrays. Which 2d formats play well with
> both the subs and the diff funtions?
I think our Matrix should work with them in some way.
>
> It seems that Matrix lacks the diff attribute , list and numpy.array
> lack the subs attribute.
> Is there a better way to handle this than a lot of
> Matrix(diff(Matrix(rdotarray).subs(xdot,s)[:],s)).subs(s,xdot) ?
Yes, you can use Matrix.applyfunc(). See it's docstring for usage.
>
> Where in the Docs am I most likely to find the answers to my question?
http://docs.sympy.org/modules/matrices.html
>
> I am using sympy 6.2 now.
If you have further questions, please ask. Sorry for my late reply.
Ondrej