Ring of Regular functions on $\Bbb{A}^2 - \{(0,0)\}$ Suppose I want to determine the ring of regular functions on  $U = \Bbb{A}^2 - \{(0,0)\}$. Now I can do this assuming the following fact:


Fact: If $f$ is regular on $U$, then we can write $f = g/h$ with $g,h$ polynomials in $k[x,y]$ such that $h(p) \neq 0$ on all of $U$. 


How does this come from the definition of $f$ being regular on $U$? The definition (at least the one given in Hartshorne 1.3 ) is:


Definition: Let $Y$ be an open subset of an affine variety. A function $f : Y \to k$ is regular at $P \in Y$ if there is an open neighbourhood $V$ with $P \in V \subseteq Y$ and polynomials  $g,h \in k[x_1,\ldots,x_n]$ such that $h$ is non-zero on $U$ and $f = g/h$ on $V$. We say $f$ is regular on $Y$ if it is regular at every point in $Y$.


Now I am a little confused as to how the fact I claim comes from this definition. In my mind, I have the following hazy interpretation.


My thoughts: Suppose we pick any open subset $W \subseteq U = \Bbb{A}^2 - \{(0,0)\}$. Then I can write $f = g/h$ for some polynomials $g,h$ at least on $W$. I claim that that actually $f = g/h$ on the whole of $U$. Indeed, pick any other non-empty open subset $W' \subseteq U$ and suppose $f = g'/h'$ on $W'$. Then because $W,W'$ are two dense open subsets they have a non-empty intersection, so that when we restrict to $W \cap W'$, 
    $$ \frac{g}{h}= f|_{W \cap W'}  = \frac{g'}{h'}.$$
    Thus $g/h $ and $g'/h'$ agree on a dense open subset and thus are equal on all of $U$. So it makes sense to set $f = g/h$ on all of $U$.


I think my understanding is correct, but I'm interested in different ways of understanding the fact I quote above.
 A: Let $r\in k(x,y).$ Define $J_r := \{ G\in k[X,Y] \mid \overline{G} r \in k[X,Y] \}.$ Then the pole set of $r$ is $V(J_r).$ If $r$ was regular on $U$ but not $\mathbb{A}^2$ then we would have $V(J_r) = V(X,Y) \implies \sqrt{J_r}=(X,Y).$ This implies that there are integers $m,n$ such that $$r= \frac{f_1(x,y)}{x^n} = \frac{f_2(x,y)}{y^m}$$ where $x, y$ are comprime to $f_1, f_2$ respectively, which contradicts the UFD property of $k[X,Y].$
A: You don't need the fact. $\mathbb{A}^2 \setminus \{0\}$ is covered by $\{x \neq 0\}$ and $\{y \neq 0\}$, which are affine and have as ring of regular functions $k[x,y,x^{-1}]$ and $k[x,y,y^{-1}]$. Thus, (by the sheaf property) the ring of regular functions on $\mathbb{A}^2 \setminus \{0\}$ is $k[x,y,x^{-1}] \cap k[x,y,y^{-1}]=k[x,y]$ (using that $k[x,y]$ is UFD and $x,y$ are coprime).
A: Here is a slightly different approach, which is perhaps a little more intuitive, and in fact vindicates the fact you state at the beginning of your question (and is probably what Gathmann had in mind in his notes).

A regular function on a non-empty open subset $U$ is certainly a rational function on $\mathbb A^2$, so we can write is a ratio of polynomials $f/g$,
which we may as well assume are in lowest terms (using the fact that polynomials form a UFD).
Now at each point $P$ of $U$, we have some rational function $f_P/g_P$ representing our regular function, where $g_P(P) \neq 0$.  Now $f_P/g_P$ must be equal to $f/g$ as a rational function, and so (since $f/g$ was chosen to be in lowest terms) we see that $g$ divides $g_P$, and hence that $g(P) \neq 0$.
Applying this to every $P \in U$, we find that $g$ is non-zero on $U$, and so we have proved your fact.

Note though that this doesn't follow just from the definition of regular function.  It also uses the fact that the ring of functions on $\mathbb A^2$ is a UFD.  So if we were to replace $\mathbb A^2$ by a more complicated smooth affine surface $S$, it would still be true that the regular functions on $S$ minus a point coincide with the regular functions on $S$, but this argument wouldn't apply (at least not directly).
So the argument Martin gives is somehow more canonical: he just computes $\mathcal O(U)$ directly by covering $U$ with distinguished affine opens and
then intersecting the ring of functions on each of those inside the rational function field.  This is a procedure you can apply (in principal) to compute
the regular functions on any open subset of any variety.  (You can see it being applied, for example, in the proof of Thm. I.3.4(a) of Hartshorne.) It also foreshadows the Cech approach to computing cohomology.
A: As an absolute beginner reading Hartshorne, I would like to provide a very basic and detailed proof for people of similar background.
Claim: if $X\subseteq \mathbb{A}^n$ is quasi-affine variety such that $\overline{X}=\mathbb{A}^n$, then any $f\in\mathcal{O}_{X}$ is equal to $\frac{g}{h}$ on $X$ for some $g,h\in k[x_1,...,x_n]$, $h$ vanishes nowhere on $X$.
Proof: The closure of a quasi variety is the unique variety which contains the quasi variety as an open subset. In particular, $X$ is open in $\mathbb{A}^n$. Take any $f\in\mathcal{O}_{X}$, $p\in X$. Then there exists $U$ open in $X$ (thus open in $\mathbb{A}^n$) containing $p$ such that $f=\frac{g}{h}$ as function on $U$, where $g,h\in k[x_1,...,x_n]$ and $h$ is nowhere zero on $U$. Assume $\gcd(g,h)=1$. Take any other point $p'\in X$, then there exists $U'$ open in $X$ (thus open in $\mathbb{A}^n$) containing $p'$ such that $f=\frac{g'}{h'}$ on $U'$ where $g',h'$ are polynomials and $h'$ does not vanish on $U'$. Assume $\gcd(g',h')=1$.
Because $X$ is irreducible, any two nonempty open subsets must have nonempty intersection, so $\frac{g}{h}=\frac{g'}{h'}$ as functions on $U\cap U'\neq\emptyset$. Then $gh'-g'h=0$ as a function on $U\cap U'\neq\emptyset$. But $gh'-g'h$ is a polynomial, so $Z(gh'-g'h)\supseteq \overline{U\cap U'}=\mathbb{A}^n$, so $gh'-g'h\in I(\mathbb{A}^n)=0$, so $gh'=g'h$ as polynomials. (Note the passage from function (which takes value) to polynomial (which is an algebraic construction) indeed depends on $\overline{X}=\mathbb{A}^n$.) But we have $\gcd(g,h)=\gcd(g',h')=1$, so algebra tells us $h'=ch,g'=cg$ for some unit $c$. In particular, $h$ vanishes nowhere on $U'$, and as function, $f=\frac{cg}{ch}=\frac{g}{h}$ on $U'$. $\square$
Using this claim, we can easily see that the map $k[x,y]\to \mathcal{O}_{\mathbb{A}^2-\{(0,0)\}}$ defined by restriction of function is surjective (Essentially because a polynomial function nonvanishing on $\mathbb{A}^2-\{(0,0)\}$ must be constant, as $k$ is algebraically closed). Injectivity is also easy. So we are done.
