数值分析中,假定是一維或二維的正方形格點,五點模版的點是由其四個鄰點所組成的模版。會用五點模版來將格點上的导数用有限差分來近似。這是數值微分的應用。
一維
一維下,假設各點之間的距離是h,則五點模板的五個點會是
: \{x-2h, x-h, x, x+h, x+2h\}.
一維一階導數
實變數函数 f在點x的一階導數可以用五點模版近似如下:
:f'(x) \approx \frac{-f(x+2 h)+8 f(x+h)-8 f(x-h)+f(x-2h)}{12 h}
上式中,沒有用到中心點位置的值f(x),只有用到其他四點。
推導
此公式可以用f(x \pm h)和f(x \pm 2h)在a的四個泰勒级数求得,泰勒級數寫到h3項,計算在a = x \mp h和a = x \mp 2h的級數,找到共同項f^{(k)}(x)的資訊,再用四個方程f ′(x),可以得到在x + h點和x − h點時:
:f(x \pm h) = f(x) \pm h f'(x) + \frac{h^2}{2}f*(x) \pm \frac{h^3}{6} f^{(3)}(x) + O_{1\pm}(h^4). \qquad (E_{1\pm}).
計算(E_{1+})-(E_{1-})可以得到
:f(x+h) - f(x-h) = 2hf'(x) + \frac{h^3}{3}f^{(3)}(x) + O_1(h^4). \qquad (E_1).
剩餘項O1(h4)階數必定是h5,不會是h4,因為若h4項已經寫成(E1+)和(E1−),會透過以下計算而消去,而更高次的剩餘項沒有處理,會留下來(如下)。
類似的,也可以得到下式
:f(x \pm 2h) = f(x) \pm 2h f'(x) + \frac{4h^2}{2!} f*(x) \pm \frac{8h^3}{3!} f^{(3)}(x) + O_{2\pm}(h^4). \qquad (E_{2\pm})
計算(E_{2+}) - (E_{2-})可得
:f(x+2h) - f(x-2h) = 4hf'(x) + \frac{8h^3}{3}f^{(3)}(x) + O_2(h^5). \qquad (E_2).
為了消去ƒ(3)(x),計算8 × (E1) − (E2)
:8f(x+h) - 8f(x-h) - f(x+2h) + f(x-2h) = 12h f'(x) + O(h^5)
可以得到上式。注意:公式中f的係數(8, -8,-1,1)是更通用的例子。
誤差估計
此近似的誤差的階數是 h 4,可以用下式展開求得
: \frac{-f(x+2 h)+8 f(x+h)-8 f(x-h)+f(x-2h)}{12 h}=f'(x)-\frac{1}{30} f^{(5)}(x) h^4+O(h^5)
可以用泰勒级数的的左邊展開求得。另外,對格點上f'(x)的中心差分近似,間距是2h和h,應用理查森外推法也可得到類似結果。
一維更高階導數
可以用五點模版的中心差分公式,求得更高階的導數如下
: \begin{align}
f*(x) &\approx \frac{-f(x+2 h)+16 f(x+h)-30 f(x) + 16 f(x-h) - f(x-2h)}{12 h^2}
\\[1ex]
f^{(3)}(x) &\approx \frac{f(x+2 h)-2 f(x+h) + 2 f(x-h) - f(x-2h)}{2 h^3}
\\[1ex]
f^{(4)}(x) &\approx \frac{f(x+2 h)-4 f(x+h)+6 f(x) - 4 f(x-h) + f(x-2h)}{h^4}
\end{align}
上述近似的誤差分別是O(h)、O(h)和O(h),說明如下:
用函數對x和y的三點模版二階導數可得:
:\begin{align}
\frac{\partial ^2 f}{\partial x^2} &=
\frac{f\left(x + \Delta x,y\right) + f\left(x - \Delta x,y\right) - 2f(x,y)}{\Delta x^2} - 2\frac{f^{(4)}(x,y)}{4!} \Delta x^2 + \cdots \\[1ex]
\frac{\partial ^2 f}{\partial y^2} &=
\frac{f\left(x, y + \Delta y\right) + f\left(x, y - \Delta y\right) - 2f(x,y)}{\Delta y^2} - 2\frac{f^{(4)}(x,y)}{4!} \Delta y^2 + \cdots
\end{align}
若假設\Delta x = \Delta y = h:
:\begin{align}
\nabla^2 f &= \frac{\partial ^2 f}{\partial x^2} + \frac{\partial ^2 f}{\partial y^2} \\[1ex]
&= \frac{f\left(x + h,y\right) + f\left(x - h,y\right) + f\left(x, y + h\right) + f\left(x, y - h\right) - 4f(x,y)}{h^2} - 4 \frac{f^{(4)}(x,y)}{4!}h^2 + \cdots \\[1ex]
&= \frac{f\left(x + h,y\right) + f\left(x - h,y\right) + f\left(x, y + h\right) + f\left(x, y - h\right) - 4f(x,y)}{h^2} + O\left(h^2\right)\\
\end{align}
相關條目
- 有限差分係數
*
- 九點模版
- 模版 (數值分析)
*
參考資料
- . Ninth printing. Table 25.2.
评论 (0)