Let $V$ be an affine variety and $g$ a polynomial function on $V$ and $D(g) \subseteq V$ its nonvanishing set. I am trying to show directly that the ring of regular functions on $D(g)$ - a regular function on $D(g)$ being a local quotient of polynomial functions on $V$ - are the localization of the regular functions on $V$ by the multiplicative set $\{1, g, g^2, \ldots \}$.
I have managed to show that the obvious association from the localization to the regular functions on $D(g)$ is injective:
If $\frac{f}{g^n} = 0$ as a regular function on $D(g)$, then $f = 0$ on $D(g)$ and since $g = 0$ on $V\setminus D(g)$, it follows that $gf = 0$ on $V$ and so $\frac{f}{g^n} = 0$ in the localization by definition.
But I can't see how to show surjectivity directly. If $a$ is a regular function on $D(g)$, then for every $x \in D(g)$ there are some regular functions on $V$ $p_x, q_x$ and an open $W_x \subseteq D(g)\cap D(q_x)$ such that $a = \frac{p_x}{q_x}$ on $W_x$. Since $V \setminus W_x$ is also an affine variety, I can find a regular function $h_x$ on $V$ such that $h_x = 0$ on $V \setminus W_x$, so then $a q_x h_x = p_x h_x$ on $V$. But I am stuck here. It seems like such an $h_x$ doesn't help at all, because it doesn't produce any link to the localization. This seems like the hardest part - somehow linking $a$ to the localization. Is this even doable directly?
As you say for each point you have some rational expression $a=p_x/q_x$. This expression holds in some neighborhood of $x$ which we denoted as $W_x=D(g)\cap D(q_x)$. The problem is how we can extend this to the whole of $D(g)$.
Now, we know that $D(g)$ has an open cover $D(g)=\cup_{x\in D(g)} W_x$. Because $D(g)$ is quasi-compact(not a trivial fact), we have $D(g)=\cup_{i=1}^n W_{x_i}$.
By taking complements, we see that $V(g)\supset \cap_{i=1}^n V(q_x)$. At the level of ideals, this translates to the statement, $\sqrt{(g)}\subset \sqrt{(q_{x_1},...,q_{x_n})}$.
So $g\in \sqrt{(q_{x_1},...,q_{x_n})}$ and $g^r=\sum_{i=1}^n \phi_i q_{x_i}$.
Now $$a\cdot \frac{g^r}{g^r}=a\sum_{i=1}^{n}\frac{\phi_iq_{x_i}}{g^r}$$
But $aq_{x_i}=p_{x_i}$ is a polynomial for each $x_i$. So, $$a=\sum_{i=1}^{n}\frac{p_{x_i}\phi_{i}}{g^r}$$. But the numerator is a polynomial.