This post presents the central finite difference(FD) system build in stagger grid. Symmetric scheme are derived and examples are presented.
Taylor expansion
As always, we start the derivation from taylor expansion. For the red points in the below staggerd point, function value here have the form of taylor series expanded in the blue point. This kind of stagger grid scheme is widely used in modeling.
f(x−iδ2)=f(x)−iδ2f′(x)+i2δ2222!f″(x)−i3δ3233!f(3)(x)+...+i2Nδ2N22N(2N)!f(2N)(x)+O(δ2N+1)...f(x−δ2)=f(x)−δ2f′(x)+δ2222!f″(x)−δ3233!f(3)(x)+...+δ2N22N(2N)!f(2N)(x)+O(δ2N+1)f(x+δ2)=f(x)+δ2f′(x)+δ2222!f″(x)+δ3233!f(3)(x)+...+δ2N22N(2N)!f(2N)(x)+O(δ2N+1)...f(x+iδ2)=f(x)+iδ2f′(x)+i2δ2222!f″(x)+i3δ3233!f(3)(x)+...+i2Nδ2N22N(2N)!f(2N)(x)+O(δ2N+1)(i=1,3,5,7,9...)First order derivatives
f(x+δ2)−f(x−δ2)2=δ2f′(x)+δ3233!f(3)(x)+...+δ2N−122N−1(2N−1)!f(2N−1)(x)+O(δ2N+1)...f(x+iδ2)−f(x−iδ2)2=iδ2f′(x)+i3δ3233!f(3)(x)+...+i2N−1δ2N−122N−1(2N−1)!f(2N−1)(x)+O(δ2N+1)(i=1,3,5,7,9...)or in the forms of:
f′(x)=f(x+δ2)−f(x−δ2)δ−δ2223!f(3)(x)−...−δ2N−222N−2(2N−1)!f(2N−1)(x)+O(δ2N)...f′(x)=f(x+iδ2)−f(x−iδ2)iδ−i2δ2223!f(3)(x)−...−i2N−2δ2N−222N−2(2N−1)!f(2N−1)(x)+O(δ2N)adding all these f′(x) propotionally together:
f′(x)∑iCi=∑iCif(x+iδ2)−f(x−iδ2)iδ−δ2223!f(3)(x)∑ii2Ci−δ4245!f(5)(x)∑ii4Ci−δ2N−222N−2(2N−1)!f(2N−1)(x)∑ii2N−2Ci+O(δ2N)(i=1,3,5,7,9...,2N−1)So, for 2Nth order accuracy, Ck must be the solution of linear equation:
[1111...11325272...(2N−1)21345474...(2N−1)4...132N−252N−272N−2...(2N−1)2N−2][C1C3C5...C2N−1]=[100...0](16) is the vandermonde equation, its augmented matrix corresponds to the upper triangular linear equation:
[1111...101a23a24...a2N001a34...a3N...0000...1][x1x2x3...xN]=[b1b−2b−3...bN]while
aij=[(2j−1)2−(2i−3)2][(2j−1)2−(2i−5)2]...[(2j−1)2−1][(2i−1)2−(2i−3)2][(2i−1)2−(2i−5)2]...[(2i−1)2−1](j≥i)bi=(−1)i−11232...(2i−3)2[(2i−1)2−(2i−3)2][(2i−1)2−(2i−5)2]...[(2i−1)2−1]Thus, xi have the value of:
{xi=C2i−1=bi−N∑j=i+1aijxjxN=C2N−1=bNConclusion
From (15), the FD scheme of 2Nth order accuracy is built:
f′(x)=∑iCif(x+iδ2)−f(x−iδ2)iδor in the form of:
{f′(x)=1δ∑ici[f(x+iδ2)−f(x−iδ2)]ci=Cii(i=1,3,5,7,9...)Values of ci for different accuracy order are:
order | c1 | c2 | c3 | c4 | c5 | c6 |
---|---|---|---|---|---|---|
2 | 11 | |||||
4 | 98 | −124 | ||||
6 | 7564 | −25384 | 3640 | |||
8 | 12251024 | −2453072 | 495120 | −57168 | ||
10 | 1984516384 | −7358192 | 56740960 | −405229376 | 35294912 | |
12 | 160083131072 | −12705131072 | 228691310720 | −54451835008 | 8472359296 | −632883584 |
Examples
FD scheme corresponding to accuracy orders of 2,4,6,8,10,12 are implemented to f(x)=sin(x), their FD results are ploted versus theoretical first order derivative of f′(x)=cos(x), as well as their error.