Hi Tom! On Sun, Oct 5, 2008 at 1:54 PM, glt <[EMAIL PROTECTED]> wrote: > > Hello all, > > I am looking for a quick and short way to implement computations with > the Virasoro algebra in sympy. What i want to achieve is pretty basic: > i want to define symbolic noncommutative objects L(n), where n is an > integer, and have sympy handle products of L(n)'s as follows: > > * On two-terms products L(n)L(m): > * if n<=m, do nothing > * otherwise, replace L(n)L(m) by L(m)L(n) + [L(n),L(m)] where [ ] > is the commutator of the Virasoro operators (expressed as another L > operator plus possibly another term) > > * On products L(n)L(m)...L(p): recursively apply the two-terms rule, > so that n, m, .. p are in increasing order
Thanks for doing it, that's very useful. What other operations would you like to do with it? Looking here, it's just a Lie algebra, right? http://en.wikipedia.org/wiki/Virasoro_algebra > > So i started by subclassing Basic and ArithMeths in an L class, with > is_commutative=False. Now i'm stuck the the definition of the product > rule. I guess this should happen somewhere in Mul.flatten, but what is > the proper way of doing it? Subclassing Mul to define my own > multiplication? How can then i couple it to the L objects? > > Another thing i have thought about would be representing the product > of L objects as a Basic object itself, with its own rules, but i'm not > too sure about it. > > How would you guys do it? > Thanks in advance I would suggest you either subclass Mul, or just "fork it", e.g. create VirasoroMul by copying the current Mul and then customizing it to do what you want. If you have problems, just create a function that takes some set of L(n)L(m)...L(p) and returns the simplifications using the algorithm you described. After you have some working prototype, we'll help you integrate it well in sympy, with the patch and getting it in. In the past, we played with having a NCMul like ginac, then we switched to just having one Mul and the commutative=False assumption, currently attached to the symbols directly, in the future this will be handled by the assumptions system, just like in Mathematica. If you have a better idea how this could/should be handled, please share it. Looking forward, Ondrej --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---