New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: sympy.factor doesn't work for Poly !!! #21180
Comments
The In [1]: p = Poly(x ** 4 + 6 * x ** 3 + 4 * x ** 2 - 30 * x - 45, x)
In [2]: factor(p.as_expr())
Out[2]:
2 ⎛ 2 ⎞
(x + 3) ⋅⎝x - 5⎠
In [3]: p.factor_list()
Out[3]: (1, [(Poly(x + 3, x, domain='ZZ'), 2), (Poly(x**2 - 5, x, domain='ZZ'), 1)]) Previously It was not intentional that that would change In [2]: Poly(x**2 - 1) == (x - 1)*(x + 1)
Out[2]: True That should return False. It gives True because the expression on the rhs is converted to Poly (which expands everything). I think that For the OP issue I'm not sure that it should be expected for |
Thanks, shouldn't it be stated in the While instead, it has From that, I get a clue that it can be used with Poly. |
Yes, I guess the doc should be updated. |
Thanks for your quick response. Am I supposed to close this issue? |
The issue can stay open until the doc is updated |
Maybe it should be possible to pass Having |
Minimum reproduction example:
from sympy import symbols, Poly, factor
x = symbols('x')
print(factor(Poly(x ** 4 + 6 * x ** 3 + 4 * x ** 2 - 30 * x - 45, x)))
This outputs
Poly(x**4 + 6*x**3 + 4*x**2 - 30*x - 45, x, domain='ZZ')
, but I expect factorization into(x+3)(x+3)(x^2−5)
sympy version: 1.7.1
Python version: 3.7.8 (tags/v3.7.8:4b47a5b6ba, Jun 28 2020, 08:53:46) [MSC v.1916 64 bit (AMD64)]
The text was updated successfully, but these errors were encountered: