How to show that $f$ is a straight line if $f(\frac{x+y}{2})=\frac{f(x)+f(y)}{2}$?

The two points $(x,f(x))$ and $(y,f(y))$ are on the graph of $f$. The point on the straight line half-way between them is $\left(\frac{x+y} 2, \frac{f(x)+f(y)} 2 \right)$. The actual point on the graph with abscissa $\frac{x+y}2$ is $\left(\frac{x+y} 2, f\left(\frac{x+y} 2 \right) \right)$. And we are told those two points are the same.

Now iterate this: We've shown the conclusion that's it's a straight line is right for $x$ and $y$ and the point $z$ half-way between them: those three points on the graph are on a straight line. Now deal in the same way with the points half-way between $x$ and $z$ (call it $a$), and half-way between $z$ and $y$ (call it $b$). So far we have $$ x < a < z < b< y. $$ Then half-way between $x$ and $a$; then half-way between $a$ and $z$; then half-way between $z$ and $b$; then half-way between $b$ and $y$.

Then further split the resulting intervals in half. Then split the next set of resulting intervals in half. And so on.

No matter how long we continue the process, the points we getting by splitting smaller and smaller intervals in half will thus be shown always to lie on a straight line.

However, some points between $x$ and $y$ will never be reached by successively splitting in half: the point two-thirds of the way from $x$ to $y$ is one such point. Here we use continuity of the function $f$: that point can be approached as closely as you wish by points that do result from successively splitting intervals in half.

Thus the part of the graph between $(x,f(x))$ and $(y,f(y))$ is a straight line.

But that is true no matter which two points are chosen to be called $x$ and $y$. Hence the whole graph is a straight line.


Define a linear function $g \colon \mathbb{R} \rightarrow \mathbb{R}$ by $g(x) = (f(1) - f(0))x + f(0)$. Note that by definition, $g(0) = f(0)$ and $g(1) = f(1)$ and that $g$ also satisfies

$$ g \left( \frac{x + y}{2} \right) = \frac{g(x) + g(y)}{2}. $$

You want to show that $g(x) = f(x)$ for all $x \in \mathbb{R}$. We have

$$ f \left( \frac{x + 0}{2} \right) = \frac{f(x) + f(0)}{2}. $$

Plugging in $x = 1$, we see that

$$ f \left( \frac{1}{2} \right) = \frac{f(1) + f(0)}{2} = \frac{g(1) + g(0)}{2} = g \left( \frac{1}{2} \right) $$

(where we used $f(0) = g(0)$ and $f(1) = g(1)$). Plugging in $x = \frac{1}{2}$ will give you

$$ f \left( \frac{1}{4} \right) = \frac{f \left( \frac{1}{2} \right) + f(0)}{2} = \frac{g \left( \frac{1}{2} \right) + g(0)}{2} = g \left( \frac{1}{4} \right)$$

(where we used $f(0) = g(0)$ and $f \left( \frac{1}{2} \right) = g \left( \frac{1}{2} \right)$). Iterating this inductively, you can show that

$$ f \left( \frac{1}{2^n} \right) = g \left( \frac{1}{2^n} \right) $$

for all $n \in \mathbb{N}$. By a similar inductive argument, you can then show that

$$ f \left( \frac{m}{2^n} \right) = g \left( \frac{m}{2^n} \right) $$

for all $n \in \mathbb{N}$ and $m \in \mathbb{Z}$. Since $f$ and $g$ are two continuous functions that agree on the dense set $ \{ \frac{m}{2^n} \, | \, n \in \mathbb{N}, m \in \mathbb{Z} \}$ of the dyadic rationals, they must agree everywhere and so $f(x) = g(x)$ for all $x \in \mathbb{R}$.