Solution (source code)

= Solution

<Rolle theorem>: if $f$ is continuous on $[a,b]$, differentiable on $(a,b)$, and $f(a)=f(b)$, then $f'(c)=0$ for some $c\in(a,b)$. Indeed, the <extreme value theorem> gives a maximum and minimum. If both occur only at the endpoints then $f$ is constant; otherwise an interior extremum $c$ satisfies $f'(c)=0$ by comparing the two-sided difference quotients.

<Mean value theorem>: if $f$ is continuous on $[a,b]$ and differentiable on $(a,b)$, then some $c\in(a,b)$ satisfies
$$
f'(c)=\frac{f(b)-f(a)}{b-a}.
$$
Apply Rolle's theorem to
$$
h(x)=f(x)-f(a)-\frac{f(b)-f(a)}{b-a}(x-a),
$$
which has $h(a)=h(b)=0$.