I think this is indeed a bug, so thanks for reporting it. My impression from a quick look at the code is that sagemath expands the expression into a polynomial (a linear combination of monomials) before trying to factor it. If the expansion has only a single term (a constant times a monomial), then nothing needs to be done, since this expansion is already factored. Sagemath erroneously thinks nothing needed to be done from the beginning, and returns the original expression, instead of the expanded expression.
Here is a simpler example: sage: ((x + 1)^2 - 2*x - 1).factor() # bad (should be x^2) (x + 1)^2 - 2*x - 1 sage: ((x + 2)^2 - 2*x - 3).factor() # good (x + 1)^2 I opened trac ticket #33640 <https://trac.sagemath.org/ticket/33640> for further discussion. On Sunday, April 3, 2022 at 3:02:39 PM UTC-6 a.simpl...@gmail.com wrote: > I meant to say that f.expand() gives the correct answer. > To see why, factor out the common factors (x-y)(y-z)(z-x). > Once you did so, the rest is ( (x-y) + (y-z) + (z-x) ) > and so I expect f.factor() returns 0. > > The statement "the given expression cannot be factorized further" > seems weird to me. > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/af719f1b-d0c7-41bc-8ccc-5481b9a9d4dcn%40googlegroups.com.