7

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?

  • Out of curiosity, is this restriction to those four operations something that's an arbitrary part of an assignment from an instructor, or does it have some other context? – Alan Oct 10 '14 at 12:35
  • @Alan I don't really know why is this restriction. I was just asked for help to figure out this small part of a bigger problem. –  Oct 10 '14 at 12:42
  • Why don't you construct a two-branch function which will be positive if x,y are positive and negative if x,y are negative instead? – Rrjrjtlokrthjji Oct 10 '14 at 12:52
  • 1
    Should the return of a negative be 'if and only if' both $x$ and $y$ or negative; or, as stated in the post, 'only if both $x$ and $y$ are negative'? – paw88789 Oct 10 '14 at 12:55
  • Finite many or infinite many operations? – mvw Oct 10 '14 at 12:56
  • 1
    if and only if both x and y are negative. –  Oct 10 '14 at 12:56
  • 1
    @mvw finite many operations –  Oct 10 '14 at 12:57
  • It is not for some clever programming trick using overflow effects of the finite representation? – mvw Oct 10 '14 at 13:03
  • Nit: since you're defining an algebra, what you really have is two operations. Subtraction is actually addition with a different element (-6 , rather than "minus" +6). – Carl Witthoft Oct 10 '14 at 15:03
  • @CarlWitthoft Clear, but how do You write reciprocals without division? –  Oct 10 '14 at 15:21
  • The reciprocal of $x$ is the element $y$ (in the same set of elements underlying your algebra) such that $x * y = 1$ -- or whatever your defined "unity" for the defined $ * $ operator is. – Carl Witthoft Oct 10 '14 at 16:23

1 Answers1

11

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$.

  • Pardon me, but should'nt $d=\max{,i\mid a_{i,j}\ne 0,}$ be $d=\max \left( {,i\mid a_{i,j}\ne 0,} \right)$ ? – Rrjrjtlokrthjji Oct 10 '14 at 12:53
  • 2
    @Nickolas That's a matter of notational convention. If $S$ is a set I usually write $\max S$, $\sup S$, $\min S$, $\inf S$ for the maximum, supremum etc. For finite cases (i.e. if $S={x,y,z}$, say) I usually write $\max(x,y,z)$ instead of $\max{x,y,z}$, but I personally won't write $\max({x,y,z})$, for instance. – Hagen von Eitzen Oct 10 '14 at 14:53
  • You mean third quadrant, not fourth quadrant. – Jeppe Stig Nielsen Oct 10 '14 at 21:16
  • @JeppeStigNielsen Late, but edited accordingly. While math.SE is a very active site, I should possibly subscribe to counting.SE ;) – Hagen von Eitzen Dec 02 '14 at 21:23
  • Couldn’t $q$ be a sum of squares? On $\mathbb R^2$, such a polynomial is never negative. I don’t think this affects your answer in any essential way… – Lubin Dec 02 '14 at 21:31
  • @Lubin Yes $q$ could be a sum of squares, hence be always positive, hence can be ignored and we can simply use the numerator instead. That's what I meant. – Hagen von Eitzen Dec 02 '14 at 21:40