In [this](http://arxiv.org/pdf/0809.1958v3.pdf) article by Iyama and Wemyss there is the following formula:
Let $R$ be a Cohen-Macaulay ring with canonical module $\omega$, let $X$ be a finitely generated $R$-module. Then
$$\mbox{depth}(X)=\dim{R}-\sup\{i\ge 0\ |\ \mbox{Ext}^i\_R(X,\omega)\not= 0\}.$$
I am not very familiar with this area, so possibly this is trivial, nevertheless I am looking for a proof of this formula. Possibly one also needs $R$ to be local and complete, which I am not sure about.



Depth formula in CM-ring involving canonical module
Put $d:=\dim R$. Grothendieck duality identifies the local cohomology group $H^i\_{\mathfrak{m}}(X)$ with the Matlis dual of 
$\mathrm{Ext}^{d-i}\_R(X, \omega )$ (the Matlis dual of a $R$-module $M$ is $\mathrm{Hom}\_R(M,I)$, where $I$ is an injective hull of the residual field). This implies your equality because by definition $\mathrm{depth}(X)=\inf \{i\,|\, H^i\_{\mathfrak{m}}(X)\neq 0\} $. A good reference for Grothendieck duality is Bourbaki *Algèbre Commutative* X, §10 (unfortunately not yet translated, as far as I know).


