Status: Valid
Owner: ----
Labels: Type-Defect Priority-High WrongResult

New issue 3342 by [email protected]: subs coefficient error
http://code.google.com/p/sympy/issues/detail?id=3342

This was originally https://github.com/sympy/sympy/issues/1451

When using cse the resulting replacements and reduced_exprs did not give the same result as the original expression. Digging into the differences, I found the error came from the propagation of the replacements in sympy.simplify.cse_main.cse. Looking further, the error appears to be in the way that Mul handles substitution:

Input:

import sympy
x = sympy.Symbol('x')
y = sympy.Symbol('y')
expr = 4*x**2
print expr
print expr.subs([(2*x, y)])
Output:

4*x**2
2*y**2
The output should obviously be y**2. As a result of this bug, coefficients are incorrectly calculated in cse. The reason for this seems to be the incorrect handling of coefficients in sympy.core.mul._eval_subs.

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" 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-issues?hl=en.

Reply via email to