Prove that a function is constant [duplicate]

I'm attempting to prove the following statement:

Let $f:\mathbb{R}\to\mathbb{R}$ be a function and suppose that $|f(x)-f(y)|\leq (x-y)^2$ for all $x,y\in\mathbb{R}$, therefore f is constant.

I was trying to prove it by a theorem that states that; Let f be a differentiable function in $(a,b)$. Therefore if $f'(x)=0$ for all $x,y\in(a,b)$, then f is constant.

But i'm stuck trying to prove that f is differentiable to use the above theorem.

marked as duplicate by Git Gud, Andrés E. Caicedo, user147263, user2345215, egregJan 25 '15 at 21:58

• yes, is the same problem, i searched but i only saw like 10 questions that were different of mine, didn't see this one, thanks – Zigisfredo Jan 25 '15 at 21:05
• Don't worry. It's OK to ask duplicates, they just get closed and that's all. Plus you got an elementary solution here that isn't in the other question. – Git Gud Jan 25 '15 at 21:08

Hint: $$0 \leq \left| \frac{f(x)-f(y)}{x-y}\right| \leq |x - y|,$$ and make $x-y \to 0$. Then does $f'$ exists? Is it zero? What next?
If it makes easier to see, this is equivalent to $$0 \leq \left| \frac{f(x+h)-f(x)}{h}\right| \leq |h|,$$ then make $h \to 0$. (In the notation above, swap $y \leftrightarrow x$ and $x \leftrightarrow x+h$)
$f(y)-f(x) = \sum_{k=1}^{n} f(x+{k \over n} (y-x)) - f(x+{k-1 \over n} (y-x))$, so $|f(y)-f(x) | \le \sum_{k=1}^{n} {1 \over n^2} |y-x|^2 = {1 \over n} |y-x|^2$.
Since $n$ is arbitrary we have the desired result.