Solution (source code)

= Solution

For $x\ne0$, put $P(t)=\sum_{k=0}^{n-1}f^{(k)}(0)t^k/k!$ and $K=(f(x)-P(x))/x^n$. The auxiliary function $F(t)=f(t)-P(t)-Kt^n$ satisfies
$$
F(x)=F(0)=0,\qquad F^{(j)}(0)=0\quad(1\leq j\leq n-1).
$$
<Rolle's theorem> first gives a zero of $F'$ strictly between zero and $x$. Apply <Rolle's theorem> to $F'$ between that zero and zero, where $F'(0)=0$, to obtain a zero of $F''$. Continue in this way. The <derivatives> through order $n-1$ are <continuous>, since they are differentiable; hence every application is valid even if $f^{(n)}$ is not <continuous>. After $n$ applications there is $c$ strictly between zero and $x$ with $F^{(n)}(c)=0$.

But $F^{(n)}(c)=f^{(n)}(c)-n!K$, so $K=f^{(n)}(c)/n!$. Writing $c=\theta x$ yields \b[the Taylor formula with Lagrange remainder]
$$
\boxed{f(x)=\sum_{k=0}^{n-1}\frac{f^{(k)}(0)}{k!}x^k
+\frac{f^{(n)}(\theta x)}{n!}x^n,\qquad0<\theta<1.}
$$
The same construction using repeated applications of <Rolle's theorem> applies when $x<0$, with intervals ordered from $x$ to zero. For $x=0$ the identity is immediate and any $\theta\in(0,1)$ works. This proves the <Taylor theorem with Lagrange remainder> using only the allowed theorem and elementary differentiation.