Let $f(x,y)$ be a polynomial in $\mathbf R[x, y]$ such that $f(x, x^3) = 0$ for all $1< x< 2$.
Question. Then is it necessary that $f(x, x^3) = 0$ for all $x$?
(As pointed out by @dvix in the comments, this question has answer YES. The reason is that $f(x, x^3)$ is a single variabel polynomial vanishing on infinitely many points, and hence must be identically zero).
More generally what I want to know is the following:
Question. Suppose $X\subseteq \mathbf R^n$ is an irreducible affine variety and $f\in \mathbf R[x_1, \ldots, x_n]$ be a polynomial which vanishes on an open subset of $X$. Then is it forced that $f$ vanishes on all of $X$. Or at least on all smooth points of $X$?
Here "open" is with respect to Euclidean topology.
In the following, when we write $\dim$, we mean dimension as a topological space, and when we write varieties, we mean schemes of finite type over a field, and when we write $\dim$ of a scheme, we mean dimension of the associated topological space.
Let $U\subset X(\Bbb R)$ be the open set on which $f$ vanishes. $f=0$ is a closed set in $X$, so if $X$ is reduced and $U$ is of dimension $\dim X$, then $f$ must be identically zero ($\{f=0\}$ is a closed set containing $U$, so $\dim \{f=0\} \geq \dim U=\dim X$, and the only closed subset of an irreducible, reduced variety of dimension $\dim X$ is $X$).
It is important that $\dim U = \dim X$: it may happen that $\dim U < \dim X$, such as the case when $X = V(x^2-y^2z)$ - here, $X$ is two-dimensional, irreducible, and reduced, but it is possible to pick a $U\subset X(\Bbb R)$ which is open but has dimension 1: consider $X(\Bbb R)\cap ((-1,1)\times(-1,1)\times(-2,-1)).$ If $U$ consists entirely of smooth points, you are ensured that $\dim U=\dim X$, by the implicit function theorem.