Let $A$ be any ring, commutative with identity, and let $I\subset A$ be an ideal $\neq A$. Let $U\subset{\rm Spec}(A)$ be the open subscheme obtained by "removing" the closed set $V(I)$ of all the prime ideals of $A$ containing $I$. Is there a criterion on the ideal $I$ that enables one to decide whether $U$ is an affine scheme?

$\begingroup$ This was discussed here: mathoverflow.net/questions/20782/… $\endgroup$ – Martin Brandenburg Sep 25 '10 at 9:04

5$\begingroup$ Assume $U$ is qcompact; equivalently, choose $I$ finitely generated. Inclusion $j:U \rightarrow X := {\rm{Spec}}(A)$ is a qcompact open immersion, so $j_{\ast}(F)$ is qcoh. on $X$ for all qcoh. $F$ on $U$. Restricting back to $U$ gives $F$, so $F = \widetilde{M}_U$ for an $A$module $M$. Then by excision ${\rm{H}}^i(U,F) = {\rm{H}}^i(U,\widetilde{M}) = {\rm{H}}^{i+1}_{XU}(X,\widetilde{M}) = \injlim {\rm{Ext}}^{i+1}(A/I^n,M)$ (limit over $n \rightarrow \infty$), final equality since $I$ f. gen'td (univ. $\delta$functor argument). Vanishing for $i > 0$ and all $M$ seems "impractical"... $\endgroup$ – BCnrd Sep 25 '10 at 9:11

2$\begingroup$ A necessary condition: $I$ has to be of pure codimension one (see e.g. jstor.org/pss/1970814) $\endgroup$ – auniket Sep 25 '10 at 10:12

$\begingroup$ In fact, BCnrd's argument implies aniket's as well (at least in sufficiently geometric settings). This is because $H^{i+1}_{X\setminus U}(X, \widetilde{M})$ is nonzero at the generic points of $X \setminus U$ for appropriate $i$ (depending on the dimension of those generic points). $\endgroup$ – Karl Schwede Sep 25 '10 at 21:53
This question has been studied on and off for a while. As pointed out in the comments, an interesting necessary and sufficient condition in full generality will be hard to find, but there are many related results in different directions. Here are two references:
Holger Brenner: "On superheight conditions for the affineness of open subsets".
Amnon Neeman: "Steins, Affines and Hilbert's Fourteenth Problem"
For example, 4.4 of the first paper (see also 5.5 of the second) states that if $A$ is a domain of finite over $\mathbb C$ and $U\subset X = \text{Spec} A$ open such that $\Gamma(U,\mathcal O_X)$ is a finite generated $\mathbb C$algebra. Then $U$ is affine iff $U^{an}$ is Stein.
Here is a simple necessary condition that is of interest to some algebraists. For simplicity I will assume our rings are Noetherian. Since preimage of affine is affine, one conclude that for any ring homomorphism $A\to B$, the ideal $IB$ also has height one. This gives simple nonexamples. Take $A=k[x,y,u,v]/(xuv)$, $I=(x,y)$, $B=A/(u,v)=k[x,y]$. Then the height of $IB$ is $2$, so $U$ can't be affine.
The condition that the height of $I$ remains at most one in all extensions is called "$I$ has superheight one". Krull's Hauptidealsatz can be viewed as saying the superheight of $I=(T)$ in $\mathbb Z[T]$ is one! This point of view leads to many nontrivial generalizations, and some of the most notorious open questions in the field can be stated as a very simple question involving superheights.