In this article by Iyama and Wemyss there is the following formula: Let $R$ be a CohenMacaulay 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.

$\begingroup$ You don't need complete certainly, without local you need to be a bit careful about dimension (so it's probably safest to assume local unless you are finite type over a field). This formula though is certainly in Bruns and Herzog among other places (the chapter on canonical modules). $\endgroup$– Karl SchwedeSep 11 '14 at 14:22

$\begingroup$ Yes, that is exactly the book that I looked at first. I didn't find the formula there (Of course I might have missed it). But there is this other formula $\mbox{depth}(X)=\min\{i\ \ \mbox{Ext}^i_R(k,X)\not=0\}$. Thus there is probably some duality involved. $\endgroup$– Lars KastnerSep 11 '14 at 14:48

$\begingroup$ This is already answered below by abx, but let me give the right references in Bruns and Herzog too. See Corollary 3.5.11. $\endgroup$– Karl SchwedeSep 12 '14 at 3:06

$\begingroup$ Ah, thank you. So I definitely need local, but not necessarily complete. $\endgroup$– Lars KastnerSep 12 '14 at 9:49
Put $d:=\dim R$. Grothendieck duality identifies the local cohomology group $H^i_{\mathfrak{m}}(X)$ with the Matlis dual of $\mathrm{Ext}^{di}_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).