I have a variety of modifications to routines so they handle non-
commutatives. If you've got any work that depends on nc symbols and
care to give it a try, it's in the current 1766 branch at github.
.gcd_factors -> returns list of factors of expr
>>> (1/(2*x+2)+1/(x+1)).gcd_factors()
[3/2, 1/(1 + x)]
Non-commutative terms are also respected:
>>> (a*b + (a*b)**(2+x)).gcd_factors()
[a*b, 1 + a*b*(a*b)**x]
.gcd_factors_quick -> does the same as the above but only removes
identical terms so
(x+x**2).gcd_exact_factors() -> [x + x**2]
.args_cnc() -> split expr.as_Mul into multiplied terms according to
commutativity
>>> (-2*x*A*B*y).args_cnc()
[set([-1, 2, x, y]), [A, B]]
.coeff()
>>> n, m, o = symbols('nmo', commutative=False)
>>> n.coeff(n)
1
>>> (3*n).coeff(n)
3
>>> (n*m + m*n*m).coeff(n) # = (1 + m)*n*m
1 + m
>>> (n*m + m*n*m).coeff(n, right=True) # = (1 + m)*n*m
m
If there is more than one possible coefficient None is
returned:
>>> (n*m + m*n).coeff(n)
>>>
.as_coefficient() depends on coeff and so is nc-aware; also a new
behavior is added:
>>> (2*E + x*E).as_coefficient(E)
2 + x
.as_independent()
>>> (n1*n2*n3).as_independent(n1)
(1, n1*n2*n3)
>>> (n1*n2*n3).as_independent(n2)
(n1, n2*n3)
factor_nc() -> only returns a factoring if it is valid
>>> factor_nc(A*C + B*A + B*C + A**2)
(A + B)*(A + C)
>>> factor_nc(A*C + B*A + C*B + A**2)
A*C + B*A + C*B + A**2
separate() -> automatically goes into exp() but can't be restrained
with do_exp=False
>>> separate(exp(x+y), do_exp=True) #default
exp(x)*exp(y)
Nothing for review...just announcing in case anyone is in need of non-
commutative handling and can give it a test.
--
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.