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. >From what I remember, Gilbert used this to implement some degree of Euler-Lagrange in the mechanics module. You'll have to ask him or look at the code for the specifics, though. Aaron Meurer On Fri, Mar 23, 2012 at 4:39 PM, Tim Lahey <tim.la...@gmail.com> wrote: > On Fri, Mar 23, 2012 at 5:33 PM, Elliot Marshall <marshall2...@gmail.com> > wrote: >> For example, I would like to write the functions necessary so that, using >> sympy.physics.mechanics, one could use Euler, Lagrange, and possibly other >> methods to find the dynamical equations of motion for a system. > > I assume you mean Euler-Lagrange? I'd like to see it progress to > handling variables that vary spatially and not just in time. That > said, I'd like Euler-Lagrange support as well. Supporting vector > variables (in a linear algebra sense) would be nice as well. I believe > there's been work on symbolic matrix expressions in Sympy. This would > allow for the derivation of finite element equations. > > Implementing just Euler-Lagrange shouldn't take too long if one is > familiar with the programming of the module. I expect probably a few > weeks to a month at most. My implementation of E-L in Maple is less > than a page of code, most of that is converting from a function to a > variable that can be differentiated and back. There will be a bit > setting things up for the E-L equation, but some can probably be > reused from the current module. > > 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.