# Prove that for any function $f:\mathbb R\to\mathbb R$ there exist real numbers $x,y$, with $x\neq y$, such that $|f(x)-f(y)|\leq 1$.

I need help with a 9th grade functions exercise:

Prove that for any function $$f:\mathbb R\to\mathbb R$$ there exist real numbers $$x,y$$, with $$x\neq y$$, such that $$|f(x)-f(y)|\leq 1$$.

I tried assuming that $$|f(x) - f(y) | > 1$$ so that I could say that each $$f(z)$$, where $$z$$ is an integer, is from an interval $$(a, a+1]$$ where a is also an integer. So $$f: \mathbb Z \to \mathbb R$$ would just be from the interval $$(-\infty, \infty)$$. But if n is not an integer, $$f(n)$$ would still be from $$\mathbb R$$, meaning $$|f(z) - f(n)| \leq 1$$, a contradiction. However, I don’t really know how to write this so it’s easily understandable. Sorry if I haven’t explained myself well, but this is how we do it where I’m from.

• Seems trivial if you allow $x=y$ you would have $f(x)-f(y)=f(x)-f(x)=0$ is clearly less than $1$ Commented Feb 15 at 16:13
• Sorry, I forgot to mention they can’t be equal, I will edit my question right now. Commented Feb 15 at 16:16
• I can't follow your argument and I think it's probably not the right idea. What do you mean by "if $n$ is not a real number..."? Unless you have some more information about $f$ (eg continuity), answering this question requires using a special property of $\Bbb R$, because this fact is not true for functions $\Bbb Q \to \Bbb Q$. Commented Feb 15 at 16:19
• @IzaakvanDongen I meant to say “If $n is not an integer”, sorry again. No extra information provided. Commented Feb 15 at 16:20 • I think you must somehow use the fact that the real numbers are not countable. If you were looking at only a countable set of input, for example$f: \mathbb Q\to\mathbb R$, then you could assign every possible input value$x$a unique integer$N(x)$by "counting" the set, and then let$f(x) = 2N(x).$Commented Feb 15 at 19:39 ## 1 Answer Here's a proof. It may be what you are trying to say. The real line is the disjoint union of the countably many half open intervals $$(n,n+1]$$ of length $$1$$ (here $$n$$ is an integer). Since there are uncountably many real numbers there must be some interval that contains two images $$f(x)$$ and $$f(y)$$ with $$x \ne y$$. This is probably an acceptable answer for a ninth grade competition, although your standard ninth grade curriculum might not include a proof of the uncountability of the reals. • I do not understand your proof. If you select the images arbitrarily you cannot be sure that they fall within$I_n=(n,n+1]$without begging the question. A logical fallacy that cannot be yours. If you select the images in a given$I_n$, OK you now have the inequality but how on earth can you be sure that$x \neq y$? There is no assomption on injectivity....At best your proof is incomplete Commented Feb 15 at 18:09 • @user12030145 This argument uses the pigeonhole principle. If you sprinkle uncountably many real values$f(x)$onto the line you can't have just one in each of the unit intervals. Some interval must contain at least two. In fact, some interval will have uncountably many values in it. Commented Feb 15 at 18:25 • Yes, OK. This was not my point. What I was saying is that two different image values$f(x)\neq f(y)$cannot be associated with$x=y$. This looks obvious but is actually not. You need to bar multi-valued functions for this to be true. But at ninth-grade level this is the implicit assumption about real analysis. Always a good thing to make it specific though. Commented Feb 15 at 19:38 • @user12030145 I think you are missing the point. The "images" need not be different. The argument works for the function that's equal to$\pi$everywhere. The argument shows that there are (at least) two different values in the domain whose images in the range are no more than$1\$ apart. Commented Feb 15 at 23:41
• @user12030145 We have to agree to disagree. The argument is as clear as I can make it, and no one else here seems to have your problem with it. Commented Feb 16 at 0:29