Hello,
I have to do some calculations with polynomials (in fact only
addition) and found the following problem:
import sympy as sy
>>> sy.__version__
'0.6.6'
>>> x, y, z = sy.symbols('xyz')
>>> Q = sy.Poly(((sy.S(1), sy.S(1), sy.S(1), sy.S(5), sy.S(6), sy.S(3),
>>> sy.S(1)), ((2, 3, 1), (1, 4, 1), (2, 2, 2), (3, 1, 1), (2, 2, 1), (1, 3,
>>> 1), (4, 0, 0))), x, y, z)
>>> Q
Poly(x**2*y**3*z + x*y**4*z + x**2*y**2*z**2 + 5*x**3*y*z +
6*x**2*y**2*z + 3*x*y**3*z + x**4, x, y, z)
>>> S = sy.Poly(((sy.S(1),), ((2, 2, 2),)), x, y, z)
>>> S
Poly(x**2*y**2*z**2, x, y, z)
>>> P = Q + S
>>> P
Poly(x**2*y**2*z**2 + x**2*y**3*z + x*y**4*z + x**2*y**2*z**2 +
5*x**3*y*z + 6*x**2*y**2*z + 3*x*y**3*z + x**4, x, y, z)
>>> P.as_basic()
x**2*y**2*z**2 + 6*z*x**2*y**2 + z*x**2*y**3 + 3*x*z*y**3 + 5*y*z*x**3
+ x**4 + x*z*y**4
>>> P.subs({x:1, y:1, z:1})
18
As you can see the problem is with the monomial x**2*y**2*z**2, which
appears two times in P.monoms. In the following further calculation
and also the output for P are not correct.
--
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.