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.