We factor a polynomial of degree 200 over the integers.
sage: x = PolynomialRing(IntegerRing()).gen() sage: f = (x**100+17*x+5)*(x**100-5*x+20) sage: f x^200 + 12*x^101 + 25*x^100 - 85*x^2 + 315*x + 100 sage: g = mathematica(str(f)) sage: g 100 + 315*x - 85*x^2 + 25*x^100 + 12*x^101 + x^200 sage: g.Factor() (20 - 5*x + x^100)*(5 + 17*x + x^100)
We can also factor a multivariate polynomial:
sage: f = mathematica('x^6 + (-y - 2)*x^5 + (y^3 + 2*y)*x^4 - y^4*x^3') sage: f.Factor() x^3*(x - y)*(-2*x + x^2 + y^3)
We factor an integer:
sage: n = mathematica(2434500) sage: n.FactorInteger() {{2, 2}, {3, 2}, {5, 3}, {541, 1}} sage: n = mathematica(2434500) sage: F = n.FactorInteger(); F {{2, 2}, {3, 2}, {5, 3}, {541, 1}} sage: F[1] {2, 2} sage: F[4] {541, 1}
We can also load the ECM package and factoring using it:
sage: _ = mathematica.eval("<<NumberTheory`FactorIntegerECM`"); sage: mathematica.FactorIntegerECM('932901*939321') 8396109
See About this document... for information on suggesting changes.