Solution (source code)

= Solution

The <intermediate value theorem> states that if $f:[\alpha,\beta]\to\mathbb R$ is continuous and $y$ lies between $f(\alpha)$ and $f(\beta)$, then some $c\in[\alpha,\beta]$ satisfies $f(c)=y$.

It is enough to prove the case
$$
f(\alpha)<y<f(\beta).
$$
Let
$$
E=\{x\in[\alpha,\beta]:f(x)<y\},
\qquad c=\sup E.
$$
Choose $x_n\in E$ with $x_n\to c$. Continuity gives $f(c)\leq y$. If $f(c)<y$, continuity would make $f(x)<y$ for some $x>c$, contradicting that $c$ is an upper bound of $E$. Thus $f(c)=y$. The case with reversed endpoint inequalities follows by replacing $f$ with $-f$.