10.2 Factorization

You can factor a polynomial using Sage.

Using Sage to factor a univariate polynomial is a matter of applying the method factor to the PolynomialRingElement object f. In fact, this method actually calls Pari, so the computation is fairly fast.

sage: x = PolynomialRing(RationalField(), 'x').gen()
sage: f = (x^3 - 1)^2-(x^2-1)^2
sage: f.factor()
(x - 1)^2 * x^2 * (x^2 + 2*x + 2)

Using the Singular interface, Sage also factors multivariate polynomials.

sage: x, y = PolynomialRing(RationalField(), 2, ['x','y']).gens()
sage: f =  9*y^6 - 9*x^2*y^5 - 18*x^3*y^4 - 9*x^5*y^4 + 9*x^6*y^2 + 9*x^7*y^3\ 
...   + 18*x^8*y^2 - 9*x^11
sage: f.factor()
(-9) * (x^5 - y^2) * (x^6 - 2*x^3*y^2 - x^2*y^3 + y^4)

See About this document... for information on suggesting changes.