Skip to main content

Postmodern Algebra

Section C.3 Basic Commands

Many Macaulay2 commands are easy to guess, and named exactly what you would expect them to be named. Often, googling “Macaulay2” followed by a few descriptive words will easily land you on the documentation for whatever you are trying to do.
Here are some basic commands you will likely use:
  • ideal (f_1, \dots , f_n) will return the ideal generated by \(f_1, \dots , f_n\text{.}\) Here products should be indicated by *, and powers with ^. If you’d rather not use ^ (this might be nice if you have lots of powers), you can write ideal (f_1, \dots , f_n) instead.
  • map S, R, (f_1, \dots , f_n) gives a ring map \(R \to S\) if \(R\) and \(S\) are rings, and \(R\) is a quotient of \(k[x_1, \dots , x_n]\text{.}\) The resulting ring map will send \(x_i \mapsto f_i\text{.}\) There are many variations of map — for example, you can use it to define \(R\)-module homomorphisms — but you should carefully input the information in the required format. Try viewHelp map in Macaulay2 for more details.
  • ker\((f)\) returns the kernel of the map \(f\) .
  • I + J and I*J return the sum and product of the ideals \(I\) and \(J\text{,}\) respectively.
  • A = matrix\{\{a_1,1, \dots , a_1,n}, \dots , {a_m,1, \dots , a_m,n\}\} returns the matrix
    \begin{equation*} A= \begin{pmatrix} a_{1,1} & \dots & a_{1,n} \\ & \ddots & \\ a_{m,1} & \dots & a_{m,n} \end{pmatrix} \end{equation*}
As in most programming languages, Macaulay2 follows the convention that the first position in a list is the \(0\)th position.
The method primaryDecomposition returns a list of primary ideals whose intersection is the input ideal, and associatedPrimes returns the list of associated primes of the given ideal or module. Operations on lists are often intuitive. For example, let’s say we want to find the primary component of an ideal with a particular radical.
i1 : R = QQ[x,y];

i2 : I = ideal"x2,xy";

o2 : Ideal of R

i3 : prim = primaryDecomposition I
                          2
o3 = {ideal x, ideal (y, x )}

o3 : List

i4 : L = select(prim, Q -> radical(Q) == ideal"x,y")
                 2
o4 = {ideal (y, x )}

o4 : List
The method select returns a list of all the elements in our list with the required properties. In this case, if we actually want the primary ideal we just selected, as opposed to a list containing it, we need to extract the first component of our list \(L\text{.}\)
i5 : L_0
                2
o5 = ideal (y, x )

o5 : Ideal of R