TITLE: Function that returns negative number for negative x and y
QUESTION [7 upvotes]: I need a function, $$f(x,y):\mathbb{R} \times \mathbb{R} \rightarrow \mathbb{R} $$, that returns negative a number only if both x and y are negative. It can use only the four basic operations, so for example computing the absolute value or square root are not allowed.
I only found solution using the absolute value:
$$ -(x-|x|)*(y-|y|)$$
Is it possible with only the four basic operation (+, -, *, and/)? And if it isn't, why?

REPLY [12 votes]: If you are restricted to the four basic operations, all you can get is a rational function $f(x,y)=\frac{p(x,y)}{q(x,y)}$ where $p,q$ are polynomials in $x$ and $y$.
Since we want $f$ to be defined everywhere, $q$ must not have zeroes, so we may assume wlog. that $q(x,y)>0$ for all $x,y$. This allows us to use simply $f(x,y)=p(x,y)$, i.e. a polynomial.
If your assignment formulation really reads "only if", you can simply take $f(x,y)=0$, which never returns negative values; or try something more interesting such as $(x+1)^2+(y+1)^2-1$, which at least becomes negative for some points in the thord quadrant, but never in the other quadrants.
If what you want is "if and only if", however, there is no such polynomial $p$: If one plugs in an arbitrary constant $c\in\mathbb R$ for $y$, one obtains an univariate polynomial $f_c(x)=p(x,c)$ and $\deg f_c$ is the same for all $c$ with at most finitely many exceptions: If we write $p(x,y)=\sum_{i,j}a_{i,j}x^iy^j$ (where only finitely many $a_{i,j}$ are nonzero), let $d=\max\{\,i\mid a_{i,j}\ne 0\,\}$. Then $\deg f_c\le d$ for all $c$ and the inequality is strict only if $c$ is among the fintely many solutions of $\sum_{i=d}a_{i,j}c^j=0$. 
But for the desired condition, we need that $\deg f_c$ is even for all $c\ge 0$ and odd for all $c<0$.