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
 A: 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*}
A: I was only able to get $O(h)$. Perhaps someone cleverer than I can point out where I was loose.

By the mean value theorem,
$$\frac{f(x_{i+1}) - f(x_i)}{h} = f'(x_0)$$
for some $x_0 \in [x_i, x_{i+1}]$.
Because $f \in C^2[a,b]$, there exists $M$ such that $\max\{|f'(x)|,|f''(x)|\} \le M$ for all $x \in [a,b]$.
This implies
$$|(f'(x))^2 - (f'(x_0))^2|
\le 2 M^2 |f'(x) - f'(x_0)|
\le 2 M^3 h$$
for all $x \in [x_i, x_{i+1}]$.
Thus
$$\left|\int_{x_i}^{x_{i+1}} (f'(x))^2\, dx - h \left(\frac{f(x_{i+1}) - f(x_i)}{h}\right)^2\right|
\le \int_{x_i}^{x_{i+1}} |(f'(x))^2 - (f'(x_0))^2| \, dx \le 2 M^3 h^2.$$
Summing over $i = 0,1,\ldots, n-1$ yields $2M^3 h$.
A: Let $g$ be any Lipschitz function. Then the atomar expression in question is the minimum of a quadratic function
$$
\int_x^{x+h}g(s)^2ds-\frac1h\left(\int_x^{x+h}g(s)ds\right)^2 = \min_{m\in\Bbb R}\int_x^{x+h}(g(s)-m)^2ds
$$
By the mean value theorem, $m=\frac1h\int_x^{x+h}g(s)ds$ is equal to one of the function values of $g$.
\begin{align}
\min_{c\in[x,x+h]}\int_x^{x+h}(g(s)-g(c))^2ds
&\le\int_x^{x+h}|g(s)-g(x+h/2)|^2ds\\
&\le\int_x^{x+h}L^2|s-(x+h/2)|^2ds=\frac{L^2}{12}h^3
\end{align}
In the given case $g=f'$ the Lipschitz constant can be chosen as $L=\|f''\|_\infty$,
$$
\int_{x_i}^{x_{i+1}}f'(s)^2ds-h\left(\frac{f(x_{i+1})-f(x_i)}h\right)^2
\le\frac{\|f''\|_\infty^2}{12}h^3
$$
and in the sum
$$
\int_{x_0}^{x_n}f'(s)^2ds-h\sum_{i=0}^{n-1}\left(\frac{f(x_{i+1})-f(x_i)}h\right)^2
\le\frac{\|f''\|_\infty^2}{12}(x_n-x_0)h^2
$$
