First a question on noncommutative multiplication. The following code -
from sympy import *
(a1,a2,b1,b2) = symbols('a1 a2 b1 b2')
(e1,e2) = symbols('e1 e2',commutative=False)
x = expand(a1*(e1+e2)*a2*b1*(e1+e2)*b2)
print x
gives -
a1*a2*b1*b2*e1*e2 + a1*a2*b1*b2*e1**2 + a1*a2*b1*b2*e2*e1 +
a1*a2*b1*b2*e2**2
Are the products of the noncommutative symbols always grouped together?
This is important so that if one defines a multiplication table for the
noncommutative symbols a complex product could be evaluated with a simple
x = x.subs(mul_table)
where the keys of the mul_table dictionary are e1**2, e1*e2, e2*e1,
e2**2. Would e1*e1 work as a key as well as e1**2?
The second question is if one uses a function rather than a table to
calculate the product of noncommuting symbols what class should be
subclassed in order to overload the __mul__() operator? Should it be
the Basic class?
--
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.