# manipulating chain complexes

There are several natural ways to handle chain complexes; for details, see ChainComplex. Let's illustrate by making two chain complexes.
 `i1 : R = QQ[x,y];` ```i2 : M = coker vars R o2 = cokernel | x y | 1 o2 : R-module, quotient of R``` ```i3 : N = coker matrix {{x}} o3 = cokernel | x | 1 o3 : R-module, quotient of R``` ```i4 : C = res M 1 2 1 o4 = R <-- R <-- R <-- 0 0 1 2 3 o4 : ChainComplex``` ```i5 : D = res N 1 1 o5 = R <-- R <-- 0 0 1 2 o5 : ChainComplex```
We can form the direct sum as follows.
 ```i6 : C ++ D 2 3 1 o6 = R <-- R <-- R <-- 0 0 1 2 3 o6 : ChainComplex```
We can shift the degree, using the traditional notation.
 ```i7 : E = C 1 2 1 o7 = R <-- R <-- R <-- 0 -5 -4 -3 -2 o7 : ChainComplex``` ```i8 : E_-4 == C_1 o8 = true```
The same syntax can be used to make a chain complex from a single module.
 ```i9 : R^4 4 o9 = R -1 o9 : ChainComplex```
We can form various tensor products with **, and compute Tor using them.
 ```i10 : M ** D o10 = cokernel | x y | <-- cokernel {1} | x y | 0 1 o10 : ChainComplex``` ```i11 : C ** D 1 3 3 1 o11 = R <-- R <-- R <-- R <-- 0 <-- 0 0 1 2 3 4 5 o11 : ChainComplex``` ```i12 : prune HH_1(C ** D) o12 = cokernel {1} | y x | 1 o12 : R-module, quotient of R``` ```i13 : prune HH_1(M ** D) o13 = cokernel {1} | y x | 1 o13 : R-module, quotient of R``` ```i14 : prune HH_1(C ** N) o14 = cokernel {1} | y x | 1 o14 : R-module, quotient of R```
Of course, we can use Tor to get the same result.
 ```i15 : prune Tor_1(M,N) o15 = cokernel {1} | y x | 1 o15 : R-module, quotient of R```