关于构建三阶精度有限差分近似的权重求解问题
My professor gave us this question to solve, but I don't know have much familiarity with the topic.
Question
The forward difference is first order accurate and is defined to be $$ D_{+} = \frac{f(x+h) - f(x)}{h} $$ and the centered difference is $$ D_{0} = \frac{f(x+h)-f(x-h)}{2h}$$ Consider the finite difference approximation where $$ f'(x) = \frac{af(x+h) + bf(x) + cf(x-h)}{h}$$ where a,b,c are constants. The forward difference has constants $(a,b,c) = (1,-1,0)$ and the centered difference has constants $(a,b,c) = (\frac{1}{2}, 0, -\frac{1}{2})$. Are there any constants (a,b,c) that achieve 3rd order accuracy?Work
So my approach was to take a look at the Taylor Series expansion of these terms.
\begin{align}
&af(x+h) = af(x)+ ahf'(x) + ah^2\frac{f''(x)}{2} + \dots \
&bf(x) = bf(x) \
&cf(x-h) = cf(x) - chf'(x) + ch^2\frac{f''(x)}{2} - \dots
\end{align}
We want to approximate the first order derivative, which means we need a,b, and c to eliminate the f(x), f''(x), f'''(x) and solve for f'(x). This gives us the matrix
$$
\begin{pmatrix}
1 & 1 & 1 \
1 & 0 & -1 \
1 & 0 & 1 \
1 & 0 & -1
\end{pmatrix} \times \begin{pmatrix} a \ b \ c\end{pmatrix} = \begin{pmatrix} 0 \ 1 \ 0 \ 0 \end{pmatrix}
$$
This setup must be wrong as the last line of my matrix has $a-c = 0$, but the second line has $a-c = 1$. Can someone help me with this?I should add that when I look this up online I find that this does exist with weights $\frac{-11}{6}, \frac{-3}{2}, \frac{1}{3}$ Otherwise, I would write that it doesn't exist.
Thanks.
你的泰勒展开思路完全正确,但在构建方程组的时候出现了小问题,而且核心结论其实是:用三个点($x-h, x, x+h$)的线性组合除以$h$来近似$f'(x)$,无法达到三阶精度,咱们一步步拆解原因:
第一步:正确展开泰勒级数并整理系数
先把$f(x+h)$和$f(x-h)$的泰勒展开写到三阶项(足够判断精度):
$$
\begin{align*}
f(x+h) &= f(x) + h f'(x) + \frac{h^2}{2} f''(x) + \frac{h^3}{6} f'''(x) + O(h^4) \
f(x-h) &= f(x) - h f'(x) + \frac{h^2}{2} f''(x) - \frac{h^3}{6} f'''(x) + O(h^4)
\end{align*}
$$
将$af(x+h) + bf(x) + cf(x-h)$展开并合并同类项:
$$
\begin{align*}
af(x+h) + bf(x) + cf(x-h) &= (a+b+c)f(x) + (a - c)h f'(x) \
&\quad + \frac{a+c}{2}h^2 f''(x) + \frac{a - c}{6}h^3 f'''(x) + O(h^4)
\end{align*}
$$
第二步:明确三阶精度的要求
我们希望$\frac{af(x+h) + bf(x) + cf(x-h)}{h} = f'(x) + O(h3)$,也就是近似式的误差是$h3$阶的。这意味着:
- 消去$f(x)$项:否则近似式里会出现$\frac{f(x)}{h}$的项,完全不符合导数的形式,因此要求:
$$a + b + c = 0$$ - $f'(x)$的系数为1:这是我们要近似的目标项,因此:
$$\frac{(a - c)h}{h} = a - c = 1$$ - 消去$f''(x)$项:如果保留这一项,误差会是$O(h)$或$O(h^2)$,无法达到三阶,因此要求:
$$\frac{\frac{a+c}{2}h^2}{h} = \frac{a+c}{2}h = 0 \implies a + c = 0$$ - 消去$f'''(x)$项:要达到三阶精度,误差必须是$O(h^3)$,因此这一项的系数必须为0:
$$\frac{\frac{a - c}{6}h^3}{h} = \frac{a - c}{6}h^2 = 0 \implies a - c = 0$$
第三步:发现矛盾
现在看上面的条件:
- 要求$a - c = 1$(保证$f'(x)$系数正确)
- 同时要求$a - c = 0$(消去$f'''(x)$项,达到三阶精度)
这两个方程是矛盾的,说明没有这样的常数$a,b,c$能同时满足所有四个条件。也就是说,仅用三个点的线性组合,最多只能达到二阶精度(就是你熟悉的中心差分,满足前三个条件,误差为$O(h^2)$)。
关于你查到的权重
你提到的权重$\frac{-11}{6}, \frac{-3}{2}, \frac{1}{3}$应该是对应包含更多点的高阶格式(比如加入$x+2h$或$x-2h$),或者是近似更高阶导数的格式,并非仅用$x-h, x, x+h$三个点的一阶导数近似。如果要实现三阶精度的一阶导数近似,通常需要用到四个点(比如$x-2h, x-h, x, x+h$),通过四个未知数来满足四个条件,从而消去$f(x), f''(x), f'''(x)$项,得到三阶精度的结果。
总结一下:仅用$(x-h, x, x+h)$三个点的线性组合来近似$f'(x)$,无法达到三阶精度,你的矩阵里出现的矛盾正好验证了这一点。
备注:内容来源于stack exchange,提问作者Calum

