[proofplan]
We apply the [Maximum-Minimum Theorem](/theorems/182) to obtain points where $f$ attains its global extrema on $[a,b]$. If $f$ is constant, the derivative vanishes everywhere. If $f$ is non-constant, the hypothesis $f(a) = f(b)$ forces at least one extremum to lie in the interior $(a,b)$, where the derivative must vanish because the one-sided difference quotients have opposite signs.
[/proofplan]
[step:Apply the Maximum-Minimum Theorem to locate global extrema]
Since $f$ is continuous on $[a,b]$, the [Maximum-Minimum Theorem](/theorems/182) provides points $c_{\min}, c_{\max} \in [a,b]$ such that
\begin{align*}
f(c_{\min}) \leq f(x) \leq f(c_{\max}) \quad \text{for all } x \in [a,b].
\end{align*}
[/step]
[step:Handle the constant case: $f(c_{\min}) = f(c_{\max})$ implies $f' \equiv 0$]
If $f(c_{\min}) = f(c_{\max})$, then $f(x) = f(c_{\min})$ for all $x \in [a,b]$, so $f$ is constant. For any $c \in (a,b)$:
\begin{align*}
f'(c) = \lim_{h \to 0} \frac{f(c+h) - f(c)}{h} = \lim_{h \to 0} \frac{0}{h} = 0.
\end{align*}
[/step]
[step:In the non-constant case, use $f(a) = f(b)$ to place an extremum in the interior]
Assume $f(c_{\min}) < f(c_{\max})$. Since $f(c_{\min}) \leq f(a) = f(b) \leq f(c_{\max})$ and $f(c_{\min}) < f(c_{\max})$, at least one inequality is strict:
**Case 1:** If $f(a) < f(c_{\max})$, then $f(c_{\max}) > f(a) = f(b)$, so $c_{\max} \neq a$ and $c_{\max} \neq b$. Therefore $c_{\max} \in (a,b)$.
**Case 2:** If $f(c_{\min}) < f(a)$, then $f(c_{\min}) < f(a) = f(b)$, so $c_{\min} \neq a$ and $c_{\min} \neq b$. Therefore $c_{\min} \in (a,b)$.
At least one case holds (since $f(c_{\min}) \leq f(a) \leq f(c_{\max})$ with $f(c_{\min}) < f(c_{\max})$ forces $f(c_{\min}) < f(a)$ or $f(a) < f(c_{\max})$).
[guided]
Why must at least one extremum be interior? The boundary values are equal: $f(a) = f(b)$. If the maximum exceeds $f(a)$, the maximum point cannot be either endpoint. If the minimum is less than $f(a)$, the minimum point cannot be either endpoint. Since the maximum strictly exceeds the minimum, at least one of these situations occurs.
More precisely, from $f(c_{\min}) \leq f(a) \leq f(c_{\max})$ and $f(c_{\min}) < f(c_{\max})$, if $f(c_{\min}) = f(a)$ then $f(a) < f(c_{\max})$ (Case 1 holds). If $f(c_{\min}) < f(a)$, Case 2 holds directly. So at least one case always applies.
[/guided]
[/step]
[step:Show the derivative vanishes at an interior extremum]
Suppose $d \in (a,b)$ is an interior maximum (the minimum case is analogous with all inequalities reversed).
For $h > 0$ sufficiently small (so that $d + h \in [a,b]$), $f(d+h) \leq f(d)$, so
\begin{align*}
\frac{f(d+h) - f(d)}{h} \leq 0.
\end{align*}
Taking the right-hand limit: $f'(d) = \lim_{h \to 0^+} \frac{f(d+h) - f(d)}{h} \leq 0$.
For $h < 0$ sufficiently small (so that $d + h \in [a,b]$), $f(d+h) \leq f(d)$ and $h < 0$, so
\begin{align*}
\frac{f(d+h) - f(d)}{h} \geq 0.
\end{align*}
Taking the left-hand limit: $f'(d) = \lim_{h \to 0^-} \frac{f(d+h) - f(d)}{h} \geq 0$.
Combining $f'(d) \leq 0$ and $f'(d) \geq 0$ gives $f'(d) = 0$.
[guided]
At an interior maximum $d \in (a,b)$, the function $f$ can only decrease (or stay flat) as we move away from $d$ in either direction. This forces the difference quotient to have different signs depending on the direction of approach:
When $h > 0$: the numerator $f(d+h) - f(d) \leq 0$ and the denominator $h > 0$, so the quotient is $\leq 0$.
When $h < 0$: the numerator $f(d+h) - f(d) \leq 0$ and the denominator $h < 0$, so the quotient is $\geq 0$.
Since $f$ is differentiable at $d$, the two one-sided limits must agree. The right-hand limit is $\leq 0$ and the left-hand limit is $\geq 0$, so
\begin{align*}
f'(d) \leq 0 \quad \text{and} \quad f'(d) \geq 0,
\end{align*}
giving $f'(d) = 0$. The same argument with reversed inequalities works for an interior minimum. In either case, there exists $c \in (a,b)$ with $f'(c) = 0$.
[/guided]
[/step]