We factor a polynomial of degree 200 over the integers.
sage: R.<x> = PolynomialRing(ZZ)
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: print g
2 100 101 200
100 + 315 x - 85 x + 25 x + 12 x + x
sage: g
100 + 315*x - 85*x^2 + 25*x^100 + 12*x^101 + x^200
sage: print g.Factor()
100 100
(20 - 5 x + x ) (5 + 17 x + x )
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: print f.Factor()
3 2 3
x (x - y) (-2 x + x + y )
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.