sage: singular(389) 389 sage: R1 = singular.ring(0, '(x,y)', 'dp') sage: f = singular('9*x^16-18*x^13*y^2-9*x^12*y^3+9*x^10*y^4-18*x^11*y^2+36*x^8*y^4+18*x^7*y^5-18*x^5*y^6+9*x^6*y^4-18*x^3*y^6-9*x^2*y^7+9*y^8') sage: F = f.factorize() sage: print F [1]: _[1]=9 _[2]=x^6-2*x^3*y^2-x^2*y^3+y^4 _[3]=-x^5+y^2 [2]: 1,1,2
Next we convert the factor
to a SAGE multivariate
polynomial. Note that it is important to let
and
be the
generators of a polynomial ring, so the eval command works.
sage: x, y = MPolynomialRing(RationalField(), 2).gens() sage: g = eval(F[1][3].sage_polystring()); g x1^2 - x0^5
Next we create a polynomial ring in GAP and obtain its indeterminates:
sage: R = gap.PolynomialRing('Rationals', 2); R PolynomialRing(..., [ x_1, x_2 ]) sage: I = R.IndeterminatesOfPolynomialRing(); I [ x_1, x_2 ]
In order to eval
in GAP, we need to tell GAP to view the variables
x0
and x1
as the two generators of
. This is the
one tricky part. In the GAP interpreter the object
I
has its
own name (which isn't I
). We can access its name using
I.name()
.
sage: _ = gap.eval("x0 := %s[1];; x1 := %s[2];;"%(I.name(), I.name()))
Now
and
are defined, so we can construct the GAP polynomial
corresponding to
:
sage: f = gap(str(g)); f -x_1^5+x_2^2
We can call GAP functions on
. For example, we evaluate
the GAP
Value
function, which evaluates
at the point
.
sage: f.Value(I, [1,2]) 3 sage: g(1,2) # agrees 3
See About this document... for information on suggesting changes.