On Mon, Nov 10, 2008 at 8:16 PM, Brian Granger <[EMAIL PROTECTED]> wrote: > > Hi, > > By default, Python's * operator work in L->R order, so: > > a*b*c*d = ((a*b)*c)*d > > But, I am implementing some operators from quantum mechanics that I > want to apply like this: > > a*b*c*d = a*(b*(c*d)) > > Is this possible with sympy? In my case, a, b, c, and d are custom > subclasses of Basic that don't commute. I would like to do this using > a custom __mul__ method on my class, but I am not sure that will work. > > Any thoughts?
Could you please elaborate? What you want is a noncommutative *nonassociative* algebra. As far as I know, everything in quantum mechanics is at least associative. Maybe you want some way to evaluate the operators starting from the right hand side? Then I suggest to simply construct the whole expression, store it into a variable "e" and access "e.args". Or am I missing something? Ondrej --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
