2
$\begingroup$

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.

$\endgroup$
0

1 Answer 1

2
$\begingroup$

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.)

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .