Macaulay2 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 Macaulay2 that might be used to replace them.
-
Macaulay commands:
-
ac -- such destructive changes are not allowed
-
add -- +
-
ar -- not documented yet
-
betti -- betti
-
calc -- not documented yet
-
cat -- not documented yet
-
ce -- not documented yet
-
characteristic -- char
-
chcalc -- not documented yet
-
codim -- codim
-
coef -- not documented yet
-
col_degree -- not documented yet
-
col_degs -- not documented yet
-
commands -- not documented yet
-
compress -- compress
-
concat -- |,||
-
continue -- not documented yet
-
contract -- contract
-
copy -- not documented yet
-
degree -- degree
-
determinants -- minors
-
diag -- The command diag m n is equivalent to the Macaulay2 expression
n = map((ring m)^(numgens source m), source m,(i,j) -> if i === j then m_(0,i) else 0)
-
diag -- not documented yet
-
diff -- diff
-
dshift -- not documented yet
-
dsum -- ++
-
edit -- not documented yet
-
edit_map -- not documented yet
-
elim -- selectInSubring
-
ev -- substitute,RingMap
-
exit -- quit
-
fetch -- substitute
-
flatten -- flatten
-
forcestd -- forceGB
-
help -- help
-
help_file -- not documented yet
-
hilb -- hilbertSeries,hilbertPolynomial,hilbertFunction,poincare
-
hilb_numer -- hilbertSeries
-
homog -- homogenize
-
hulb -- not documented yet
-
ideal -- ideal, matrix
-
iden -- id
-
if -- if
-
imap -- map
-
in -- leadTerm
-
inpart -- not documented yet
-
int -- not documented yet
-
intersect -- intersect
-
is_zero -- ==
-
jacob -- jacobian
-
jump -- not documented yet
-
k-basis -- basis
-
k_basis -- basis
-
keep -- not documented yet
-
kill -- not documented yet
-
koszul -- koszul
-
lift -- //
-
lift_std -- gb
-
listvars -- listUserSymbols
-
mat -- matrix
-
max -- max
-
mc -- not documented yet
-
min -- min
-
modulo -- modulo
-
monitor -- using Macaulay2 with emacs
-
monitoring -- not documented yet
-
monoms -- not documented yet
-
monprimes -- not documented yet
-
mr -- not documented yet
-
mult -- *
-
ncols -- use numgens source m
-
nres -- resolution
-
nrows -- use numgens target m
-
numinfo -- not documented yet
-
nvars -- use numgens R
-
outer -- **
-
path -- path
-
pc -- not documented yet
-
pfaff -- pfaffians
-
pmap -- not documented yet
-
poly -- not documented yet
-
power -- ^
-
pr -- not documented yet
-
pres <C:complex> -- Use C.dd or print C.dd
-
present_ring -- not documented yet
-
pring -- not documented yet
-
prmat -- print or toString
-
putchange -- not documented yet
-
putmat -- not documented yet
-
putstd -- not documented yet
-
qring <I:ideal> <result A:ring> -- In Macaulay2, if I is an ideal, then A = (ring I)/I is equivalent, except that in Macaulay2, a Gröbner basis of I is computed for you, if it is needed
-
quit -- quit
-
quotient -- not documented yet
-
random -- not documented yet
-
reduce -- not documented yet
-
res -- not documented yet
-
reset -- restart
-
ring -- not documented yet
-
ring-from-rows -- not documented yet
-
ring_from_cols -- not documented yet
-
ring_from_rows -- not documented yet
-
ring_sum -- not documented yet
-
rmap -- not documented yet
-
row_degree -- not documented yet
-
row_degs -- not documented yet
-
sat -- saturate
-
set -- not documented yet
-
set_value -- not documented yet
-
setcoldegs -- not documented yet
-
setdegs -- not documented yet
-
setring -- use
-
shout -- not documented yet
-
size -- not documented yet
-
smult -- *
-
space -- not documented yet
-
spairs -- not documented yet
-
spare -- not documented yet
-
sparse -- not documented yet
-
std -- not documented yet
-
std_minimal -- not documented yet
-
stdpart -- not documented yet
-
submat -- submatrix
-
subtract -- -
-
syz -- syz,kernel
-
tensor <matrix M> <matrix N> <result matrix M.N> -- cokernel M ** cokernel N
-
trace -- trace
-
transpose -- transpose
-
truncate -- truncate(ZZ,Module)
-
type -- not documented yet
-
version -- version
-
wedge -- minors,exteriorPower
-
Macaulay scripts from 'scriptsde':
-
Macaulay scripts from 'scriptsmj':
-
Macaulay scripts from 'scriptsms':
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 Gröbner 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 Gröbner 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 Gröbner basis.
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)
i5 : R = ZZ/101[a..d];
|
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(m, Variables => {a})
o7 = (| a2 a 1 |, {2} | c+1 |)
{1} | b |
{0} | 3d |
o7 : Sequence
|
i8 : result_0
o8 = | a2 a 1 |
1 3
o8 : Matrix R <-- R
|
i9 : result_1
o9 = {2} | c+1 |
{1} | b |
{0} | 3d |
3 1
o9 : Matrix R <-- R
|
col_degree <matrix> <column> [result integer]
To obtain the degree of the
i-th 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 Gröbner 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 Gröbner 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 Gröbner basis.
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.
i16 : R = ZZ[a..d];
|
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
i19 : R = ZZ[a..d];
|
i20 : m = matrix{{a,b^2},{c^2,d^3}}
o20 = | a b2 |
| c2 d3 |
2 2
o20 : Matrix R <-- R
|
i21 : betti m
0 1
o21 = total: 2 2
0: 2 .
1: . 1
2: . 1
o21 : BettiTally
|
i22 : n = m ** R^{-1}
o22 = {1} | a b2 |
{1} | c2 d3 |
2 2
o22 : Matrix R <-- R
|
i23 : betti n
0 1
o23 = total: 2 2
1: 2 .
2: . 1
3: . 1
o23 : BettiTally
|
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 Gröbner basis, use
forceGB m. See
forceGB.
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.
ideal <resulting matrix>
To enter a one row matrix, use we may use the following method.
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 statement
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
|
i45 : a
o45 = a
o45 : R
|
i46 : a = 43
o46 = 43
|
i47 : a
o47 = 43
|
i48 : use R
o48 = R
o48 : PolynomialRing
|
i49 : a
o49 = a
o49 : R
|
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
o52 = ideal (c d - c*d - 2c + 2, a*b*c - a*b - c + 1, c*d - a*b*d + 2a*b -
-----------------------------------------------------------------------
2 2 2 2 2 2
c*d - 2d + d, a c*d - b*c*d - 2a + 2b, a b*d - b c*d - 2a b + a*c*d +
-----------------------------------------------------------------------
2 2 2 2 2 3 2 2
2b - a*d, a b - a*b*d - a*b + d , a b - a*b - a + 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 matrix
f, 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.