Macaulay2 » Documentation
Packages » Macaulay2Doc > matrices > format and display of matrices in Macaulay2
next | previous | forward | backward | up | index | toc

format and display of matrices in Macaulay2

By default, Macaulay2 displays matrices in a compact form.
i1 : QQ[x,y];
i2 : f = matrix{{x^2, x*y},{x*y, y^2}}

o2 = | x2 xy |
     | xy y2 |

                      2               2
o2 : Matrix (QQ[x..y])  <-- (QQ[x..y])
i3 : dual f

o3 = {-2} | x2 xy |
     {-2} | xy y2 |

                      2               2
o3 : Matrix (QQ[x..y])  <-- (QQ[x..y])
i4 : source f

               2
o4 = (QQ[x..y])

o4 : QQ[x..y]-module, free, degrees {2:2}
i5 : target dual f

               2
o5 = (QQ[x..y])

o5 : QQ[x..y]-module, free, degrees {2:-2}
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.

Note how the exponents have been placed to the right of the variables rather than formatted in superscript. While this format is generally considered to be desirable, this can be turned off by setting the variable compactMatrixForm to false.
i6 : compactMatrixForm = false

o6 = false
i7 : matrix{{x^2 + 3, x^4 + 1},{x^13 - 5, x^7 - 1}}

     |    2       4      |
o7 = |   x  + 3  x  + 1  |
     |                   |
     |   13       7      |
     |  x   - 5  x  - 1  |

                      2               2
o7 : Matrix (QQ[x..y])  <-- (QQ[x..y])
To have Macaulay2 display matrices in compact form again, type:
i8 : compactMatrixForm = true

o8 = true
i9 : matrix{{x^2 + 3, x^4 + 1},{x^13 - 5, x^7 - 1}}

o9 = | x2+3  x4+1 |
     | x13-5 x7-1 |

                      2               2
o9 : Matrix (QQ[x..y])  <-- (QQ[x..y])