I'm trying to find formulas for the finite difference approximation "Five-points-stencil" of the first derivative for non-constant grid spacing. It's needed for the outermost left and right points. I tried to search for it but can't find it.



Finite difference approximation
Given pairwise distinct real numbers $x\_0,\dots,x\_4$, one can approximate $f'(x\_0)$ by a linear combination $a\_0f(x\_0)+\cdots+a\_4f(x\_4)$ so that
$$g\_j'(x\_0)=a\_0g\_j(x\_0)+\cdots+a\_4g\_j(x\_4)$$
for $g\_j(x):=x^j$ and $j\in\{0,\dots,4\}$.


Solving the resulting system of equations for $a\_0,\dots,a\_4$, we get
$$a\_0=-(a\_1+\cdots+a\_4)$$
and
$$a\_i=\frac{\prod\limits\_{j\in\{0,\dots,4\}\setminus\{0,i\}}(x\_0-x\_j)}
{\prod\limits\_{j\in\{0,\dots,4\}\setminus\{i\}}(x\_i-x\_j)}$$
for $i\in\{1,\dots,4\}$.


(Here it does not matter whether $x\_0$ is an outermost point or not.)


