First, note that because of the form of the error term
\begin{equation*}
\begin{aligned}f(x_{i})\amp = P(x_{i})\amp \amp \text{for $i=0 \ldots n$}\\\end{aligned}
\end{equation*}
since at each \(x_{i}\text{,}\) the error term is zero.
For any value \(x \in [a,b]\) such that \(x \neq x_{i}\) for all \(i\text{,}\) define:
\begin{equation*}
\begin{aligned}g(t)\amp = f(t) - P(t) - \bigl(f(x) -P(x) \bigr) \prod_{i=0}^{n}\frac{t-x_{i}}{x-x_{i}}\\\end{aligned}
\end{equation*}
By the conditions of the theorem,
\(f\) has
\(n+1\) continuous derivatives, and since
\(P\) is a polynomial, and it has
\(n+1\) continuous derivatives,
\(g\) has
\(n+1\) continuous derivatives on
\((a,b)\text{.}\)
Furthermore,
\begin{equation*}
\begin{aligned}g(x_{j})\amp = f(x_{j}) - P(x_{j}) - \bigl(f(x)-P(x) \bigr) \cdot 0 \\\amp = 0\end{aligned}
\end{equation*}
for \(j=0, 1, \ldots, n\) and
\begin{equation*}
\begin{aligned}g(x)\amp = f(x) - P(x) - \bigl(f(x) - P(x) \bigr) \prod_{i=0}^{n} \frac{x-x_{i}}{x-x_{i}}\\\amp = f(x) - P(x) - \bigl(f(x) - P(x)\bigr) \cdot 1 = 0.\end{aligned}
\end{equation*}
therefore
\(g\) has
\(n+2\) roots on
\([a,b]\text{.}\) Applying the Generalized Rolle’s Theorem given in
Theorem 1.2.5, it follows that there exists
\(\xi \in [a,b]\) such that
\(g^{(n+1)}(\xi) = 0\text{.}\)
Note that \(P\) is a polynomial of degree at most \(n\text{,}\) so \(P^{(n+1)}(x) \equiv 0\text{.}\) And \(\prod_{i=0}^{n}\frac{t-x_{i}}{x-x_{i}}\) is a polynomial of degree \(n+1\) with leading coefficient \(\prod_{i=0}^{n} (x-x_{i})^{-1}\text{,}\) so
\begin{equation*}
\begin{aligned}\frac{d^{n+1}}{dt^{n+1}}\biggl[\prod_{i=0}^{n} \frac{t-x_{i}}{x-x_{i}}\biggr] ,\amp = (n+1)! \biggl[\prod_{i=0}^{n} (x-x_{i}) \biggr]^{-1}.\end{aligned}
\end{equation*}
Differentiating \(g\) \(n+1\) times and evaluating it at \(\xi\) yields
\begin{equation*}
\begin{aligned}0\amp = g^{(n+1)}(\xi) = f^{(n+1)}(\xi) - 0 - \bigl(f(x) - P(x)\bigr) \biggl[\prod_{i=1}^{n} (x-x_{i})\biggr]^{-1}.\end{aligned}
\end{equation*}
Solving for \(f(x)\text{,}\) results in
\begin{equation*}
\begin{aligned}f(x)\amp = P(x) + \frac{f^{(n+1)}(\xi)}{(n+1)!}(x-x_{0})(x-x_{1}) \cdots (x-x_{n})\end{aligned}
\end{equation*}