This example illustrates single variable polynomial GCD's:
sage: x = PolynomialRing(RationalField(), 'x').gen() sage: f = 3*x^3 + x sage: g = 9*x*(x+1) sage: f.gcd(g) x
This example illustrates multivariate polynomial GCD's:
sage: R = PolynomialRing(RationalField(),3, ['x','y','z'], 'lex') sage: x,y,z = PolynomialRing(RationalField(),3, ['x','y','z'], 'lex').gens() sage: f = 3*x^2*(x+y) sage: g = 9*x*(y^2 - x^2) sage: f.gcd(g) x^2 + x*y
Here's another way to do this:
sage: R2 = singular.ring(0, '(x,y,z)', 'lp') sage: a = singular.new('3x2*(x+y)') sage: b = singular.new('9x*(y2-x2)') sage: g = a.gcd(b) sage: g x^2+x*y
This example illustrates univariate polynomial GCD's via the GAP interface.
sage: R = gap.PolynomialRing(gap.GF(2)); R PolynomialRing( GF(2), ["x_1"] ) sage: i = R.IndeterminatesOfPolynomialRing(); i [ x_1 ] sage: x_1 = i[1] sage: f = (x_1^3 - x_1 + 1)*(x_1 + x_1^2); f x_1^5+x_1^4+x_1^3+x_1 sage: g = (x_1^3 - x_1 + 1)*(x_1 + 1); g x_1^4+x_1^3+x_1^2+Z(2)^0 sage: f.Gcd(g) x_1^4+x_1^3+x_1^2+Z(2)^0
sage: x = PolynomialRing(GF(2), 'x').gen() sage: f = (x^3 - x + 1)*(x + x^2); f x^5 + x^4 + x^3 + x sage: g = (x^3 - x + 1)*(x + 1) sage: f.gcd(g) x^4 + x^3 + x^2 + 1
See About this document... for information on suggesting changes.