# ideals to and from modules

## from ideals to modules

An ideal I is also an R-submodule. In Macaulay2 we distinguish between when we are thinking of I as as ideal or a module. If it is first defined as an ideal, it is easily turned into a module using the function module and for any submodule of the rank one free module R we can obtain an ideal of the generators using the function ideal.
 i1 : R = ZZ/32003[x,y,z]; i2 : I = ideal(x^2,y*z-x); o2 : Ideal of R i3 : module I o3 = image | x2 yz-x | 1 o3 : R-module, submodule of R

## from modules to ideals

For any submodule of the rank one free module R we can obtain an ideal of the generators using the function ideal.
 i4 : A = matrix{{x*y-z,z^3}}; 1 2 o4 : Matrix R <--- R i5 : M = image A o5 = image | xy-z z3 | 1 o5 : R-module, submodule of R i6 : ideal M 3 o6 = ideal (x*y - z, z ) o6 : Ideal of R

## getting the quotient module corresponding to an ideal

We also often work with R/I as an R-module. Simply typing R/I at a prompt in Macaulay2 constructs the quotient ring (see quotient rings). There are two ways to tell Macaulay2 that we want to work with this as a module.
 i7 : coker generators I o7 = cokernel | x2 yz-x | 1 o7 : R-module, quotient of R i8 : R^1/I o8 = cokernel | x2 yz-x | 1 o8 : R-module, quotient of R

## modules versus ideals for computations

Some functions in Macaulay2 try to make an informed decision about ideal and modules. For example, if resolution is given an ideal I, it will compute a resolution of the module R^1/I, as in the following example.
 i9 : resolution I 1 2 1 o9 = R <-- R <-- R <-- 0 0 1 2 3 o9 : ChainComplex
The functions dim and degree also operate on R^1/I if the input is I or R^1/I. However, the function hilbertPolynomial computes the Hilbert polynomial of the module I if the input is hilbertPolynomial I.

For basic information about working with modules see modules.