# Tensor Products and Tor

## `TensorProduct(M, N): ModMPol, ModMPol -> ModMPol, Map`

Given $R-$modules $M$ and $N$, return the tensor product $M\otimes_R N$ as an ambient module $T$, together with the associated map $f: M\times N \rightarrow T$. If $M$ and $N$ are graded, then $T$ is graded also.

## `TensorProduct(C, N): ModCpx, ModMPol -> ModMPol`

Given a complex $C$ of $R$-modules and an $R$-module $N$, return $C\otimes_R N$. This is a new complex whose $i$-th term is $C_i \otimes_R N$ (where $C_i$ is the $i$-th term of $C$); the boundary maps are also derived from those of $C$ in the natural way via the functor $- \otimes_R N$ (see [[Eisenbud, 1995](../../references.md#cite-eisenbudcommalg), p.64]).

## `Tor(i, M, N): RngIntElt, ModMPol, ModMPol -> ModMPol`

Given an integer $i\ge 0$ and $R$-modules $M$ and $N$, return ${\rm Tor}^i(M, N)$. This is the homology at the $i$-th term of the complex $C\otimes_R N$ where $C$ is a free resolution of $M$.

## `Example: Hom (ex-ff1e8f)`

We construct a tensor product and some ${\rm Tor}$ modules for the same modules from the previous example.

```magma
> R<x,y,z> := PolynomialRing(RationalField(), 3);
> M := quo<GradedModule(R, 3) |
>     [x*y, x*z, y*z], [y, x, y],
>     [0, x^3 - x^2*z, x^2*y - x*y*z], [y*z, x^2, x*y]>;
> N := quo<GradedModule(R, 2) |
>     [x^2, y^2], [x^2, y*z], [x^2*z, x*y^2]>;
> T, f := TensorProduct(M, N);
> T;
Graded Module R^6/<relations>
Relations (Groebner basis):
[x^2, y*z, 0, 0, 0, 0],
[0, 0, 0, 0, x^2, y*z],
[0, 0, 0, 0, 0, x*y*z - y*z^2],
[x*y - y*z, 0, 0, 0, 0, 0],
[0, x*y - y*z, 0, 0, 0, 0],
[y*z, 0, 0, -y*z, x*y, 0],
[y, 0, x, 0, y, 0],
[0, y, 0, x, 0, y],
[0, y^2 - y*z, 0, 0, 0, 0],
[0, 0, 0, y^2 - y*z, 0, 0],
[0, 0, 0, 0, 0, y^2 - y*z],
[y*z^2, 0, 0, -y*z^2, 0, -y*z^2],
[0, y*z^2, 0, y*z^2, 0, y*z^2]

```

Note that $f$ maps the cartesian product of $M$ and $N$ into $T$.

```magma
> f(<M.1, N.1>);
[1, 0, 0, 0, 0, 0]
> [f(<m, n>): n in Basis(N), m in Basis(M)];
[
    [1, 0, 0, 0, 0, 0],
    [0, 1, 0, 0, 0, 0],
    [0, 0, 1, 0, 0, 0],
    [0, 0, 0, 1, 0, 0],
    [0, 0, 0, 0, 1, 0],
    [0, 0, 0, 0, 0, 1]
]

```

Finally we construct associated Tor modules.

```magma
> Tor(0, M, N);
Graded Module R^6/<relations>
Relations:
[y, 0, x, 0, y, 0],
[0, y, 0, x, 0, y],
[0, 0, 0, 0, x*y - y*z, 0],
[0, 0, 0, 0, 0, x*y - y*z],
[y*z, x^2, 0, 0, 0, 0],
[x*y*z - y*z^2, 0, 0, 0, 0, 0],
[y^2 - y*z, 0, 0, 0, 0, 0],
[0, 0, y*z, x^2, 0, 0],
[0, 0, x*y*z - y*z^2, 0, 0, 0],
[0, 0, y^2 - y*z, 0, 0, 0],
[0, 0, 0, 0, y*z, x^2],
[0, 0, 0, 0, y^2 - y*z, 0],
[0, 0, 0, 0, x*y*z - y*z^2, 0]
> Tor(1, M, N);
Graded Module R^2/<relations> with grading [3, 3]
Relations:
[y - z,     0],
[    z,    -y],
[  z^2,  -x*y],
[    0,     0]
> Tor(2, M, N);
Free Reduced Module R^0

```
