Skip to main content

Postmodern Algebra

Section C.1 Getting Started

A Macaulay2 session often starts with defining some ambient ring we will be doing computations over. Common rings such as the rationals and the integers can be defined using the commands QQ and ZZ; one can easily take quotients or build polynomial rings (in finitely many variables) over these. For example,
i1 : R = ZZ/101[x,y]

o1 = R

o1 : PolynomialRing

    and

i1 : k = ZZ/101;

i2 : R = k[x,y];
both store the ring \(\Z/(101)\) as \(R\text{,}\) with the small difference that in the second example Macaulay2 has named the coefficient field \(k\text{.}\) One quirk that might make a difference later is that if we use the first option and later set \(k\) to be the field \(\Z/(101)\text{,}\) our ring \(R\) is not a polynomial ring over \(k\text{.}\) Also, in the second example we ended each line with a ;, which tells Macaulay2 to run the command but not display the result of the computation — which is in this case was simply an assignment, so the result is not relevant.
We can now do all sorts of computations over our ring \(R\text{.}\) For example, we can define an ideal in \(R\) as follows:
i3 : I = ideal(x^2,y^2,x*y)
             2   2
o3 = ideal (x , y , x*y)

o3 : Ideal of R
Above we have set \(I\) to be the ideal in \(R\) that is generated by \(x^2, y^2, xy\text{.}\) The notation ideal( ) requires the usage of ^ for powers and * for products; alternatively, we can define the exact same ideal with the notation ideal" ", as follows:
i3 : I = ideal"x2,y2,xy"
             2   2
o3 = ideal (x , y , x*y)

o3 : Ideal of R
Now we can use this ideal \(I\) to either define a quotient ring \(S=R/I\) or the \(R\)-module \(M=R/I\text{,}\) as follows:
i4 : M = R^1/I

o4 = cokernel | x2 y2 xy |
                            1
o4 : R-module, quotient of R

i5 : S = R/I

o5 = S

o5 : QuotientRing
It’s important to note that while \(R\) is a ring, \(R^1\) is the \(R\)-module \(R\) — this is a very important difference for Macaulay2, since these two objects have different types. So \(S\) defined above is a ring, while \(M\) is a module. Notice that Macaulay2 stored the module \(M\) as the cokernel of the map
\begin{equation*} R^3\xrightarrow {[x^2\;\;y^2\;\;xy]} R. \end{equation*}
When you make a new definition in Macaulay2, you might want to pay attention to what ring your new object is defined over. For example, now that we defined this ring \(S\text{,}\) Macaulay2 has automatically taken \(S\) to be our current ambient ring, and any calculation or definition we run next will be considered over \(S\) and not \(R\text{.}\) If you want to return to the original ring \(R\text{,}\) you must first run the command use R
If you want to work over a finitely generated algebra over one of the basic rings you can define in Macaulay2, and your ring is not a quotient of a polynomial ring, you want to rewrite this algebra as a quotient of a polynomial ring. For example, suppose you want to work over the second Veronese in \(2\) variables over our field \(k\) from before, meaning the algebra \(k[x^2, xy, y^2]\text{.}\) We need \(3\) algebra generators, which we will call \(a, b, c,\) corresponding to \(x^2, x^y,\) and \(y^2\text{:}\)
o6 = U

o6 : PolynomialRing

i7 : f = map(R,U,{x^2,x*y,y^2})
               2        2
o7 = map(R,U,{x , x*y, y })

o7 : RingMap R <--- U

i8 : J = ker f
            2
o8 = ideal(b - a*c)

o8 : Ideal of U

i9 : T = U/J

o9 = T

o9 : QuotientRing
Our ring \(T\) at the end is isomorphic to the 2nd Veronese of \(R\text{,}\) which is the ring we wanted. Note the syntax order in map: first target, then source, then a list with the images of each algebra generator.