Example 26.9.3. Let $k$ be a field. An example of a scheme which is not affine is given by the open subspace $U = \mathop{\mathrm{Spec}}(k[x, y]) \setminus \{ (x, y)\}$ of the affine scheme $X =\mathop{\mathrm{Spec}}(k[x, y])$. It is covered by two affines, namely $D(x) = \mathop{\mathrm{Spec}}(k[x, y, 1/x])$ and $D(y) = \mathop{\mathrm{Spec}}(k[x, y, 1/y])$ whose intersection is $D(xy) = \mathop{\mathrm{Spec}}(k[x, y, 1/xy])$. By the sheaf property for $\mathcal{O}_ U$ there is an exact sequence

$0 \to \Gamma (U, \mathcal{O}_ U) \to k[x, y, 1/x] \times k[x, y, 1/y] \to k[x, y, 1/xy]$

We conclude that the map $k[x, y] \to \Gamma (U, \mathcal{O}_ U)$ (coming from the morphism $U \to X$) is an isomorphism. Therefore $U$ cannot be affine since if it was then by Lemma 26.6.5 we would have $U \cong X$.

In your comment you can use Markdown and LaTeX style mathematics (enclose it like $\pi$). A preview option is available if you wish to see how it works out (just click on the eye in the toolbar).