Macaulay2 begins with printing its version number and preloaded packages. After that, your first input prompt will be i1 : .
In response to the prompt, type 2+2 and press Enter. The expression you entered will be evaluated — no punctuation is required at the end of the line.
|
The answer is displayed to the right of the output label o1 =.
Here is some arithmetic with fractions.
|
Notice the additional line of output labeled with o2 :. Output lines labeled with colons provide information about the type of output. In this case, the symbol QQ is our notation for the class of all rational numbers, and indicates that the answer on the previous line is a rational number.
Multiplication is indicated with *.
|
Powers are obtained with ^.
|
Factorials are obtained with !.
|
Because some answers can be very long, it is a good idea to run the program in a window that does not wrap output lines, and allows the user to scroll left horizontally to see the rest of the output. (See using Macaulay2 with Emacs.)
|
Multiple expressions may be separated by semicolons.
|
A semicolon at the end of the line suppresses the printing of the value.
|
The output from the previous line can be obtained with oo, even if a semicolon prevented it from being printed.
|
Lines before that can be obtained with ooo and oooo. Alternatively, the symbol labeling an output line can be used to retrieve the value, as in the following example.
|
To enter a string, use quotation marks.
|
A value can be assigned to a variable with =.
|
Strings may be concatenated horizontally with | (see String | String).
|
or vertically with || (see Net || Net).
|
A list of expressions can be formed with braces.
|
Lists behave like vectors.
|
A function can be created with the arrow operator, -> .
|
To evaluate a function, place its argument to the right of the function.
|
Functions of more than one variable take a parenthesized sequence of arguments.
|
|
The function apply can be used to apply a function to each element of a list.
|
|
The operator .. may be used to generate sequences of consecutive numbers.
|
If the first argument to apply is an integer n then it stands for the list {0, 1, ..., n-1}.
|
The function scan is analogous to apply except that no value is returned. It may be used to implement loops in programs.
|
|
Most computations with polynomials take place in rings that may be specified in usual mathematical notation.
|
Caution: we reserve single letter symbols such as Z for use as variables in rings, hence we must use something like ZZ to stand for the ring of integers. It may remind you of the "blackboard bold" font of $\mathcal{A\kern-.1667em}\raisebox{-.5ex}{$\mathcal M$\kern-.125em}\mathcal{S}\textrm{-}\TeX$. If you prefer Z to ZZ, you may put Z=ZZ in your initialization file. The symbols ZZ/5 represent the quotient ring $\ZZ/5\ZZ$, and ZZ/5[x,y,z] represents the ring of polynomials in the variables $x$,$y$, and $z$ with coefficients in the ring $\ZZ/5\ZZ$.
|
Rings and certain other types of things acquire the name of the global variable they are assigned to.
|
To see the original description of a ring, use describe.
|
A free module can be created as follows.
|
The i-th basis element of F can be obtained as F_i. In this example, the valid values for i are 0, 1, and 2.
|
Using a list of indices instead will produce the homomorphism corresponding to the basis vectors indicated.
|
Repetitions are allowed.
|
We can create a homomorphism between free modules with matrix by providing the list of rows of the matrix, each of which is in turn a list of ring elements.
|
Use image to get the image of f.
|
We may use ideal to produce the corresponding ideal.
|
We may use kernel to compute the kernel of f.
|
The answer comes out as a module that is expressed as the image of a homomorphism whose matrix is displayed. This is one way of making modules from matrices. Integers inside braces to the left of the matrix give the degrees of the basis elements of the target of the matrix; they are omitted if the degrees are all zero. In case the matrix itself is desired, it can be obtained with generators, as follows.
|
We may use poincare to compute the Poincare polynomial.
|
We may use rank to compute the rank.
|
A presentation for the kernel can be obtained with presentation.
|
We can produce the cokernel with cokernel; no computation is performed.
|
The direct sum is formed with Module ++ Module.
|
The answer is expressed in terms of the subquotient function, which produces subquotient modules. Each subquotient module is accompanied by its matrix of generators and its matrix of relations. These matrices can be recovered with generators and relations.
|
|
The function prune can be used to convert a subquotient module to a quotient module.
|
We can use resolution to compute a projective resolution of the cokernel of f.
|
To see the differentials we examine C.dd.
|
We can verify that C is a complex by squaring the differential map.
|
We can use betti to see the degrees of the components of C.
|
Let's try a harder example. We can use .. to create a sequence of variables.
|
We use genericMatrix to make a 3 by 6 generic matrix whose entries are drawn from the variables of the ring R.
|
Then we construct its cokernel with cokernel.
|
We may use resolution to produce a projective resolution of it, and time to report the time required.
|
As before, we may examine the degrees of its components, or display it.
|
We can make a polynomial ring with 18 indexed variables.
|
We can use genericMatrix to pack the variables into 3-by-3 matrices.
|
|
We may look at the matrix product.
|
Let's use flatten to produce the equations generated by the equations that assert that $m$ and $n$ commute with each other.
|
Let's compute a Gröbner basis for the image of j with gb.
|
The resulting Gröbner basis contains a lot of information, which may be very long to print, so only a summary is printed. We can get the generators of the basis using generators, and even though we call upon gb again, the computation will not be repeated.
|
The semicolon prevents the matrix of generators from appearing on the screen, but the class of the matrix appears — we see that there are 26 generators.
We can use betti to see the degrees involved in the Gröbner basis.
|
To exit your first session, you can type exit or quit.
The source of this document is in Macaulay2Doc/ov_first_session.m2:295:0.