TITLE: Prove that function is constant
QUESTION [20 upvotes]: Prove that a function $f:\mathbb{R}\to\mathbb{R}$ which satisfies
$$f\left({\frac{x+y}3}\right)=\frac{f(x)+f(y)}2$$
is a constant function.
This is my solution: constant function have derivative $0$ for any number, so I need to prove that $f'$ is always $0$. I first calculated $\frac{d}{dx}$ and then $\frac{d}{dy}$:
$$f'\left({\frac{x+y}3}\right)\frac13=\frac{f'(x)}2$$
$$f'\left({\frac{x+y}3}\right)\frac13=\frac{f'(y)}2$$
From this I can see that $\frac{f'(x)}2=\frac{f'(y)}2$. Multiplying by $2$ and integrating I got:
$$f(x)=f(y)+C$$
for some constant $C\in\mathbb{R}$. By definition of $f$ it is true for any $x,y\in\mathbb{R}$, so I can write
$$f(y)=f(x)+C$$
Adding this two equation and simplifying I got
$$C=0$$
so $f(x)=f(y)$ for all $x,y\in\mathbb{R}$. Is my solution mathematically correct. Is this complete proof, or I missed something?

REPLY [51 votes]: It is not even necessary to assume that $f$ is continuous.

By letting $y = 2x$, we see that $f(x) = f(2x)$
Letting $y = -4x$, we get $f(-x) = \frac{f(x) + f(-4x)}{2}$.  However, from (1), $f(-4x) = f(-2x) = f(-x)$, so this simplifies to $f(-x) = f(x)$
Finally, let $y = -x$ and simplifying gives $2f(0) = f(x) + f(-x)$.  Substituting in from (2), this becomes $f(0) = f(x)$.  Since this holds for all $x \in \mathbb{R}$, we conclude that $f$ must be constant.