coef in presence of non-commuting variables: weird built-in behavior

17 views
Skip to first unread message

r.du...@gmail.com

unread,
Sep 4, 2017, 12:19:13 PM9/4/17
to sy...@googlegroups.com
Hello

Concerning sympy.core.expr.Expr.coeff in presence of non-commuting variables

The docs [1] state that (in presence of non-commuting variables) when there is more that one coefficient, coeff returns 0.

Eg (from SympyLive)
n, m, o = symbols('n m o', commutative=False)
>>> (n*m + o*n).coeff(n)
0

This built-in behavior sounds weird to me: if zero is always returned, how to know that we are in the case of more than coefficient?

I would have expected some information useful to reconstruct the polynomial like a tuple (Left_coefficient, Right_coefficent), i.e. (o,m) in the example.

ric

[1]
http://docs.sympy.org/dev/modules/core.html?highlight=coeff#sympy.core.expr.Expr.coeff
Reply all
Reply to author
Forward
0 new messages