Let $X$ be a closed subset of $\mathbb{A}^n$ (with ground field $k$) and $f\in k[T_1,...,T_n]$. Let $V(f)$ denote the zeros of $f$ and $D(f)$ denote $X\backslash V(f)$. How can I prove that $k[D(f)]=k[X][f^{-1}]$? According to Shararevich, I should be able to prove this using the fact that $D(f)$ is isomorphic to the closed set $Z$ in $\mathbb{A}^{n+1}$ defined by the equations defining $X$ plus the equation $f(T_1,...,T_n)T_{n+1}=1$. But I don't know how to give a rigorous proof.
Thanks in advance.
$D(f)$ is an affine variety because it is isomorphic to a closed subset of $\mathbb{A}^{n+1}$ according to the construction you mentioned. Explicitly, suppose $G_1=\cdots=G_m=0$ are the equations of $X\subset \mathbb{A}^n$, then $D(f)\subset \mathbb{A}^{n+1}$ is the vanishing locus of the following polynomials \begin{align*} F_i(t_1,\ldots,t_{n+1})&:=G_i(t_1,\ldots,t_n)\quad i=1,\ldots,m\\ F_{m+1}(t_1,\ldots,t_{n+1})&:=f(t_1,\ldots,t_n)t_{n+1}-1. \end{align*}
In this case, the regular functions on $D(f)$ is given by $$k[D(f)]:=\frac{k[t_1,\ldots,t_{n+1}]}{(F_1,\ldots,F_{m+1})}=\frac{k[t_1,\ldots,t_n][t_{n+1}]}{(G_1,\ldots,G_m,ft_{n+1}-1)}\cong \frac{k[t_1,\ldots,t_n]}{(G_1,\ldots,G_m)}[t_{n+1}]/(ft_{n+1}-1)\cong k[X][f^{-1}],$$ where the nontrivial isomorphism could be proven by computing the kernel of $$\Phi:k[t_1,\ldots,t_n][t_{n+1}]\overset{}{\to} \frac{k[t_1,\ldots,t_n]}{(G_1,\ldots,G_m)}[t_{n+1}]\overset{}{\to} \frac{k[t_1,\ldots,t_n]}{(G_1,\ldots,G_m)}[t_{n+1}]/(ft_{n+1}-1).$$