1. ## Polynomial Interpolation

Let $h_i = x_i-x_{i-1}>0$. Suppose $f$ is three times differentiable and let $P_i$ be the linear interpolant through the points $(x_{i-1}, f(x_{i-1}))$ and $(x_i, f(x_i)).$
I want to show, for $h_i \rightarrow 0$
$\\$
$f'(x)-P'_i(x) = \frac{1}{2}(2x-x_{i-1}-x_i)f''(x)+\mathcal{O}(h_i^2)=$ $\left(\begin{array}{cc}\mathcal{O}(h_i^2),&\mbox{ if } x= \frac{1}{2}(x_{i-1}+x_i)\\\mathcal{O}(h_i), & \mbox{ otherwise} \end{array}\right)$

2. I almost have the solution. I just made a mistake somewhere with some minussign but i can't find a mistake;

$P_i(x)$ is of degree 1. So $P_i'(x)$ is a constant and $P_i'(x) = \frac{f(x_i)-f(x_{i-1})}{h_i}$

$f(x_i)=f(x)+f'(x)(x-x_i)+\frac{1}{2}f"(x)(x-x_i)^2+\mathcal{O}(h_i^3)$
$f(x_{i-1})=f(x)+f'(x)(x-x_{i-1})+\frac{1}{2}f"(x)(x-x_{i-1})^2+\mathcal{O}(h_i^3)$
So $f(x_i)-f(x_{i-1}) =$ $f'(x)(x_{i-1}-x_i)+\frac{1}{2}f"(x)(x^2-2xx_i+x_i^2-x^2+2xx_{i-1}-x_{i-1}^2)+\mathcal{O}(h_i^3)$
$=f'(x)(x_i-x_{i-1})+\frac{1}{2}f"(x)(-2x(x_i-x_{i-1})+(x_i-x_{i-1})(x_i+x_{i-1}))+\mathcal{O}(h_i^3)$
While $h_i=x_{i-1}-x_i$ the equation becomes
$=-f'(x)h_i+\frac{1}{2}f"(x)(-2xh_i+ (x_i+x_{i-1})h_i)+\mathcal{O}(h_i^3)$
And so $P_i'(x) = \frac{f(x_i)-f(x_{i-1})}{h_i}=-f'(x)+\frac{1}{2}f"(x)(-2x+ x_i+x_{i-1})+\mathcal{O}(h_i^2)$
Thus $f'(x)-P_i'(x)=f'(x)-(-f'(x)+\frac{1}{2}f"(x)(-2x+ x_i+x_{i-1})+\mathcal{O}(h_i^2)$

So somewhere there is a small mistake, can you find it anywhere?
thanks