Yeah, if you try diff(x,y), the method is not called. Ronan, I'm not sure how to do what you're describing? How would I call that?
-Gilbert On Jun 3, 7:32 pm, Ronan Lamy <[email protected]> wrote: > Le vendredi 03 juin 2011 à 19:16 -0700, Gilbert gede a écrit : > > > You're talking about Symbol._eval_derivative? I tried that within my > > extended Symbol class. It returns 0 or 1 testing self == symbol. I > > tried making some changes to it, but I don't think I can use it. I > > think it doesn't even get called unless you do something like: > > t = timevaryingsymbols('t') > > Derivative(2+3*t,t) > > I think only when t is both part of (expr, symbols, ...) within > > Derivative's __new__ definition does t's _eval_derivative() method get > > called. > > That seems to be a recent "optimisation" from commit 2361dd86. You > should revert this to the old behaviour: call > expr._eval_derivative(symbol) in all cases. > > > > > > > > > On Jun 3, 6:53 pm, Aaron Meurer <[email protected]> wrote: > > > Can you just get what you want by overriding _eval_derivative()? > > > > Aaron Meurer > > > > On Fri, Jun 3, 2011 at 7:48 PM, Gilbert gede <[email protected]> > > > 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 <[email protected]> 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" <[email protected]> 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 [email protected]. > > > >> > > To unsubscribe from this group, send email to > > > >> > > [email protected]. > > > >> > > 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 [email protected]. > > > > To unsubscribe from this group, send email to > > > > [email protected]. > > > > 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 [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.
