# subquotient modules -- the way Macaulay2 represents modules

Not all modules arise naturally as submodules or quotients of free modules. As an example, consider the module M = I/I2 in the example below.
 `i1 : R = QQ[x,y,z];` ```i2 : I = ideal(x*y,x*z,y*z) o2 = ideal (x*y, x*z, y*z) o2 : Ideal of R``` ```i3 : M = I/I^2 o3 = subquotient (| xy xz yz |, | x2y2 x2yz xy2z x2z2 xyz2 y2z2 |) 1 o3 : R-module, subquotient of R```
Macaulay2 represents each module (at least conceptually) as a subquotient module, that is, a submodule of a quotient of an ambient free module. A subquotient module is determined by two matrices f : Rm → Rn and g : Rp → Rn. The subquotient module with generators f and relations g is by definition the module M = ((image f) + (image g))/(image g).

If f is the identity map, M = coker g, and if g = 0, then M = image f. The class of subquotient modules is the smallest class containing free modules, which is closed under taking submodules and quotients.

One may create a subquotient module directly from matrices f and g having the same target free module.

 ```i4 : f = matrix{{x,y}} o4 = | x y | 1 2 o4 : Matrix R <--- R``` ```i5 : g = matrix{{x^2,x*y,y^2,z^4}} o5 = | x2 xy y2 z4 | 1 4 o5 : Matrix R <--- R``` ```i6 : M = subquotient(f,g) o6 = subquotient (| x y |, | x2 xy y2 z4 |) 1 o6 : R-module, subquotient of R```
The same module can be constructed in the following manner.
 ```i7 : N = (image f)/(image g) o7 = subquotient (| x y |, | x2 xy y2 z4 |) 1 o7 : R-module, subquotient of R``` ```i8 : N1 = (image f + image g)/(image g) o8 = subquotient (| x y x2 xy y2 z4 |, | x2 xy y2 z4 |) 1 o8 : R-module, subquotient of R``` ```i9 : M === N o9 = true```
Notice that Macaulay2 allows one to write (image f)/(image g), even though mathematically this really means: (image f + image g)/(image g). There is an important difference however. Modules in Macaulay2 always come with an ordered set of generators, and N1 has 4 more generators (all zero in the module!) than N. The modules M and N though are identical.

The two matrices f and g mentioned above are recovered using the routines generators(Module) and relations(Module).

 ```i10 : generators M o10 = | x y | 1 2 o10 : Matrix R <--- R``` ```i11 : relations M o11 = | x2 xy y2 z4 | 1 4 o11 : Matrix R <--- R```

Submodules and quotients of free modules work as one would imagine.

 ```i12 : N2 = R*M_0 + I*M o12 = subquotient (| x x2y xy2 x2z xyz xyz y2z |, | x2 xy y2 z4 |) 1 o12 : R-module, subquotient of R``` ```i13 : M/N2 o13 = subquotient (| x y |, | x x2y xy2 x2z xyz xyz y2z x2 xy y2 z4 |) 1 o13 : R-module, subquotient of R``` ```i14 : prune(M/N2) o14 = cokernel {1} | y x z4 | 1 o14 : R-module, quotient of R```

Given a subquotient module M, there are several useful modules associated to M.The free module of which M is a subquotient is obtained using ambient(Module).

 ```i15 : ambient M 1 o15 = R o15 : R-module, free```
This is the same as the common target of the matrices of generators and relations.
 ```i16 : ambient M === target relations M o16 = true``` ```i17 : ambient M === target generators M o17 = true```
M is a submodule of the module R^n/(image g). The routine super(Module) returns this quotient module.
 ```i18 : super M o18 = cokernel | x2 xy y2 z4 | 1 o18 : R-module, quotient of R```
This may be obtained directly as the cokernel of the matrix of relations.
 ```i19 : super M === cokernel relations M o19 = true```
Often the given representation of a module is not very efficient. Use trim(Module) (missing documentation) to keep the module as a subquotient of the same ambient free module, but change the generators and relations to be minimal, or in the nonlocal or non-graded case, at least more efficient.
 ```i20 : M + M o20 = subquotient (| x y x y |, | x2 xy y2 z4 |) 1 o20 : R-module, subquotient of R``` ```i21 : trim (M+M) o21 = subquotient (| y x |, | y2 xy x2 z4 |) 1 o21 : R-module, subquotient of R```
Use minimalPresentation(Module) to also allow the ambient free module to be improved. This currently returns a quotient of a free module, but in the future it might not.
 ```i22 : minimalPresentation M o22 = cokernel {1} | y x 0 0 z4 0 | {1} | 0 0 y x 0 z4 | 2 o22 : R-module, quotient of R```
prune is a synonym for minimalPresentation.
 ```i23 : prune M o23 = cokernel {1} | y x 0 0 z4 0 | {1} | 0 0 y x 0 z4 | 2 o23 : R-module, quotient of R```
For maps between modules, including between subquotient modules, see homomorphisms (maps) between modules.