We’ve previously covered forward, backward, and central difference approximations for a function’s first and second derivatives. These approximations have convergence orders of 1 and 2, but what about approximations with greater convergence rates?
In this section, we discuss a general method for developing these methods. Recall Taylor Polynomials from Chapter 1.
These approximations are with convergence order of 1 and 2; however what about higher convergne rate approximations.
4.3.1. Higher-order approximations of the first derivative of a function
Now, it follows from \(x = x_{i} + h\) and \(c = x_{i}\) that,
(4.32)\[\begin{align}
f(x_{i} + h) & = \sum_{j = 0}^{n} \frac{f^{(j)}(x_{i})}{j!} (x_{i} + h - x_{i})^{j}
+ \mathcal{O}(h^{n+1})
\notag \\ &
= \sum_{j = 0}^{n} \frac{f^{(j)}(x_{i})}{j!} h^{j} + \mathcal{O}(h^{n+1}).
\end{align}\]
Similarly,
(4.33)\[\begin{align}
f(x_{i} - 2\,h) & = \sum_{j = 0}^{n} \frac{f^{(j)}(x_{i})}{j!} (-2\,h)^{j} + \mathcal{O}(h^{n+1}),\\
f(x_{i} - h) & = \sum_{j = 0}^{n} \frac{f^{(j)}(x_{i})}{j!} (-h)^{j} + \mathcal{O}(h^{n+1}),\\
f(x_{i} + h) & = \sum_{j = 0}^{n} \frac{f^{(j)}(x_{i})}{j!} (h)^{j} + \mathcal{O}(h^{n+1}),\\
f(x_{i} + 2\,h) & = \sum_{j = 0}^{n} \frac{f^{(j)}(x_{i})}{j!} (2\,h)^{j} + \mathcal{O}(h^{n+1}).
\end{align}\]
Let \(f_{i+j}\) be \(f(x_i+ jh)\) for \(j \in \mathbb{Z}\). The above can be polynomials can be expressed as follows,
(4.34)\[\begin{align}
\begin{cases}
f_{i+2} & = f_{i} + 2hf_{i}' + 2 h^2 f_{i}'' + \dfrac{4}{3} h^3 f_{i}^{(3)} + \dfrac{2}{3} h^4 f_{i}^{(4)} + \mathcal{O}(h^5),
\\
f_{i+1} & = f_{i} + hf_{i}' + \dfrac{1}{2} h^2 f_{i}'' + \dfrac{1}{6} h^3 f_{i}^{(3)} + \dfrac{1}{24} h^4 f_{i}^{(4)} + \mathcal{O}(h^5),
\\
f_{i-1} & = f_{i} - hf_{i}' + \dfrac{1}{2} h^2 f_{i}'' - \dfrac{1}{6} h^3 f_{i}^{(3)} + \dfrac{1}{24} h^4 f_{i}^{(4)} + \mathcal{O}(h^5),
\\
f_{i-2} & = f_{i} - 2hf_{i}' + 2 h^2 f_{i}'' - \dfrac{4}{3} h^3 f_{i}^{(3)} + \dfrac{2}{3} h^4 f_{i}^{(4)} + \mathcal{O}(h^5). \end{cases}
\end{align}\]
For example, to develop a fourth-order approximation for the first derivative of a function using five points, we can solve the following linear system for \(a_{j}\) with \(0\leq j \leq 4\).
(4.35)\[\begin{align}\label{4th-order-eq}
h f'(x_i) = \sum_{j = -2}^{2} a_{j+2} f_{i+j} & = a_{0}f_{i-2} + a_{1}f_{i-1} + a_{2}f_{i} + a_{3}f_{i+1} + a_{4}f_{i+2}
\notag \\ &
= a_{0}\left(f_{i} - 2hf_{i}' + 2h^2 f_{i}'' - \frac{4}{3} h^3 f_{i}^{(3)} + \frac{2}{3} h^4 f_{i}^{(4)} \right)
\notag \\ &
+ a_{1}\left( f_{i} - hf_{i}' + \frac{1}{2} h^2 f_{i}'' - \frac{1}{6} h^3 f_{i}^{(3)} + \frac{1}{24} h^4 f_{i}^{(4)} \right)
\notag \\ &
+ a_{2}f_{i}
\notag \\ &
+ a_{3}\left( f_{i} + hf_{i}' + \frac{1}{2} h^2 f_{i}'' + \frac{1}{6} h^3 f_{i}^{(3)} + \frac{1}{24} h^4 f_{i}^{(4)} \right)
\notag \\ &
+ a_{4}\left( f_{i} + 2hf_{i}' + 2h^2 f_{i}'' + \frac{4}{3} h^3 f_{i}^{(3)} + \frac{2}{3} h^4 f_{i}^{(4)} \right)+ \mathcal{O}(h^5).
\end{align}\]
In other words,
(4.36)\[\begin{align}
h f'(x_i) &= \left(a_{0}f_{i} - 2h\,a_{0}f_{i}' + 2h^2\,a_{0} f_{i}'' - \frac{4}{3} h^3 \,a_{0}f_{i}^{(3)} + \frac{2}{3} h^4 \,a_{0}f_{i}^{(4)} \right)
\notag \\ &
+ \left( a_{1}f_{i} - h\,a_{1}f_{i}' + \frac{1}{2} h^2 \,a_{1} f_{i}'' - \frac{1}{6} h^3 \,a_{1} f_{i}^{(3)} + \frac{1}{24} h^4 \,a_{1} f_{i}^{(4)} \right)
\notag \\ &
+ a_{2}f_{i}
\notag \\ &
+ \left( a_{3} f_{i} + h\,a_{3}f_{i}' + \frac{1}{2} h^2 \,a_{3} f_{i}'' + \frac{1}{6} h^3 \,a_{3} f_{i}^{(3)} + \frac{1}{24} h^4 \,a_{3} f_{i}^{(4)} \right)
\notag \\ &
+ \left( a_{4}f_{i} + 2h\,a_{4}f_{i}' + 2h^2 \,a_{4}f_{i}'' + \frac{4}{3} h^3 \,a_{4}f_{i}^{(3)} + \frac{2}{3} h^4 \,a_{4}f_{i}^{(4)} \right)+ \mathcal{O}(h^5).
\end{align}\]
or
(4.37)\[\begin{align}
h f'(x_i) &= \left(a_{0} + a_{1} + a_{2} + a_{3} + a_{4}\right)f_{i}
\notag \\ &
+ \left(- 2a_{0} - a_{1} + 0\,a_{2} + a_{3} + 2a_{4} \right)h\,f_{i}'
\notag \\ &
+ \left(2a_{0} +\dfrac{1}{2} a_{1} + 0a_{2} + \dfrac{1}{2} a_{3} + 2a_{4}\right)h^2 \,f_{i}''
\notag \\ &
+ \left(-\dfrac{4}{3}a_{0} -\dfrac{1}{6} a_{1} + 0a_{2} + \dfrac{1}{6} a_{3} + \dfrac{4}{3}a_{4} \right)h^3 \,f_{i}^{(3)}
\notag \\ &
+\left(\dfrac{2}{3}a_{0} +\dfrac{1}{24} a_{1} + 0a_{2} + \dfrac{1}{24} a_{3} + \dfrac{2}{3}a_{4}\right)h^4 \,f_{i}^{(4)} + \mathcal{O}(h^5).
\end{align}\]
Now since \(h>0\), it follows that
(4.38)\[\begin{align}
\begin{cases}
a_{0} + a_{1} + a_{2} + a_{3} +a_{4} &=0, \\
-2a_{0} - a_{1} + 0a_{2} + a_{3} +2a_{4} &=1, \\
2a_{0} +\dfrac{1}{2} a_{1} + 0a_{2} + \dfrac{1}{2} a_{3} + 2a_{4} &=0, \\
-\dfrac{4}{3}a_{0} -\dfrac{1}{6} a_{1} + 0a_{2} + \dfrac{1}{6} a_{3} + \dfrac{4}{3}a_{4} &=0, \\
\dfrac{2}{3}a_{0} +\dfrac{1}{24} a_{1} + 0a_{2} + \dfrac{1}{24} a_{3} + \dfrac{2}{3}a_{4} &=0.
\end{cases}
\end{align}\]
The solution to the system can be found as follows,
(4.39)\[\begin{equation}
\left[\begin{array}{ccccc} 1 & 1 & 1 & 1 & 1\\ -2 & -1 & 0 & 1 & 2\\ 2 & \frac{1}{2} & 0 & \frac{1}{2} & 2\\ -\frac{4}{3} & -\frac{1}{6} & 0 & \frac{1}{6} & \frac{4}{3}\\ \frac{2}{3} & \frac{1}{24} & 0 & \frac{1}{24} & \frac{2}{3} \end{array}\right]
\left[\begin{array}{c}a_{0}\\a_{1}\\a_{2}\\a_{3}\\a_{4}\end{array}\right]=
\left[\begin{array}{c} 0\\ 1\\ 0\\ 0\\ 0 \end{array}\right].
\end{equation}\]
Therefore,
(4.40)\[\begin{align}
\left[\begin{array}{c}a_{0}\\a_{1}\\a_{2}\\a_{3}\\a_{4}\end{array}\right] & =
\left[\begin{array}{ccccc} 1 & 1 & 1 & 1 & 1\\ -2 & -1 & 0 & 1 & 2\\ 2 & \frac{1}{2} & 0 & \frac{1}{2} & 2\\ -\frac{4}{3} & -\frac{1}{6} & 0 & \frac{1}{6} & \frac{4}{3}\\ \frac{2}{3} & \frac{1}{24} & 0 & \frac{1}{24} & \frac{2}{3} \end{array}\right]^{-1}
\left[\begin{array}{c} 0\\ 1\\ 0\\ 0\\ 0 \end{array}\right]
\notag \\
&= \left[\begin{array}{ccccc} 0 & \frac{1}{12} & -\frac{1}{12} & -\frac{1}{2} & 1\\ 0 & -\frac{2}{3} & \frac{4}{3} & 1 & -4\\ 1 & 0 & -\frac{5}{2} & 0 & 6\\ 0 & \frac{2}{3} & \frac{4}{3} & -1 & -4\\ 0 & -\frac{1}{12} & -\frac{1}{12} & \frac{1}{2} & 1 \end{array}\right]
\left[\begin{array}{c} 0\\ 1\\ 0\\ 0\\ 0 \end{array}\right]
=
\left[\begin{array}{r} \frac{1}{12}\\ -\frac{2}{3}\\ 0\\ \frac{2}{3}\\ -\frac{1}{12} \end{array}\right],
%\stackrel{~or~}{=}\frac{1}{12} \left[\begin{array}{c} 1\\ -8\\ 0\\ 8\\ -1 \end{array}\right]
\end{align}\]
We have,
(4.41)\[\begin{equation}
f'(x_{i}) = \frac{1}{h}
\left(\frac{1}{12}f_{i-2} - \frac{2}{3}f_{i-1} + \frac{2}{3}f_{i+1} - \frac{1}{12}f_{i+2}\right) + \mathcal{O}(h^4).
\end{equation}\]
Thus,
(4.42)\[\begin{align}
{f'(x_{i}) \approx \frac{1}{h}\left(\frac{1}{12}f_{i-2} - \frac{2}{3}f_{i-1} + \frac{2}{3}f_{i+1} - \frac{1}{12}f_{i+2}\right).}
\end{align}\]
\subsection{Higher-order approximations of the second derivative of a function}
Similarly,
(4.43)\[\begin{align}\label{2ndder_4thorder_eq01}
h^2 f''(x_i) = \sum_{j = -2}^{2} a_{j+2} f_{i+j}
&= a_{0}f_{i-2} + a_{1}f_{i-1} + a_{2}f_{i} + a_{3}f_{i+1} + a_{4}f_{i+2}
\notag \\ &= a_{0}\left(f_{i} - 2hf_{i}' + 2h^2 f_{i}'' - \frac{4}{3} h^3 f_{i}^{(3)} + \frac{2}{3} h^4 f_{i}^{(4)} \right)
\notag \\ &
+ a_{1}\left( f_{i} - hf_{i}' + \frac{1}{2} h^2 f_{i}'' - \frac{1}{6} h^3 f_{i}^{(3)} + \frac{1}{24} h^4 f_{i}^{(4)} \right)
\notag \\ &
+ a_{2}f_{i}
\notag \\ &
+ a_{3}\left( f_{i} + hf_{i}' + \frac{1}{2} h^2 f_{i}'' + \frac{1}{6} h^3 f_{i}^{(3)} + \frac{1}{24} h^4 f_{i}^{(4)} \right)
\notag \\ &
+ a_{4}\left( f_{i} + 2hf_{i}' + 2h^2 f_{i}'' + \frac{4}{3} h^3 f_{i}^{(3)} + \frac{2}{3} h^4 f_{i}^{(4)} \right)+ \mathcal{O}(h^5).
\end{align}\]
Therefore,
(4.44)\[\begin{align}
h^2 f''(x_i) &= \left(a_{0} + a_{1} + a_{2} + a_{3} +a_{4}\right)f_{i}
\notag \\ &
+ \left(-2a_{0} - a_{1} + 0a_{2} + a_{3} +2a_{4}\right)h\,f_{i}'
\notag \\ &
+ \left(2a_{0} +\frac{1}{2} a_{1} + 0a_{2} + \dfrac{1}{2} a_{3} + 2a_{4}\right)h^2\,f_{i}''
\notag \\ &
+ \left( -\dfrac{4}{3}a_{0} -\dfrac{1}{6} a_{1} + 0a_{2} + \dfrac{1}{6} a_{3} + \dfrac{4}{3}a_{4}\right)h^3\,f_{i}^{(3)}
\notag \\ &
+ \left(\dfrac{2}{3}a_{0} +\dfrac{1}{24} a_{1} + 0a_{2} + \dfrac{1}{24} a_{3} + \dfrac{2}{3}a_{4}\right)h^4\,f_{i}^{(4)}
+ \mathcal{O}(h^5).
\end{align}\]
Since \(h>0\), it follows that
(4.45)\[\begin{align}
\begin{cases}
a_{0} + a_{1} + a_{2} + a_{3} +a_{4} &=0, \\
-2a_{0} - a_{1} + 0a_{2} + a_{3} +2a_{4} &=0, \\
2a_{0} +\dfrac{1}{2} a_{1} + 0a_{2} + \dfrac{1}{2} a_{3} + 2a_{4} &=1, \\
-\dfrac{4}{3}a_{0} -\dfrac{1}{6} a_{1} + 0a_{2} + \dfrac{1}{6} a_{3} + \dfrac{4}{3}a_{4} &=0, \\
\dfrac{2}{3}a_{0} +\dfrac{1}{24} a_{1} + 0a_{2} + \dfrac{1}{24} a_{3} + \dfrac{2}{3}a_{4} &=0.
\end{cases}
\end{align}\]
The solution to the system can be found as follows,
(4.46)\[\begin{equation}
\left[\begin{array}{ccccc} 1 & 1 & 1 & 1 & 1\\ -2 & -1 & 0 & 1 & 2\\ 2 & \frac{1}{2} & 0 & \frac{1}{2} & 2\\ -\frac{4}{3} & -\frac{1}{6} & 0 & \frac{1}{6} & \frac{4}{3}\\ \frac{2}{3} & \frac{1}{24} & 0 & \frac{1}{24} & \frac{2}{3} \end{array}\right]
\left[\begin{array}{c}a_{0}\\a_{1}\\a_{2}\\a_{3}\\a_{4}\end{array}\right]=
\left[\begin{array}{c} 0\\ 0\\ 1\\ 0\\ 0 \end{array}\right].
\end{equation}\]
Therefore,
(4.47)\[\begin{align}\label{2ndder_4thorder_eq04}
\left[\begin{array}{c}a_{0}\\a_{1}\\a_{2}\\a_{3}\\a_{4}\end{array}\right] & =
\left[\begin{array}{ccccc} 1 & 1 & 1 & 1 & 1\\ -2 & -1 & 0 & 1 & 2\\ 2 & \frac{1}{2} & 0 & \frac{1}{2} & 2\\ -\frac{4}{3} & -\frac{1}{6} & 0 & \frac{1}{6} & \frac{4}{3}\\ \frac{2}{3} & \frac{1}{24} & 0 & \frac{1}{24} & \frac{2}{3} \end{array}\right]^{-1}
\left[\begin{array}{c} 0\\ 0\\ 1\\ 0\\ 0 \end{array}\right]
\notag \\
&= \left[\begin{array}{ccccc} 0 & \frac{1}{12} & -\frac{1}{12} & -\frac{1}{2} & 1\\ 0 & -\frac{2}{3} & \frac{4}{3} & 1 & -4\\ 1 & 0 & -\frac{5}{2} & 0 & 6\\ 0 & \frac{2}{3} & \frac{4}{3} & -1 & -4\\ 0 & -\frac{1}{12} & -\frac{1}{12} & \frac{1}{2} & 1 \end{array}\right]
\left[\begin{array}{c} 0\\ 0\\ 1\\ 0\\ 0 \end{array}\right]
=
\left[\begin{array}{r} -\frac{1}{12}\\ \frac{4}{3}\\ -\frac{5}{2}\\ \frac{4}{3}\\ -\frac{1}{12} \end{array}\right].
\end{align}\]
Using the above coefficients, we have,
(4.48)\[\begin{equation}\label{2ndder_4thorder_eq02}
f''(x_i) = \frac{1}{h^2}\left(-\frac{1}{12}f_{i-2} + \frac{4}{3}f_{i-1} -\frac{5}{2} f_{i} + \frac{4}{3}f_{i+1} -\frac{1}{12}f_{i+2}\right) + \mathcal{O}(h^4).
\end{equation}\]
Thus,
(4.49)\[\begin{align}\label{2ndder_4thorder_eq03}
{f''(x_i) \approx \frac{1}{h^2}\left(-\frac{1}{12}f_{i-2} + \frac{4}{3}f_{i-1} -\frac{5}{2} f_{i} + \frac{4}{3}f_{i+1} -\frac{1}{12}f_{i+2}\right).}
\end{align}\]
4.3.2. Higher-order approximations of the second derivative of a function
Similarly,
(4.50)\[\begin{align}
h^2 f''(x_i) = \sum_{j = -2}^{2} a_{j+2} f_{i+j}
&= a_{0}f_{i-2} + a_{1}f_{i-1} + a_{2}f_{i} + a_{3}f_{i+1} + a_{4}f_{i+2}
\notag \\ &= a_{0}\left(f_{i} - 2hf_{i}' + 2h^2 f_{i}'' - \frac{4}{3} h^3 f_{i}^{(3)} + \frac{2}{3} h^4 f_{i}^{(4)} \right)
\notag \\ &
+ a_{1}\left( f_{i} - hf_{i}' + \frac{1}{2} h^2 f_{i}'' - \frac{1}{6} h^3 f_{i}^{(3)} + \frac{1}{24} h^4 f_{i}^{(4)} \right)
\notag \\ &
+ a_{2}f_{i}
\notag \\ &
+ a_{3}\left( f_{i} + hf_{i}' + \frac{1}{2} h^2 f_{i}'' + \frac{1}{6} h^3 f_{i}^{(3)} + \frac{1}{24} h^4 f_{i}^{(4)} \right)
\notag \\ &
+ a_{4}\left( f_{i} + 2hf_{i}' + 2h^2 f_{i}'' + \frac{4}{3} h^3 f_{i}^{(3)} + \frac{2}{3} h^4 f_{i}^{(4)} \right)+ \mathcal{O}(h^5).
\end{align}\]
Therefore,
(4.51)\[\begin{align}
h^2 f''(x_i) &= \left(a_{0} + a_{1} + a_{2} + a_{3} +a_{4}\right)f_{i}
\notag \\ &
+ \left(-2a_{0} - a_{1} + 0a_{2} + a_{3} +2a_{4}\right)h\,f_{i}'
\notag \\ &
+ \left(2a_{0} +\frac{1}{2} a_{1} + 0a_{2} + \dfrac{1}{2} a_{3} + 2a_{4}\right)h^2\,f_{i}''
\notag \\ &
+ \left( -\dfrac{4}{3}a_{0} -\dfrac{1}{6} a_{1} + 0a_{2} + \dfrac{1}{6} a_{3} + \dfrac{4}{3}a_{4}\right)h^3\,f_{i}^{(3)}
\notag \\ &
+ \left(\dfrac{2}{3}a_{0} +\dfrac{1}{24} a_{1} + 0a_{2} + \dfrac{1}{24} a_{3} + \dfrac{2}{3}a_{4}\right)h^4\,f_{i}^{(4)}
+ \mathcal{O}(h^5).
\end{align}\]
Since \(h>0\), it follows that
(4.52)\[\begin{align}
\begin{cases}
a_{0} + a_{1} + a_{2} + a_{3} +a_{4} &=0, \\
-2a_{0} - a_{1} + 0a_{2} + a_{3} +2a_{4} &=0, \\
2a_{0} +\dfrac{1}{2} a_{1} + 0a_{2} + \dfrac{1}{2} a_{3} + 2a_{4} &=1, \\
-\dfrac{4}{3}a_{0} -\dfrac{1}{6} a_{1} + 0a_{2} + \dfrac{1}{6} a_{3} + \dfrac{4}{3}a_{4} &=0, \\
\dfrac{2}{3}a_{0} +\dfrac{1}{24} a_{1} + 0a_{2} + \dfrac{1}{24} a_{3} + \dfrac{2}{3}a_{4} &=0.
\end{cases}
\end{align}\]
The solution to the system can be found as follows,
(4.53)\[\begin{equation}
\left[\begin{array}{ccccc} 1 & 1 & 1 & 1 & 1\\ -2 & -1 & 0 & 1 & 2\\ 2 & \frac{1}{2} & 0 & \frac{1}{2} & 2\\ -\frac{4}{3} & -\frac{1}{6} & 0 & \frac{1}{6} & \frac{4}{3}\\ \frac{2}{3} & \frac{1}{24} & 0 & \frac{1}{24} & \frac{2}{3} \end{array}\right]
\left[\begin{array}{c}a_{0}\\a_{1}\\a_{2}\\a_{3}\\a_{4}\end{array}\right]=
\left[\begin{array}{c} 0\\ 0\\ 1\\ 0\\ 0 \end{array}\right].
\end{equation}\]
Therefore,
(4.54)\[\begin{align}
\left[\begin{array}{c}a_{0}\\a_{1}\\a_{2}\\a_{3}\\a_{4}\end{array}\right] & =
\left[\begin{array}{ccccc} 1 & 1 & 1 & 1 & 1\\ -2 & -1 & 0 & 1 & 2\\ 2 & \frac{1}{2} & 0 & \frac{1}{2} & 2\\ -\frac{4}{3} & -\frac{1}{6} & 0 & \frac{1}{6} & \frac{4}{3}\\ \frac{2}{3} & \frac{1}{24} & 0 & \frac{1}{24} & \frac{2}{3} \end{array}\right]^{-1}
\left[\begin{array}{c} 0\\ 0\\ 1\\ 0\\ 0 \end{array}\right]
\notag \\
&= \left[\begin{array}{ccccc} 0 & \frac{1}{12} & -\frac{1}{12} & -\frac{1}{2} & 1\\ 0 & -\frac{2}{3} & \frac{4}{3} & 1 & -4\\ 1 & 0 & -\frac{5}{2} & 0 & 6\\ 0 & \frac{2}{3} & \frac{4}{3} & -1 & -4\\ 0 & -\frac{1}{12} & -\frac{1}{12} & \frac{1}{2} & 1 \end{array}\right]
\left[\begin{array}{c} 0\\ 0\\ 1\\ 0\\ 0 \end{array}\right] =
\left[\begin{array}{r} -\frac{1}{12}\\ \frac{4}{3}\\ -\frac{5}{2}\\ \frac{4}{3}\\ -\frac{1}{12} \end{array}\right].
\end{align}\]
Using the above coefficients, we have,
(4.55)\[\begin{equation}
f''(x_i) = \frac{1}{h^2}\left(-\frac{1}{12}f_{i-2} + \frac{4}{3}f_{i-1} -\frac{5}{2} f_{i} + \frac{4}{3}f_{i+1} -\frac{1}{12}f_{i+2}\right) + \mathcal{O}(h^4).
\end{equation}\]
Thus,
(4.56)\[\begin{align}
{f''(x_i) \approx \frac{1}{h^2}\left(-\frac{1}{12}f_{i-2} + \frac{4}{3}f_{i-1} -\frac{5}{2} f_{i} + \frac{4}{3}f_{i+1} -\frac{1}{12}f_{i+2}\right).}
\end{align}\]
Example:
Consider \(f(x) = 3x\,\exp(x) - \cos(x) + \sin(x)\). This function is defined and continuous on [0,1]. Discretize \([0,1]\) using \(h=0.01\). Then,
\[\begin{equation*}
\{0.02,~0.03,~0.04, \ldots,~0.97,~0.98\}.
\end{equation*}\]
Solution:
a.
\[\begin{align*}
f'(x_i) & \approx \frac{1}{h}\left(\frac{1}{12}f_{i-2} - \frac{2}{3}f_{i-1} - \frac{2}{3}f_{i+1} + \frac{1}{12}f_{i+2}\right),\\
f''(x_i) & \approx \frac{1}{h^2}\left(-\frac{1}{12}f_{i-2} + \frac{4}{3}f_{i-1} -\frac{5}{2} f_{i} + \frac{4}{3}f_{i+1} -\frac{1}{12}f_{i+2}\right).
\end{align*}\]
For \hl{\(x_{2} = 0.02\)}, since \(f(x_i+ jh)\) and \(h=0.01\), we have,
\[\begin{align*}
f'(0.02) & \approx \frac{1}{h}\left( \frac{1}{12}f(0.02 -2h) - \frac{2}{3}f(0.02 -h) - \frac{2}{3}f(0.02 + h) + \frac{1}{12}f(0.02 + 2h) \right)
\\ & = \frac{1}{0.01}\left( \frac{1}{12}f(0) - \frac{2}{3}f(0.01) - \frac{2}{3}f(0.03) + \frac{1}{12}f(0.04) \right) = 3.141815.
\end{align*}\]
Similarly,
\[\begin{align*}
f'(0.03) & \approx \frac{1}{0.01}\left( \frac{1}{12}f(0.01) - \frac{2}{3}f(0.02) - \frac{2}{3}f(0.04) + \frac{1}{12}f(0.05) \right) = 3.214100,\\
f'(0.04) & \approx \frac{1}{0.01}\left( \frac{1}{12}f(0.02) - \frac{2}{3}f(0.03) - \frac{2}{3}f(0.05) + \frac{1}{12}f(0.06) \right) = 3.287319,\\
\vdots &\\
f'(0.97) & \approx \frac{1}{0.01}\left( \frac{1}{12}f(0.95) - \frac{2}{3}f(0.96) - \frac{2}{3}f(0.98) + \frac{1}{12}f(0.99) \right) = 16.415137,\\
f'(0.98) & \approx \frac{1}{0.01}\left( \frac{1}{12}f(0.96) - \frac{2}{3}f(0.97) - \frac{2}{3}f(0.99) + \frac{1}{12}f(1.00) \right) = 16.657367.
\end{align*}\]
\[\begin{align*}
E_{h}(\text{Fourth-order approximation of the first derivative}) &= \max_{i}\left|
f'(x) - \frac{1}{h}\left(\frac{1}{12}f_{i-2} - \frac{2}{3}f_{i-1} - \frac{2}{3}f_{i+1} + \frac{1}{12}f_{i+2}\right)
\right|,\\
E_{h}(\text{Fourth-order approximation of the second derivative})&= \max_{i}\left|
f''(x) - \frac{1}{h^2}\left(-\frac{1}{12}f_{i-2} + \frac{4}{3}f_{i-1} -\frac{5}{2} f_{i} + \frac{4}{3}f_{i+1} -\frac{1}{12}f_{i+2}\right)
\right|.
\end{align*}\]
\[\max_{i}\left|
f'(x) - \frac{1}{h}\left(\frac{1}{12}f_{i-2} - \frac{2}{3}f_{i-1} - \frac{2}{3}f_{i+1} + \frac{1}{12}f_{i+2}\right)
\right| = 1.6211e-08\]
\[\max_{i}\left|
f''(x) - \frac{1}{h^2}\left(-\frac{1}{12}f_{i-2} + \frac{4}{3}f_{i-1} -\frac{5}{2} f_{i} + \frac{4}{3}f_{i+1} -\frac{1}{12}f_{i+2}\right)
\right| = 6.2761e-09\]
The order of convergence numerically:
|
h |
N |
Max Error (First Derivative) |
Max Error (Second Derivative) |
0 |
0.125000 |
8.0000e+00 |
2.6196e-04 |
1.0311e-04 |
1 |
0.062500 |
1.6000e+01 |
2.0369e-05 |
7.9286e-06 |
2 |
0.031250 |
3.2000e+01 |
1.4193e-06 |
5.4997e-07 |
3 |
0.015625 |
6.4000e+01 |
9.3660e-08 |
3.6226e-08 |
4 |
0.007812 |
1.2800e+02 |
6.0149e-09 |
2.3790e-09 |