Can you just get what you want by overriding _eval_derivative()?

Aaron Meurer

On Fri, Jun 3, 2011 at 7:48 PM, Gilbert gede <gilbertg...@gmail.com> wrote:
> I guess I should have asked this as well; is it considered bad to
> write diff() and replace the current Sympy diff() within my code? Or
> is that OK?
>
> -Gilbert
>
>
>
> On Jun 3, 6:38 pm, Gilbert gede <gilbertg...@gmail.com> wrote:
>> Yeah, I had read some of them.  I had already thought of writing my
>> own Diff method or something and do substitution with it, but was
>> hoping to have the functionality I want work like standard SymPy
>> operations.  That's what I've been trying to do with my PyDy classes;
>> make them work more like you would expect other SymPy objects to.
>> I have read through Derivative() and diff(), and couldn't really find
>> a way to make them do what I want (like I said about my symbol
>> extension no longer having its methods called once it is inside a
>> SymPy add or mul).  I guess what I was hoping for was input on whether
>> I could make Derivative do what I want with my extended Symbol, as I
>> couldn't really see how.  But if writing my own Diff method is the
>> only option, there's not much I can do then.
>>
>> Thanks,
>> -Gilbert
>>
>> On Jun 3, 5:53 pm, "Aaron S. Meurer" <asmeu...@gmail.com> wrote:
>>
>>
>>
>>
>>
>>
>>
>> > This has actually been discussed quite a bit before (a lot of people want 
>> > to use Lagrangians).  You can search the mailing list.  From what I've 
>> > seen, you will either have to write your own custom diff routine or do 
>> > clever substitution of functions and derivatives with symbols.  I don't 
>> > think I've ever seen anyone suggest extending Symbol to hold a time 
>> > derivative, which is essentially just a more formal way of doing the 
>> > substation method.  It might work.
>>
>> > Aaron Meurer
>>
>> > On Jun 3, 2011, at 6:05 PM, Gilbert Gede wrote:
>>
>> > > Hi,
>> > > I was trying to implement some functionality for PyDy for this year's 
>> > > GSoC, and was looking for some advice.
>> > > In dynamics problems, you usually have time-varying quantities, like 
>> > > generalized coordinates, speeds, and accelerations.  Often, you want to 
>> > > take the partial derivative of an expression with respect to the time 
>> > > derivative of one of these quantities.  This come up when using 
>> > > Lagrange's Method (or Kane's Method).  It's described to some degree 
>> > > here:
>> > >http://en.wikipedia.org/wiki/Lagrangian_mechanics
>> > >https://gist.github.com/1005937
>> > > In Lagrange's Method, you end up taking the partial derivative of the 
>> > > energy with respect to the time derivative of a generalized coordinate.  
>> > > I'm trying to figure out a way to make this work in PyDy/SymPy. 
>> > > Derivative won't take in anything but a Symbol.
>> > > The only idea I have come up with is to extend Symbol and write my own 
>> > > .diff() method for it which returns a new symbol representing the time 
>> > > differentiation of the original extended Symbol.  Once my new object is 
>> > > inside a Mul or Add sympy object, then my .diff() method is no longer 
>> > > called.
>> > > Can anyone give some insight into how I could get this desired behavior, 
>> > > taking the derivative of an expression wrt a time-differentiated symbol, 
>> > > to work in a way consistent with existing SymPy behavior?  Thanks.
>>
>> > > -Gilbert
>>
>> > > --
>> > > 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 
>> > > athttp://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.
>
>

-- 
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