Regular function on a variety which is not globally rational

I am looking for a particularly simple example of a regular function $f : V \to \mathbb{A}^1_k$ for some affine variety $V \subseteq \mathbb{A}^n_k$ over a field $k$, which cannot be expressed by a single rational function of $k(X_1, \dots, X_n)$.

Is there such an example if we choose $V = V(X^2+Y^2-1)$ to be the unit circle?

Added later: By "expressed" I mean "expressed as a map between sets". The converse question is: Do we find for any regular $f : V \to \mathbb{A}^1_k$ two polynomials $p,q \in k[X_1,\dots,X_n]$ such that $q$ has no zeros in $V$, and $f(x) = \frac{p(x)}{q(x)}$ holds for all $x \in V$?

Context: If we allow $V$ to be quasi-affine then there is such an example: Let $V = \{ (x,y) \in \mathbb{A}^2_k : x^2+y^2=1, (x,y) \neq (0,-1) \}$ and $f : V \to \mathbb{A}^1_k$ with $f(x,y) = \frac{1-y}{x}$ for $x \neq 0$ and $f(x,y) = \frac{x}{1+y}$ for $y \neq -1$. This function is well defined and regular. Of course the rational functions $\frac{1-y}{x}$ and $\frac{x}{1+y}$ represent the same element of $k(V)$ but I doubt that we can define $f$ by a single rational equation.

Am I understanding right from the comments that there is no analogous example in the case of a variety?

• What are the $X_i$? By first principles, giving a morphism $f:V\to \mathbb{A}^1_k$ is the same as giving an element of $\mathcal{O}_V(V)$. – Alex Youcis Aug 22 '14 at 10:50
• @AlexYoucis: The $X_i$ are indeterminates. I am asking for a morphism, which cannot be described as a function by an equation $f(x) = \frac{p(x)}{q(x)}$ for some polynomials $p,q$ and for all $x \in V$. This means we cannot choose any such polynomial $q$ without zeros in $V$. – Dune Aug 22 '14 at 11:18
• As Alex Youcis pointed out, what you are asking for is impossible: a morphism to $\mathbb{A}^1$ from a closed subvariety always extends to the ambient. The next best thing you can have is a morphism to $\mathbb{P}^1$: for this, take $\frac{Y}{1+X} = \frac{1-X}{Y}$ on the unit circle. – Gro-Tsen Aug 22 '14 at 11:33
• If $V$ is affine then there is a natural bijection between the regular functions $V \to \mathbb{A}^1$ and the elements of the coordinate ring of $V$. (If $V$ is projective then the only regular functions $V \to \mathbb{A}^1$ are constants.) – Zhen Lin Aug 22 '14 at 13:03
• The only thing to prove is what I said in my first comment, which you seem to already know. – Zhen Lin Aug 22 '14 at 14:11