Let $R[[X,Y,Z]]/(X,Y)\cap (Y,Z)\cap(X,Z)$. then $R$ is Cohen-Macaulay ring and has a canonical
module, $K$. By [Proposition 3.3.18](https://books.google.com/books?id=LF6CbQk9uScC&pg=PA116&dq=Proposition+3.3.18+Let+R+be+a+Cohen%0CMacaulay+ring+and&hl=en&sa=X&ei=6dDoVPmfGsblaK2tgYAG&ved=0CB8Q6AEwAA#v=onepage&q=Proposition%203.3.18%20Let%20R%20be%20a%20Cohen%0CMacaulay%20ring%20and&f=false) of *Bruns\_Herzog*, $K$ can be identified with an ideal in $R$. 
So we know that *there Is* an ideal, but *how can one reach* that ideal? Is there a general way for reaching the ideal in Proposition 3.3.18? 


thank you.



canonical module can be identified with an ideal. how can one reach that ideal?
Well, there is a non-canonical way.


*try random embeddings until it works.* 


Let me explain.


Strategy
--------


Say we are given a module $M$ with generators $x\_1, \ldots, x\_n$. We know that the module is an ideal (by some general nonsense) but we don't know how to embed it as an ideal of $R$. Thus we need to consider maps $\phi : M \to R$ and in particular, we need to cook up an injective map. 


Consider a presentation $R^m \xrightarrow{A} R^n \to M$, here we view $A$ as a matrix. The module $R^m$ maps surjectively onto the relations between the generators $x\_i$. For instance $a\_{1j}x\_1 + \ldots + a\_{nj} x\_n = 0$ is such a relation -- the columns of $A$ are exactly said relations. 


So we look for elements $z\_1, \ldots, z\_n \in R$ that satisfy those same relations. Fortunately, this is quite easy. Consider the relations between the rows of $A$. This would be something of the form $z\_1 {\bf a}\_1 + \ldots + z\_n {\bf a}\_n = 0$. The $z\_i$ are then *exactly* a potential target for the generators $M$ to be sent. The map $\kappa\_{z\_1, \ldots, z\_n} : M \to R$ sending the $x\_i$ to the $z\_i$ will certainly be well defined (since the $z\_i$ satisfy the same relations as the $x\_i$). The problem is that $\kappa$ might not be injective (and if one makes the obvious choices in your example, it won't be). Of course if $\kappa$ is nonzero and the target is a domain, you are fine.


Regardless, there are other choices of relations, and if one makes a general choice of relation (say a general linear combination of a generating set of the relations between the generators of the rows of $A$) then the induced map will be injective. 


Implementation
--------------


In fact it has even been implemented into Macaulay2. In that implementation, we first try embeddings based on one set of generators for the relations between the rows, and if none of those work we try random combinations (the default setting is to try 10 times). The key command here that gets the relations between the rows of the matrix in Macaulay2 is:



> 
> entries transpose syz transpose presentation M2
> 
> 
> 


Here is a sample execution which should work on Macaulay2 1.7 or later. Roughly speaking, we proceed as follows. First we construct the canonical module $M$, then we tell Macaulay2 to view it as an $R$-module (here \*\* means tensor product)



> 
> loadPackage "Divisor"
> 
> 
> S = QQ[x,y,z]
> 
> 
> I = ideal(x \* y, x \* z, y \* z)
> 
> 
> R = S/I
> 
> 
> M = Ext^2(S^1/I, S^1)
> 
> 
> M = M \*\* R
> 
> 
> moduleToIdeal(R, M)
> 
> 
> 


In this case I got Macaulay2 to output:



> 
> ideal (95981051y + 69595843z, 47476200x - 461878963z)
> 
> 
> 


Which is about the same as what Richard Stanley mentioned in the comments. 


###  Warning


By the way, the version of this function in the "Divisor" package in Macaulay2 has a bug where it won't give up if you try to embed something that isn't an ideal, as an ideal. 


An updated version is available on my website [HERE](http://www.math.utah.edu/~schwede/M2/Divisor.m2) 


If you don't have Macaulay 1.7, this file should also be usable in 1.6.


### Bibliography


Versions of this have been implemented in Macaulay2 for a long time (in particular, see the tutorial [on Divisors](http://www.math.uiuc.edu/Macaulay2/doc/Macaulay2-1.6/share/doc/Macaulay2/Macaulay2Doc/html/___Tutorial_co_sp__Divisors.html) here). It was also done in work of Moty Katzman [here](http://katzman.staff.shef.ac.uk/FSplitting/ParameterTestIdeals.m2).


