sage: var("x, y, z") (x, y, z) sage: Ex = (x-y)^2*(y-z)*(z-x) + (y-z)^2*(z-x)*(x-y) + (z-x)^2*(x-y)*(y-z) sage: Ex -(x - y)^2*(x - z)*(y - z) + (x - y)*(x - z)^2*(y - z) - (x - y)*(x - z)*(y - z)^2 sage: Ex.expand() 0 sage: Ex.factor() -(x - y)^2*(x - z)*(y - z) + (x - y)*(x - z)^2*(y - z) - (x - y)*(x - z)*(y - z)^2 sage: Ex.simplify() -(x - y)^2*(x - z)*(y - z) + (x - y)*(x - z)^2*(y - z) - (x - y)*(x - z)*(y - z)^2 sage: Ex.simplify_full() 0 sage: Ex._sympy_().expand()._sage_() 0 sage: Ex._sympy_().factor()._sage_() 0 sage: Ex._giac_().factor()._sage_() 0 sage: Ex._fricas_().factor()._sage_() 0 sage: mathematica.Factor(Ex).sage() 0
So what ? Sage’s factor doesn’t factorize this expression ? Big fail ! Film at 11… As illustrated, Sage has lots of ways to factorize this expression. BTW, expand a symbolic expression is often a clever way to (start to) finding a “nice” expression of this quantity. To understand why factorizing this expression is not trivial, meditate : sage: Ex.operator() <function add_vararg at 0x7ff7aaf70700> sage: [u.expand() for u in Ex.operands()] [-x^3*y + 2*x^2*y^2 - x*y^3 + x^3*z - x^2*y*z - x*y^2*z + y^3*z - x^2*z^2 + 2*x*y*z^2 - y^2*z^2, x^3*y - x^2*y^2 - x^3*z - x^2*y*z + 2*x*y^2*z + 2*x^2*z^2 - x*y*z^2 - y^2*z^2 - x*z^3 + y*z^3, -x^2*y^2 + x*y^3 + 2*x^2*y*z - x*y^2*z - y^3*z - x^2*z^2 - x*y*z^2 + 2*y^2*z^2 + x*z^3 - y*z^3] sage: [u.expand().cancel() for u in Ex._sympy_().args] [x**3*y - x**3*z - x**2*y**2 - x**2*y*z + 2*x**2*z**2 + 2*x*y**2*z - x*y*z**2 - x*z**3 - y**2*z**2 + y*z**3, -x**3*y + x**3*z + 2*x**2*y**2 - x**2*y*z - x**2*z**2 - x*y**3 - x*y**2*z + 2*x*y*z**2 + y**3*z - y**2*z**2, -x**2*y**2 + 2*x**2*y*z - x**2*z**2 + x*y**3 - x*y**2*z - x*y*z**2 + x*z**3 - y**3*z + 2*y**2*z**2 - y*z**3] sage: Ex._sympy_().cancel() 0 HTH, Le dimanche 3 avril 2022 à 11:29:17 UTC+2, adarsh.k...@gmail.com a écrit : > I checked this on my SageMath v9.6.beta5 on Ubuntu 20.04 LTS, and it > checks out > > [image: Screenshot from 2022-04-03 14-58-46.png] > > On Sunday, April 3, 2022 at 2:57:35 PM UTC+5:30 Adarsh Kishore wrote: > >> By the way, f.expand() is not wrong. The expression is identically equal >> to 0 for all values of x, y and z. >> >> https://www.mathpapa.com/algebra-calculator.html?q=(x-y)%5E2*(y-z)*(z-x)%2B(y-z)%5E2*(z-x)*(x-y)%2B(z-x)%5E2*(x-y)*(y-z) >> >> [image: Screenshot from 2022-04-03 14-55-22.png] >> >> As for `f.factor()`, the given expression cannot be factorized further. >> So the answer is correct. >> On Sunday, April 3, 2022 at 2:53:47 PM UTC+5:30 Adarsh Kishore wrote: >> >>> Which version of Sage are you using? And on which platform? >>> >>> On Sunday, April 3, 2022 at 10:44:59 AM UTC+5:30 a.simpl...@gmail.com >>> wrote: >>> >>>> The following code >>>> >>>> > var("z y z") >>>> > f = (x-y)^2*(y-z)*(z-x) + (y-z)^2*(z-x)*(x-y) + (z-x)^2*(x-y)*(y-z) >>>> > f.expand() >>>> >>>> outputs 0. >>>> But >>>> > f.factor() >>>> simply prints the original formula (x-y)^2... >>>> >>>> Maybe something is wrong? >>>> >>> -- 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/57bba73a-68db-45af-b73b-96ea30e1d79an%40googlegroups.com.