On Sun, Mar 25, 2012 at 3:58 PM, Tim Lahey <tim.la...@gmail.com> wrote:
> Aaron,
>
> On Sun, Mar 25, 2012 at 5:27 PM, Aaron Meurer <asmeu...@gmail.com> wrote:
>> There is already support in the git master for taking derivatives with
>> respect to functions and derivatives:
>>
>> In [153]: diff(x*f(x)**2 + f(x)*diff(f(x), x), f(x))
>> Out[153]:
>>           d
>> 2⋅x⋅f(x) + ──(f(x))
>>           dx
>>
>> In [154]: diff(x*f(x)**2 + f(x)*diff(f(x), x), diff(f(x), x))
>> Out[154]: f(x)
>>
>> So your boilerplate code would be unnecessary in SymPy.
>
> What about if f(x) isn't just f(x) but g(x,y,z,t)? And taking
> derivatives with respect to that (and its derivatives). That's the
> situation I'm in. I knew the f(x) case was implemented, but I didn't
> think that the g(x,y,z,t) case was. For straightforward dynamics
> problems, the f(x) case is enough, but once you add in flexible
> bodies, you need the g(x,y,z,t) case as well along with all possible
> derivatives.

In [162]: diff(x*g(x, y, z, t)**2 + g(x, y, z, t)*diff(g(x, y, z, t),
x), g(x, y, z, t))
Out[162]:
                    d
2⋅x⋅g(x, y, z, t) + ──(g(x, y, z, t))
                    dx

In [163]: diff(x*g(x, y, z, t)**2 + g(x, y, z, t)*diff(g(x, y, z, t),
x), diff(g(x, y, z, t), x))
Out[163]: g(x, y, z, t)

Take a look at the docstring of diff (in master) for how this is implemented.

Aaron Meurer

>
> I'd love to see a full Euler-Lagrange equation implementation. Most
> (including mine), only do the standard Euler-Lagrange equation, but
> for different functionals, you can can get much more complicated
> Euler-Lagrange equations than just the standard one. But, to get the
> full one, you'd need to implement Calculus of Variations and support
> taking a variation with respect to a functional. I have a basic
> implementation in Maple, but it's not particularly robust.
>
> Cheers,
>
> Tim.
>
> --
> Tim Lahey
> PhD Candidate, Systems Design Engineering
> University of Waterloo
> http://about.me/tjlahey
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To post to this group, send email to sympy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sympy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sympy?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to