Q:

Inverse element in the function field of an affine variety

First of all I want to mention all the definitions of our lecture, so there will be no misunderstanding:
Let $X \subset \mathbb{A}_k^n$ be an affine variety, meaning $X$ is irreducible and closed with respect to the Zariski topology. We call a function $f: X \to k$ regular in a point $P \in X$ if there exists an open neighbourhood $U$ of $P$ such that $f(Q) = \frac{g(Q)}{h(Q)}$ for all $Q \in U$ where $g,h \in k[x_1,\dots,x_n]$ and $h(Q) \neq 0$ for all $Q \in U$. The function is called regular in $X$ if it is regular in every point of $X$.
The function field of $X$ is defined as
$k(X) = \{ (U,f) \, | \, U \subset X \text{ open and non-empty }, f: U \to k \text{ regular} \}/\sim$
where $\sim$ is the following equivalence relation
$(U,f) \sim (V,g) :\Longleftrightarrow f(Q) = g(Q) \text{ for all } Q \in U \cap V$.
Now my problem: My professor says that $k(X)$ is indeed a field, so every non-zero element has an inverse. The inverse of such an element $[(U,f)]$ is given by 
$ \left[\large(U \cap \big(X \setminus V(f)\big), f^{-1} \large)\right] $.
But I do not understand what $f^{-1}$ means in this context:
It is not the inverse function of $f$ because the inverse function would map from $f(U) \subset k$ to $U \subset X$. But this makes no sense because $k$ and $X$ are completely different sets. And in general, the function $f$ is not bijective.
Could someone please explain what $f^{-1}$ means in this context?
I would be glad if someone could help me out with this. Thank you!

A:

Consider the restriction of $f$ to $U\cap (X\setminus V(f))$. Clearly by definition, $f$ is nonzero on this set, and since we are dealing with rational functions, this means that $f$ has an inverse on this set. Precisely, if for $Q\in U\cap(X\setminus V(f))$ we have $f(Q)=\frac{g(Q)}{h(Q)}$, then $f^{-1}(Q)=\frac{h(Q)}{g(Q)}$. Therefore, if we call this element $f^{-1}$ (note that strictly speaking, we're abusing notation a bit here), then $(U\cap(X\setminus V(f)),f^{-1})$ gives an inverse for $f$ in $k(X)$.

