Suppose f(x) is not constant, which means we can find x_1 and x_2 so that f(x_1) != f(x_2). We might as well suppose ||x_1 - x_2|| = 1 (think about why it doesn't really matter what their distance is)
We will want to repeatedly divide up the interval connecting x_1 and x_2 to show that f(x_1) and f(x_2) have to be arbitrarily close to each other leading to a contradiction.
So let x_1 = y_1, y_2, ..., y_{n+1} = x_2 be a sequence of points uniformly spaced on the line connecting x_1 and x_2 by distance 1/n.
This says that ||f(y_i) - f(y_{i+1})|| ≤ ||1/n||^2. Using the triangle inequality says that ||f(y_1) - f(y_3)|| ≤ ||f(y_1) - f(y_2)|| + ||f(y_2) - f(y_3)||. Doing this repeatedly tells us that ||f(y_1) - f(y_n)|| ≤ n * 1/n^2 = 1/n. This means that f(x_1) and f(x_2) have to be arbitrarily close to each other, ie) they are equal -- which is a contradiction.
Answers & Comments
Verified answer
Ok so obviously any constant function works.
Suppose f(x) is not constant, which means we can find x_1 and x_2 so that f(x_1) != f(x_2). We might as well suppose ||x_1 - x_2|| = 1 (think about why it doesn't really matter what their distance is)
We will want to repeatedly divide up the interval connecting x_1 and x_2 to show that f(x_1) and f(x_2) have to be arbitrarily close to each other leading to a contradiction.
So let x_1 = y_1, y_2, ..., y_{n+1} = x_2 be a sequence of points uniformly spaced on the line connecting x_1 and x_2 by distance 1/n.
This says that ||f(y_i) - f(y_{i+1})|| ≤ ||1/n||^2. Using the triangle inequality says that ||f(y_1) - f(y_3)|| ≤ ||f(y_1) - f(y_2)|| + ||f(y_2) - f(y_3)||. Doing this repeatedly tells us that ||f(y_1) - f(y_n)|| ≤ n * 1/n^2 = 1/n. This means that f(x_1) and f(x_2) have to be arbitrarily close to each other, ie) they are equal -- which is a contradiction.
Edited for a little clarity