Poly should ignore non-generator powers during factoring
Author: rikardnCreated Mar 31, 2023Updated Sep 15, 2026
I have a simple expression where I would like to factor out common factors of terms. Neither factor nor together do what I expect. Instead I would expect to get x*(1 - exp(-10)). Perhaps I misunderstand how these functions work. For positive values of the exponent together gives what I would expect.
import sympy
x = sympy.Symbol("x")
expr = x - x*sympy.exp(-10)
sympy.factor(expr)
Out[4]:
x*(-1 + E)*(1 + E)*(1 + E + exp(2) + exp(3) + exp(4))*(-exp(3) - E + 1 + exp(2) + exp(4))*exp(-10)
sympy.together(expr)
Out[5]:
x*(-1 + exp(10))*exp(-10)Source: sympy/sympy