On Sat, Dec 13, 2008 at 08:59:08AM -0800, Aaron wrote:
>
> I'm a newbie to sympy. The problem is, I do not know whether it is
> possible to get the derivative with respect to a function, not a
> symbol. The code is like this:
> 
> t = Symbol("t")
> f = Function("f")
> 
> theta = f(t)
> theta_dot = diff(theta,t,1)
> x = theta*theta_dot
> y = diff(x,theta_dot,1)
> 
> Then the output is
> D(f(t)*D(f(t), t), D(f(t), t))
> 
> However, my expected output should be "theta" or "f(t)" instead.

Now, I have this idea:

% isympy
In [1]: var('t xDot')
Out[1]: (t, xDot)

In [2]: g = lambdify((x, xDot), x*xDot)

In [3]: g(x, xDot)
Out[3]: x*xDot

In [4]: g(f(t), diff(f(t), t))
Out[4]: 
     d
f(t)*──(f(t))
     dt

In [5]: gDot = lambdify((x, xDot), diff(g(x, xDot), xDot))

In [6]: gDot(f(t), diff(f(t), t))
Out[6]: f(t)

By,

  Friedrich

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
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/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to