Macaulay2 » Documentation
Packages » Macaulay2Doc > chain complexes > making chain complexes by hand
next | previous | forward | backward | up | index | toc

making chain complexes by hand

A new chain complex can be made with C = new ChainComplex. This will automatically initialize C.dd, in which the differentials are stored. The modules can be installed with statements like C#i=M and the differentials can be installed with statements like C.dd#i=d. The ring is installed with C.ring = R. It's up to the user to ensure that the composite of consecutive differential maps is zero.
i1 : R = QQ[x,y,z];
i2 : d1 = matrix {{x,y}};

             1      2
o2 : Matrix R  <-- R
We take care to use map to ensure that the target of d2 is exactly the same as the source of d1.
i3 : d2 = map(source d1, ,{{y*z},{-x*z}});

             2      1
o3 : Matrix R  <-- R
i4 : d1 * d2 == 0

o4 = true
Now we make the chain complex, as explained above.
i5 : C = new ChainComplex; C.ring = R;
i7 : C#0 = target d1; C#1 = source d1; C#2 = source d2;
i10 : C.dd#1 = d1; C.dd#2 = d2;

              1      2
o10 : Matrix R  <-- R

              2      1
o11 : Matrix R  <-- R
Our complex is ready to use.
i12 : C

       1      2      1
o12 = R  <-- R  <-- R
                     
      0      1      2

o12 : ChainComplex
i13 : HH_0 C

o13 = cokernel | x y |

                             1
o13 : R-module, quotient of R
i14 : prune HH_1 C

o14 = cokernel {2} | z |

                             1
o14 : R-module, quotient of R
The chain complex we've just made is simple, in the sense that it's a homological chain complex with nonzero modules in degrees 0, 1, ..., n. Such a chain complex can be made also with chainComplex. It goes to a bit of extra trouble to adjust the differentials to match the degrees of the basis elements.
i15 : D = chainComplex(matrix{{x,y}}, matrix {{y*z},{-x*z}})

       1      2      1
o15 = R  <-- R  <-- R
                     
      0      1      2

o15 : ChainComplex
i16 : degrees source D.dd_2

o16 = {{3}}

o16 : List