In Macaulay2, ring maps from a polynomial ring are defined and used as follows.
i1 : A = QQ[a,b,c];
|
i2 : f = a+b+a*b+c^3;
|
i3 : B = QQ[x,y,z];
|
i4 : F = map(B,A,{x+y, x-y, z})
o4 = map (B, A, {x + y, x - y, z})
o4 : RingMap B <-- A
|
Notice that ring maps are defined by first giving the target ring, then the source ring, and finally the data.
Parentheses for functions with one parameter are optional.
i5 : g = F f
3 2 2
o5 = z + x - y + 2x
o5 : B
|
i6 : A1 = QQ[x,y,c,b,a,z];
|
i7 : substitute(f,A1)
3
o7 = c + b*a + b + a
o7 : A1
|
To map the first variable of A to the first variable of A1, the second variable of A to the second variable of A1, and so on, create the list of the first generators of A1
i8 : v = take(gens A1, numgens A)
o8 = {x, y, c}
o8 : List
|
i9 : G = map(A1,A,v)
o9 = map (A1, A, {x, y, c})
o9 : RingMap A1 <-- A
|
i10 : G f
3
o10 = c + x*y + x + y
o10 : A1
|