# The Hom Module and Ext

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

Given $R-$modules $M$ and $N$, return $H={\rm Hom}_R(M,N)$ as an abstract reduced module and a transfer map $f: H \rightarrow S$, where $S$ is the set of all homomorphisms (of type `ModMPolHom`) from $M$ to $N$. Thus $H$ is a module representing the set of all homomorphisms from $M$ to $N$, while $f$ maps an element $h\in H$ to an actual homomorphism from $M$ to $N$ (and the inverse image of an element of $S$ under $f$ gives a corresponding element of $H$). If $M$ and $N$ are graded, then $H$ is graded also, and the degree $d_f$ of an element $f\in H$ is the degree of the corresponding homomorphism (so an element in $M$ of degree $d$ will be mapped by $f$ to zero or an element of degree $d_f + d$ in $N$).

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

Given a complex $C$ of $R$-modules and an $R$-module $N$, return ${\rm Hom}_R(C, N)$. This is a new complex whose $i$-th term is ${\rm Hom}_R(C_i, 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 ${\rm Hom}_R(-, N)$ (see [[Eisenbud, 1995](../../references.md#cite-eisenbudcommalg), p.63]). Note that the direction of arrows in this complex is opposite to that of $C$.

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

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

## `Example: Hom (ex-7c5089)`

We construct a Hom module and explicit homomorphisms derived from it.

```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]>;
> M;
Graded Module R^3/<relations>
Relations:
[          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;
Graded Module R^2/<relations>
Relations:
[  x^2,   y^2],
[  x^2,   y*z],
[x^2*z, x*y^2]
> H, f := Hom(M, N);
> H;
Graded Module R^7/<relations> with grading [1, 2, 1, 1, 1, 1, 1]
Relations:
[x, 0, 0, -z, 0, x, 0],
[y, 0, x, 0, y, 0, 0],
[y, 0, x, 0, 0, y, 0],
[0, 0, 0, 0, 0, 0, y],
[-y, 0, -x, 0, -z, 0, z],
[x, 0, 0, -y, x, 0, 0],
[x*y, y, 0, 0, 0, 0, x*y],
[-x*y + x*z, -y + z, 0, 0, 0, 0, x*z - z^2],
[x*z, x, 0, 0, 0, 0, 0],
[0, y, 0, y^2, -z^2, 0, z^2],
[0, y - z, 0, 0, 0, 0, z^2]
> h := f(H.1);
> h;
Module homomorphism (3 by 2) of degree 1
Presentation matrix:
[0 z]
[x 0]
[0 0]
> $1 @@ f;
[1, 0, 0, 0, 0, 0, 0]
> Degree(M.1);
0
> h(M.1);
[0, z]
> Degree(h(M.1));
1
> f(Basis(H));
[
    Module homomorphism (3 by 2) of degree 1
    Presentation matrix:
    [0 z]
    [x 0]
    [0 0],
    Module homomorphism (3 by 2) of degree 2
    Presentation matrix:
    [   0 -z^2]
    [   0  y*z]
    [   0    0],
    Module homomorphism (3 by 2) of degree 1
    Presentation matrix:
    [ 0  0]
    [-y  0]
    [ x  0],
    Module homomorphism (3 by 2) of degree 1
    Presentation matrix:
    [ 0  0]
    [ 0 -y]
    [ 0  x],
    Module homomorphism (3 by 2) of degree 1
    Presentation matrix:
    [ 0 -z]
    [ 0  0]
    [ 0  y],
    Module homomorphism (3 by 2) of degree 1
    Presentation matrix:
    [ 0 -z]
    [ 0  0]
    [ 0  z],
    Module homomorphism (3 by 2) of degree 1
    Presentation matrix:
    [    0 y - z]
    [    0     0]
    [    0     0]
]

```
