Hint One way to produce a (real) polynomial $p$ that only takes nonnegative values is to write a sum of squares $$p(x, y) := q(x, y)^2 + r(x, y)^2,$$ and we can ensure that the sum is always positive by insisting that the squared quantities $q(x, y), r(x, y)$ are never simultaneously zero. On the other hand, we can ensure that the $p$ takes on arbitrarily small positive values by choosing
- $r$ to be identically zero on some curve $\gamma \subset \mathbb{R}^2$ (for suitable $r$ we can just take $\gamma$ to be the curve defined by $r(x, y) = 0$), and
- $q$ that takes on arbitrarily small positive values along $\gamma$.
(Of course, since $q, r$ cannot be simultaneously zero, $q(\gamma)$ cannot contain its infimum, and hence the curve $\gamma$ cannot be compact.)
Solution One simple noncompact curve is the hyperboloid $x y = 1$, and by construction $$r(x, y) := x y - 1$$ vanishes identically there. On the other hand, we can parameterize one arc of this hyperboloid by $\gamma: s \mapsto (\frac{1}{s}, s)$, $s > 0$. Along this curve, we thus have $$p(\gamma(s)) = p\left(\frac{1}{s}, s\right) = q\left(\frac{1}{s}, s\right)^2 + r\left(\frac{1}{s}, s\right)^2 = q\left(\frac{1}{s}, s\right)^2.$$ Now, $q\left(\frac{1}{s}, s\right)^2$ will take on arbitrarily small positive values---but no nonpositive values---if we take, e.g., $$q(x, y) := x.$$ Thus, by construction $$p(x, y) = q(x, y)^2 + r(x, y)^2 = x^2 + (xy - 1)^2$$ has the desired properties.
Remark Since for any nonconstant one-variable polynomial $u(x)$ we have $\lim_{x \to \infty} u(x) = \infty$ or $\lim_{x \to \infty} u(x) = -\infty$, and likewise for the limits as $x \to -\infty$, the Heine-Borel Theorem implies that $u$ assumes any finite infimum or supremum, that is, the phenomenon in this problem only occurs for real functions of at least two variables.