Hi Yau!

On Sun, Mar 29, 2009 at 11:16 PM, Yau Kwan Kiu <[email protected]> wrote:
>
> Hello.
> I want to write a function for reducing an
> expression for an element x \in sl2 into a sum in the
> Poincare Birkhoff Witt basis , that is,
>
> e,f,h=symbols('efh',commutative=False)
>
> e*f |---> f*e+h
>
> I tried to use subs naively and it wouldn't work:
>
>>>>e,f,h=symbols('efh',commutative=False)
>
>>>> (e*f).subs(e*f,f*e+h)
> h + f*e
>>>> (e*f*e*f).subs(e*f,f*e+h)
> e*f*e*f

That's a bug. It should work. I made it:

http://code.google.com/p/sympy/issues/detail?id=1358

We'll try to fix it soon, just Mul._eval_subs() needs to be checked
why it doesn't work for this case. It's this part of the code in
sympy/core/mul.py:


        elif l2 < l1:
            # old is some something more complex, like:
            # (a*b*c*d).subs(b*c,x) -> a*x*d
            # then we need to search where in self.args the "old" is, and then
            # correctly substitute both terms and coefficients.
            self_set = set(terms_self)
            old_set = set(terms_old)
            if old_set < self_set:
                ret_set = self_set - old_set
                return Mul(new, coeff_self/coeff_old,
*[s._eval_subs(old, new) for s in ret_set])


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

Reply via email to