How to show that $f$ is a straight line if $f(\frac{x+y}{2})=\frac{f(x)+f(y)}{2}$? Let $f:\mathbb R\to\mathbb R$ be continuous such that $f(\frac{x+y}{2})=\frac{f(x)+f(y)}{2}~\forall~x,y\in\mathbb R.$ How to show that $f$ 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}$.
