Prove that $\int_a^b (f'(x))^2dx - h\sum_{i=0}^{n-1} \left(\frac{f(x_{i+1})-f(x_i)}{h}\right)^2 = O(h^2) $ Prove that:
$\int_a^b (f'(x))^2dx - h\sum_{i=0}^{n-1} {(\frac{f(x_{i+1})-f(x_i)}{h})}^2 = O(h^2) $
Where $h=\frac{b-a}{n} , x_k=a+kh$ and $f \in C^\infty[a,b]$
First I've tried to estimate the following: $\int_{x_i}^{x_{i+1}} (f'(x))^2dx - h{\left(\frac{f(x_{i+1})-f(x_i)}{h}\right)}^2$
By Taylor series we know:
$f'(x)=\frac{f(x+h)-f(x)}{h}-\frac{h}{2}f''(\alpha)$
(Where $ x\leq\alpha\leq x+h$)
So $\int_{x_i}^{x_{i+1}} (f'(x))^2dx = \int_{x_i}^{x_{i+1}} \left(\frac{f(x+h)-f(x)}{h}-\frac{h}{2}f''(\alpha)\right)^2dx$
Then I got stuck

We have
\begin{align*}
A(x) &\overset{\text{def}}{=} \int_a^b [f'(x)]^2dx - \sum_{k=0}^{n-1}\left(\frac{f(x_{k+1}) - f(x_k)}{h}\right)^2h \\
&= \sum_{k=0}^{n-1}\left\{\color{red}{\int_{x_k}^{x_{k+1}}[f'(x)]^2 dx} - \color{blue}{\left(\frac{f(x_{k+1}) - f(x_k)}{h}\right)^2h}\right\}
\end{align*}
Now, for $x \in [x_k, x_{k+1}]$,
\begin{align*}
[f'(x)]^2 = [f'(x_k)]^2 + 2f'(x_k)f''(x_k)(x - x_k) + \{[f''(x_k)]^2 + f'(x_k)f'''(x_k)\}(x - x_k)^2 + O(h^3)
\end{align*}
and so
\begin{align*}
\color{red}{\int_{x_k}^{x_{k+1}}[f'(x)]^2 dx} &= \color{green}{[f'(x_k)]^2h} + \color{orange}{2f'(x_k)f''(x_k)\cdot\frac{1}{2}h^2} + \{[f''(x_k)]^2 + f'(x_k)f'''(x_k)\}\cdot\frac{1}{3}h^3 + O(h^4) \\
&=\color{green}{[f'(x_k)]^2h} + \color{orange}{2f'(x_k)f''(x_k)\cdot\frac{1}{2}h^2}  + O(h^3)
\end{align*}
Next,
\begin{align*}
f(x_{k+1}) = f(x_k) + hf'(x_k) + \frac{h^2}{2}f''(x_k) + O(h^3)
\end{align*}
and so
\begin{align*}
\color{blue}{\left(\frac{f(x_{k+1}) - f(x_k)}{h}\right)^2h} &= \left(f'(x_k) + \frac{h}{2}f''(x_k) + O(h^2)\right)^2 h \\
&= \color{green}{[f'(x_k)]^2h} + \color{orange}{f'(x_k)f''(x_k)h^2}+O(h^3)
\end{align*}
Therefore,
\begin{align*}
\color{red}{\int_{x_k}^{x_{k+1}}[f'(x)]^2 dx} - \color{blue}{\left(\frac{f(x_{k+1}) - f(x_k)}{h}\right)^2h} = O(h^3)
\end{align*}
Finally,
\begin{align*}
A(x) = \sum_{k=0}^{n-1}O(h^3) = O(h^2)
\end{align*}
