On Tue, May 20, 2008 at 9:18 PM, astozzia <
acm...@gmail.com> wrote:
>
> Hey y'all
> I am solving a couple of ODEs using the lagragian (mechanics). To make
> the story short, and after typing:
>
> In[1]: from sympy import *
> import scipy as s
>
> assume I have the following parameters:
>
> In[2]: m,theta,phi = symbols('m','theta','phi')
> In[3]: f = m*s.array([1,2,0]) + theta**2*s.array([1,0,0]) -
> 3*phi*theta*s.array([1,0,1])
>
> Now I want to differentiate the expression "f" w.r.t "theta".
> In[4]: diff(f,theta)
>
> and i get the following error (see below). Note that I also tried by
> defining f = Function("f") and f=... same...
> Any help/hint would be highly appeciated.
It works for me:
In [1]: import scipy as s
In [2]: m,theta,phi = symbols('m','theta','phi')
In [3]: f = m*s.array([1,2,0]) + theta**2*s.array([1,0,0]) -
3*phi*theta*s.array([1,0,1])
In [4]: f
Out[4]: [m - 3*phi*theta + theta**2 2*m -3*phi*theta]
In [5]: diff(f, theta)
Out[5]: [-3*φ + 2*θ, 0, -3*φ]
Use the latest sympy. BTW, you are using a wrong mailinglist -- this
mailinglist is for the sympycore project, we use this list for sympy:
http://groups.google.com/group/sympy
If you do some examples from Lagrangian mechanics, please share them
with us, so that we can add them to the sympy/examples directory.
Thanks,
Ondrej