Question 6.1: Derive a centered finite difference formula for the second d...
Derive a centered finite difference formula for the second derivative using four evaluation points.
Learn more on how we answer questions.
For each evaluation point, we need to use the Taylor series
y(x) = y(x_i)+y^′(x−x_i)+\frac{1}{2}y^{′′}(x−xi)^2 +\frac{1}{6}y^{′′′}(x−xi)^3+\frac{1}{24}y^{′′′′}(x−xi)^4+··· (6.2.14)
to produce the equations
y_{i+2}=y_i+y^\prime (2\Delta x)+\frac{1}{2} y^{\prime \prime }(2\Delta x)^2 +\frac{1}{6}y^{\prime \prime \prime }(2\Delta x)^3+\frac{1}{24} y^{\prime \prime \prime \prime } (2\Delta x)^4+··· (6.2.15)
y_{i+1}=y_i+y^\prime (\Delta x)+\frac{1}{2} y^{\prime \prime }(\Delta x)^2 +\frac{1}{6}y^{\prime \prime \prime }(\Delta x)^3+\frac{1}{24} y^{\prime \prime \prime \prime } (\Delta x)^4+··· (6.2.16)
y_{i-1}=y_i+y^\prime (-\Delta x)+\frac{1}{2} y^{\prime \prime }(-\Delta x)^2 +\frac{1}{6}y^{\prime \prime \prime }(-\Delta x)^3+\frac{1}{24} y^{\prime \prime \prime \prime } (-\Delta x)^4+··· (6.2.17)
y_{i-2}=y_i+y^\prime (-2\Delta x)+\frac{1}{2} y^{\prime \prime }(-2\Delta x)^2 +\frac{1}{6}y^{\prime \prime \prime }(-2\Delta x)^3+\frac{1}{24} y^{\prime \prime \prime \prime } (-2\Delta x)^4+··· (6.2.18)
The idea is to multiply each equation by some weight c_i and add them together to remove all the derivatives except for y^{′′}. This leads to the system of equations
\begin{bmatrix} 2& 1& −1& −2\\ 4 &1 &1 &4 \\ 8& 1& −1& −8\\ 16& 1& 1& 16 \end{bmatrix} \begin{bmatrix} c_{i+2} \\c_{i+1} \\c_{i−1} \\c_{i−2} \end{bmatrix} =\begin{bmatrix} 0 \\ 2 \\ 0 \\0 \end{bmatrix} (6.2.19)
where we chose the value of 2 on the right-hand side to cancel the factor of 1/2 in the second derivative. We can solve by Gauss elimination to get
\begin{bmatrix} c_{i+2} \\c_{i+1} \\c_{i−1} \\c_{i−2} \end{bmatrix}=\frac{1}{12}\begin{bmatrix} −1 \\ 16 \\ 16 \\ −1 \end{bmatrix} (6.2.20)
Adding up the equations with these coefficients gives
\frac{−y_{i+2} + 16y_{i+1} + 16y_{i−1} − y_{i−2}}{12}=\frac{30}{12}y_i+y^{\prime \prime } \Delta x^2 (6.2.21)
Solving for the derivative gives
y^{\prime \prime}= \frac{−y_{i+2} + 16y_{i+1} -30y_i+ 16y_{i−1} − y_{i−2}}{12\Delta x^2} (6.2.22)
What is the advantage of the higher-order formula? Let’s look at the error. If we continued our expansion out to the fifth derivatives, the weights and coefficients give
\frac{-(2\Delta x)^5+16(\Delta x)^5+16(-\Delta x)^5-(-2\Delta x)^5}{12}=0 (6.2.23)
so the terms cancel out. When we take the expansion out to sixth derivatives we get a non-zero result,
\frac{-(2\Delta x)^6+16(\Delta x)^6+16(-\Delta x)^6-(-2\Delta x)^6}{12}=-8\Delta x^6 (6.2.24)
Since we divided by Δx^2, the error is O( Δx^4).
This is one possible approach to derive higher-order finite difference approximations. We will discuss an alternate approach in the context of interpolation in Section 8.2.4.