TITLE: Open affine subscheme of affine scheme which is not principal
QUESTION [49 upvotes]: I'm not sure whether this is non-trivial or not, but do there exist simple examples of an affine scheme $X$ having an open affine subscheme $U$ which is not principal in $X$? By a principal open of $X = \mathrm{Spec} \ A$, I mean anything of the form $D(f) = \{\mathfrak p \in \mathrm{Spec} \ A : f \notin \mathfrak p\}$, where $f$ is an element of $A$.

REPLY [2 votes]: Here is an example that may be considered easier than Hailong Dao's. (At least it is one dimensional smaller!)
Consider the ring $R=\mathbb{Z}[x,y,z]/\langle xy-z(z-1)\rangle$ and the ideal $I=\langle x,z\rangle$.
The ideal $I$ is not the radical of a principal ideal. So the complement of $\mathrm{Spec}(R/I)$ in $\mathrm{Spec}(R)$ is not $R_r$ for any $r$ in $R$.
In fact, this complement is given by the ring homomorphism $R\to S=\mathbb{Z}[x,t]$ where $z\mapsto 1+xt$ and $y\mapsto (1+xt)t$. In other words, the complement is $\mathrm{Spec}(S)\to\mathrm{Spec}(R)$ via this ring homomorphism.
To see this, let $f:R\to A$ be a ring homomorphism such that $f(x)$ and $f(z)$ generate the unit ideal. This means $af(x)+bf(z)=1$ for some $a,b\in A$.
Now, let $\tilde{f}(t)=a(f(z)-1)+bf(y)$. One checks that this extends $f$ to $\tilde{f}:S\to A$.