replacements for commands and scripts from Macaulay
Macaulay 2 aims to provide all of the functionality of Macaulay, but
the names of the functions are not the same, and there are
other differences. One major difference is the introduction of the
notion of module, whereas in Macaulay, the pervasive concept was
the matrix.
Here is a list of old Macaulay functions, together with pointers to
functions in Macaulay 2 that might be used to replace them.
add <matrix> <matrix> <matrix>
Add matrices m and n, using result = m + n. In general, arithmetic in Macaulay2
is done using natural mathematical expressions. See +.
betti <res>
Display the graded betti numbers of a chaincomplex or resolution C using betti C. See betti.
calc <computation> [hi degree]
chcalc <computation> [new hi deg]
Compute the Groebner basis of m up to a given degree, using gb(m, DegreeLimit=>3). Similarly,
if a computation in Macaulay2 has been halted by pressing <CTRL>-C,
the computation
can be restarted from where it left off, by giving the original
command, e.g. gb m.
cat <first var(0..numvars-1)> <result matrix>
Macaulay1 then also prompts for two lists of integers, say rows and cols. The resulting catalecticant matrix can
be obtained in
Macaulay2 in the following way.
i1 : R = QQ[a..h]
o1 = R
o1 : PolynomialRing |
i2 : rows = {0,1,2}
o2 = {0, 1, 2}
o2 : List |
i3 : cols = {0,3}
o3 = {0, 3}
o3 : List |
i4 : result = map(R^3, 2, (i,j) -> R_(rows_i + cols_j))
o4 = | a d |
| b e |
| c f |
3 2
o4 : Matrix R <--- R |
characteristic <ring> [result integer]
To obtain the characteristic of a ring R, use char R. See char.
codim <standard basis> [integer result]
When computing the codimension of an ideal or module M, a Groebner basis is computed automatically, if needed. Use codim M.One use of this command in Macaulay1 was to compute the codimension
of a partially
computed Groebner basis. See computing with partial results for examples of doing this.
coef <matrix> <result monoms> <result coefs> [variable list]
To obtain the matrices of monomials and their coefficients, use coefficients. The following example obtains the coefficients
of the variable a (which is variable number 0)
i6 : m = matrix{{a^2+a^2*c+a*b+3*d}}
o6 = | a2c+a2+ab+3d |
1 1
o6 : Matrix R <--- R |
i7 : result = coefficients({0}, m)
o7 = {| a2 a 1 |, | c+1 b 3d |}
o7 : List |
i8 : result_0
o8 = | a2 a 1 |
1 3
o8 : Matrix R <--- R |
i9 : result_1
o9 = | c+1 b 3d |
1 3
o9 : Matrix R <--- R |
col_degree <matrix> <column> [result integer]
To obtain the degree of the ith column of a matrix m, use (degrees source m)_i. See degrees. Note that in Macaulay2, one can use multi-degrees, so the result
is a list of integers. Also all indices in Macaulay2 start at 0.
i10 : R = QQ[a,b,Degrees=>{{1,0},{1,-1}}]; |
i11 : m = matrix{{a*b, b^2}}
o11 = | ab b2 |
1 2
o11 : Matrix R <--- R |
i12 : (degrees source m)_0
o12 = {2, -1}
o12 : List |
col_degs <matrix> [column degrees]
Compute the list of degrees of the columns of a matrix m using degrees source m. The result is a list of degrees.
Each degree is itself a list of integers, since multi-degrees are
allowed.
commands
Using Macaulay2 in emacs, type the first few letters of a command,
then hit <TAB>. The list of all commands starting with those letters
will be displayed, or if there is only one, emacs will complete the typing
for you.
compress <matrix> <result matrix>
Remove columns of a matrix m which are entirely zero
using compress m. See compress.
concat <matrix> <matrix2> ... <matrix n>
Concatenate matrices m1, m2, ..., mn using m1 | m2 | ... | mn. See |. The main difference is that
in Macaulay2 this command does not overwrite the first matrix.
continue
In Macaulay2, one interrupts a computation using <CTRL>-C, as in
Macaulay1. Restart the computation using the original command. For
Groebner basis and resolution commands, the computation starts off
where it left off.
contract <ideal> <ideal> <result matrix>
To contract the matrix n by the matrix m use contract(m,n). See contract. In Macaulay2, the
arguments are not constrained to be matrices with one row.
copy <existing matrix> <copy of matrix>
Since matrices in Macaulay2 are immutable objects, this command is
no longer necessary. One can still make a copy of a matrix. For
example
i13 : R = ZZ/101[a..d]
o13 = R
o13 : PolynomialRing |
i14 : m = matrix{{a,b},{c,d}}
o14 = | a b |
| c d |
2 2
o14 : Matrix R <--- R |
i15 : copym = map(target m, source m, entries m)
o15 = | a b |
| c d |
2 2
o15 : Matrix R <--- R |
degree <standard basis> [integer codim] [integer degree]
When computing the degree of an ideal or module M, a Groebner basis is computed automatically, if needed. Use degree M. Note that in Macaulay2, degree returns
only the degree. Use codim M to obtain the codimension.One use of this command in Macaulay1 was to compute the degree
of a partially
computed Groebner basis. See computing with partial results for examples of doing this.
determinants <matrix> <p> <result>
Use minors(p,m) to compute the ideal of p by p minors
of the matrix m. See minors.
diag <matrix> <result>
To make a diagonal matrix whose diagonal entries are taken from
a matrix m, it is necessary to build the matrix directly,
as in the following example.
i17 : m = matrix{{a^2,b^3,c^4,d^5}}
o17 = | a2 b3 c4 d5 |
1 4
o17 : Matrix R <--- R |
i18 : map(R^(numgens source m), source m,
(i,j) -> if i === j then m_(0,i) else 0)
o18 = | a2 0 0 0 |
| 0 b3 0 0 |
| 0 0 c4 0 |
| 0 0 0 d5 |
4 4
o18 : Matrix R <--- R |
diff <ideal> <ideal> <result matrix>
To differentiate the matrix n by the matrix m use diff(m,n). See diff. In Macaulay2, the
arguments are not constrained to be matrices with one row.
dshift <matrix> <degree to shift by>
To shift the degrees of a matrix m by an integer d, use m ** (ring m)^{-d}. See **. Note that this
returns a matrix with the degrees shifted, and does not modify the
original matrix m. For example
i20 : m = matrix{{a,b^2},{c^2,d^3}}
o20 = | a b2 |
| c2 d3 |
2 2
o20 : Matrix R <--- R |
i21 : betti m
o21 = total: 2 2
0: 2 .
1: . 1
2: . 1 |
i22 : n = m ** R^{-1}
o22 = {1} | a b2 |
{1} | c2 d3 |
2 2
o22 : Matrix R <--- R |
i23 : betti n
o23 = total: 2 2
1: 2 .
2: . 1
3: . 1 |
dsum <matrix> ... <matrix> <result>
To form the direct sum of matrices m1, m2, ..., mn, use m1 ++ m2 ++ ... ++ mn. See ++.
elim <standard basis> <result matrix> [n]
To select the columns of the matrix m which lie in the
subring defined by the first n slots of the monomial order
being zero, use selectInSubring(n,m). Usually, one uses the
value of 1 for n.
ev <ideal> <matrix> <changed matrix>
In Macaulay2, one uses ring maps, or substitute to
substitute variables. If m is a matrix in a ring R having n variables, and f is a 1 by n matrix
over some ring, then use substitute(m,f) to perform the
substitution. For example,
i24 : R = QQ[a..d]
o24 = R
o24 : PolynomialRing |
i25 : S = QQ[s,t]
o25 = S
o25 : PolynomialRing |
i26 : m = matrix{{a^2-d, b*c}}
o26 = | a2-d bc |
1 2
o26 : Matrix R <--- R |
i27 : f = matrix{{s^4,s^3*t,s*t^3,t^4}}
o27 = | s4 s3t st3 t4 |
1 4
o27 : Matrix S <--- S |
i28 : substitute(m,f)
o28 = | s8-t4 s4t4 |
1 2
o28 : Matrix S <--- S |
In Macaulay2, one may also create and apply ring maps
i29 : F = map(R,R,{b,c,d,a})
o29 = map(R,R,{b, c, d, a})
o29 : RingMap R <--- R |
i30 : m + F m + F F m + F F F m
o30 = | a2+b2+c2+d2-a-b-c-d ab+bc+ad+cd |
1 2
o30 : Matrix R <--- R |
Or one may substitute for only some variables
i31 : substitute(m, {a=>1, b=>3})
o31 = | -d+1 3c |
1 2
o31 : Matrix R <--- R |
exit
Use exit to quit Macaulay2.
fetch <matrix> <result matrix> [ones, default=zeros]
In order to bring a matrix m to a ring S which
has ring variables of the same name, use substitute(m,S).
i32 : R = ZZ[s,t]
o32 = R
o32 : PolynomialRing |
i33 : m = s^2+t^2
2 2
o33 = s + t
o33 : R |
i34 : S = R[a..d]
o34 = S
o34 : PolynomialRing |
i35 : substitute(m,S)
2 2
o35 = s + t
o35 : S |
flatten <matrix> <result ideal of entries>
In order to form a one row matrix with the entries of a matrix m, use flatten m. See flatten.
forcestd <matrix> <result standard basis> [change of basis]
In order to inform the system that the columns of the matrix m form a Groebner basis, use forceGB m. See forceGB.
hilb <standard basis>
WRITE THIS
hilb_numer <standard basis> <ideal> <result>
WRITE THIS
homog <matrix> <homog variable> <new matrix>
To homogenize a matrix m with respect to a variable x, use homogenize(m,x). One may also homogenize
with respect to a given weight vector. See homogenize.
hulb <standard basis> <deg>
WRITE THIS
ideal <resulting matrix>
To enter a one row matrix, use e.g.
i36 : R = ZZ[a..d]
o36 = R
o36 : PolynomialRing |
i37 : f = matrix{{a^2-b*c,3*b*c^4-1}}
o37 = | a2-bc 3bc4-1 |
1 2
o37 : Matrix R <--- R |
Remember that ideals, modules, and matrices are all different in
Macaulay2. One can easily change between them, as in:
i38 : J = ideal f
2 4
o38 = ideal (a - b*c, 3b*c - 1)
o38 : Ideal of R |
i39 : generators J
o39 = | a2-bc 3bc4-1 |
1 2
o39 : Matrix R <--- R |
i40 : image f
o40 = image | a2-bc 3bc4-1 |
1
o40 : R-module, submodule of R |
i41 : cokernel f
o41 = cokernel | a2-bc 3bc4-1 |
1
o41 : R-module, quotient of R |
iden <size> <result>
To make the identity map on a module F, use id_F, as in
i42 : id_(R^4)
o42 = | 1 0 0 0 |
| 0 1 0 0 |
| 0 0 1 0 |
| 0 0 0 1 |
4 4
o42 : Matrix R <--- R |
See id.
if <integer> <label1> [<label2>]
For conditional execution, use the if-then or if-then-else statementWRITE MORE
imap <new ring map> <R> <S> [ones, default=zeros]
WRITE THIS
in <standard basis> [optional result matrix] [n]
WRITE THIS
inpart <standard basis> <result matrix> [variable list]
WRITE THIS
int <name> <new value>
To assign a value to a variable in Macaulay2, use =. For example,
i43 : myanswer = 2*(numgens R) - 1
o43 = 7 |
Warning: In Macaulay1, names of variables in rings, and user defined
variables are completely separate. In Macaulay2, if you assign something
to a ring variable, it will assume its new value.
i44 : R = ZZ/31991[a..d]
o44 = R
o44 : PolynomialRing |
i48 : use R
o48 = R
o48 : PolynomialRing |
intersect <mat 1> ... <mat n> <result computation>
To intersect ideals, or submodules I1, I2, ..., In, use intersect(I1,I2,...,In). The main difference
is that these values cannot be matrices, they must be ideals or
submodules. A second difference is that the computation, if interrupted,
must be restarted at the beginning. See intersect. For example,
i50 : I = ideal(a^2-b,c-1,d^2-a*b)
2 2
o50 = ideal (a - b, c - 1, - a*b + d )
o50 : Ideal of R |
i51 : J = ideal(a*b-1, c*d-2)
o51 = ideal (a*b - 1, c*d - 2)
o51 : Ideal of R |
i52 : intersect(I,J)
2 3 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2
o52 = ideal (c d - c*d - 2c + 2, - 10664c*d + 10664a*b*d + 10663a*b + 10664c*d - 10663d - 10664d, - 10664c d + 10664a*b*c + 10663c d + 10664c*d - 10664a*b + 10665c*d + c + 10663d - 1, - 10664a*b*c*d + 10664a b + 10663a*b*c*d - 10663a*b*d + 10664c*d - 10664a*b - 10663c*d + 10663d, 10664a c*d - 10664a b - 10663a c*d - 10664b*c*d + 10664a*b + 10663a d + 10663b*c*d - a - 10663b*d + b)
o52 : Ideal of R |
is_zero <poly> <result integer: 1 if zero, else 0>
To decide whether a polynomial, matrix, ideal, etc., f is zero, use f == 0. The resulting value is a Boolean:
either true, or false. See ==.
jacob <ideal> <resulting jacobian> [variable list]
To find the Jacobian matrix of an ideal or one row matrixf, use jacobian f. If you only wish to differentiate
with some of the variables, use diff instead. See jacobian.
jump <label>
Macaulay2 has no go to statements. Instead, you should use the
control structures.WRITE MORE
k_basis <matrix> <result matrix> [variable list]
WRITE THIS
keep <standard basis> <result matrix> [n]
WRITE THIS
kill <var1> ... <var n>
WRITE THIS
koszul <int n, or matrix> <p> <result matrix>
WRITE THIS
lift <standard basis> <matrix to lift> <result>
WRITE THIS
lift_std <matrix> <computation>
WRITE THIS
listvars
WRITE THIS
mat <result matrix> [optional: file name]
WRITE THIS