Skip to main content
Mathematics LibreTexts

2.02: Numerical Differentiation of Continuous Functions

  • Page ID
    126395

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

    Lesson 1: Numerical Differentiation of Continuous Functions - First Derivative

    Learning Objectives

    After successful completion of this lesson, you should be able to:

    1) derive formulas for approximating the first derivative of a function,

    2) use the developed formulas in examples to estimate derivatives of a function.

    Introduction

    The first derivative of a function \(f\left( x \right)\) at \(x\) is defined as

    \[f^{\prime}\left( x \right) = \lim_{h \rightarrow 0}\frac{f\left( x + h \right) - f\left( x \right)}{h} \nonumber\]

    To be able to find a derivative numerically, one could make \(h\) finite to give,

    \[f^{\prime}\left( x \right) \approx \frac{f\left( x + h \right) - f\left( x \right)}{h}. \nonumber\]

    Knowing the value of \(x\) at which you want to find the derivative of \(f\left( x \right)\), we choose a finite value of \(h\) to find the value of \(f^{\prime}\left( x \right)\). To estimate the value of \(f^{\prime}\left( x \right)\), one such approximation is suggested as follows.

    Forward Difference Approximation of the First Derivative

    For a finite \(h\),

    \[f^{\prime}\left( x \right) \approx \frac{f\left( x + h \right) - f\left( x \right)}{h}\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{1.1}) \nonumber\]

    The above is the forward divided difference approximation of the first derivative. It is called forward because you are taking a point ahead of \(x\).

    Graphical representation of forward difference approximation of first derivative.
    Figure \(\PageIndex{1.1}\). Graphical representation of forward difference approximation of first derivative.
    Example \(\PageIndex{1.1}\)

    The velocity of a rocket is given by

    \[v\left( t \right) = 2000\ln\left\lbrack \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100t} \right\rbrack - 9.8t,\ 0 \leq t \leq 30 \nonumber\]

    where \(v\) is given in m/s and \(t\) is given in seconds. At \(t = 16\ \text{s}\),

    a) use the forward difference approximation of the first derivative of \(v\left( t \right)\) to calculate the acceleration. Use a step size of \(h = 2\ \text{s}\).

    b) find the exact value of the acceleration of the rocket.

    c) calculate the absolute relative true error for part (b).

    Solution

    (a) \[a\left( t \right) \approx \frac{v\left( t + h \right) - v\left( t \right)}{h} \nonumber\]

    \[t = 16 \nonumber\]

    \[h = 2 \nonumber\]

    \[\displaystyle a\left( 16 \right) \approx \frac{v\left( 18 \right) - v\left( 16 \right)}{2} \nonumber\]

    \[\begin{split} v\left( 18 \right) &= 2000\ln\left\lbrack \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100\left( 18 \right)} \right\rbrack - 9.8\left( 18 \right)\\ &= 453.02 \ \text{m/s}\end{split} \nonumber\]

    \[\begin{split} v\left( 16 \right) &= 2000\ln\left\lbrack \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100\left( 16 \right)} \right\rbrack - 9.8\left( 16 \right)\\ &= 392.07 \ \text{m/s}\end{split} \nonumber\]

    Hence

    \[\begin{split} a\left( 16 \right) &\approx \frac{v\left( 18 \right) - v\left( 16 \right)}{2}\\ &= \frac{453.02 - 392.07}{2}\\ &= 30.474 \ \text{m/s}^{2}\end{split} \nonumber\]

    (b) The exact value of \(a\left( 16 \right)\) can be calculated by differentiating

    \[v\left( t \right) = 2000\ln\left\lbrack \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100t} \right\rbrack - 9.8t \nonumber\]

    as

    \[a\left( t \right) = \frac{d}{dt}\left\lbrack v\left( t \right) \right\rbrack \nonumber\]

    Knowing that

    \[\frac{d}{dt}\left\lbrack \ln\left( at \right) \right\rbrack = \frac{1}{t},\ \text{and} \nonumber\]

    \[\frac{d}{dt}\left\lbrack \frac{a}{b - ct} \right\rbrack = - \frac{ac}{(b - ct)^{2}} \nonumber\]

    \[\begin{split} a\left( t \right) &= 2000\left( \frac{14 \times 10^{4} - 2100t}{14 \times 10^{4}} \right)\frac{d}{dt}\left( \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100t} \right) - 9.8\\ &= 2000\left( \frac{14 \times 10^{4} - 2100t}{14 \times 10^{4}} \right)\left( - 1 \right)\left( \frac{(14 \times 10^{4})\left( - 2100 \right)}{\left( 14 \times 10^{4} - 2100t \right)^{2}} \right) - 9.8\\ &= \frac{- 4040 - 29.4t}{- 200 + 3t}\end{split} \nonumber\]

    \[\begin{split} a\left( 16 \right) &= \frac{- 4040 - 29.4\left( 16 \right)}{- 200 + 3\left( 16 \right)}\\ &= 29.674\text{ m/s}^{2}\end{split} \nonumber\]

    (c) The absolute relative true error is

    \[\begin{split} \left| \epsilon_{t} \right| &= \left| \frac{\text{True Value} - \text{Approximate Value}}{\text{True Value}} \right| \times 100\\ &= \left| \frac{29.674 - 30.474}{29.674} \right| \times 100\\ &= 2.6967\% \end{split} \nonumber\]

    Audiovisual Lecture

    Title: Forward Divided Difference

    Summary: Learn the forward divided difference formula to approximate the first derivative of a function.

    Backward Difference Approximation of the First Derivative

    We know

    \[f^{\prime}\left( x \right) = \lim_{h \rightarrow 0}\frac{f\left( x + h \right) - f\left( x \right)}{h} \nonumber\]

    For a finite \(h\),

    \[f^{\prime}\left( x \right) \approx \frac{f\left( x + h \right) - f\left( x \right)}{h} \nonumber\]

    If \(h\) is chosen as a negative number,

    \[\begin{split} f^{\prime}\left( x \right) &\approx \frac{f\left( x - h \right) - f\left( x \right)}{- h}\\ &= \frac{f\left( x \right) - f\left( x - h \right)}{h}\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{1.2}) \end{split} \nonumber\]

    This is a backward difference approximation as you are taking a point backward from \(x\).

    Graphical representation of backward difference approximation of the first derivative.
    Figure \(\PageIndex{1.2}\). Graphical representation of backward difference approximation of the first derivative
    Example \(\PageIndex{1}\)

    The velocity of a rocket is given by

    \[v\left( t \right) = 2000\ln\left\lbrack \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100t} \right\rbrack - 9.8t,\ 0 \leq t \leq 30 \nonumber\]

    (a) Use the backward difference approximation of the first derivative of \(v\left( t \right)\) to calculate the acceleration at \(t = 16\ \text{s}\). Use a step size of \(h = 2\ \text{s}\).

    (b) Find the absolute relative true error for part (a).

    Solution

    (a) \[a\left( t \right) \approx \frac{v\left( t + h \right) - v\left( t \right)}{h} \nonumber\]

    \[t = 16 \nonumber\]

    \[h = 2 \nonumber\]

    \[a\left( 16 \right) \approx \frac{v\left( 16 \right) - v\left( 14 \right)}{2} \nonumber\]

    \[\begin{split} v\left( 16 \right) &= 2000\ln\left\lbrack \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100\left( 16 \right)} \right\rbrack - 9.8\left( 16 \right)\\ &= 392.07\ \text{m/s} \end{split} \nonumber\]

    \[\begin{split} v\left( 14 \right) &= 2000\ln\left\lbrack \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100\left( 14 \right)} \right\rbrack - 9.8\left( 14 \right)\\ &= 334.24\ \text{m/s} \end{split} \nonumber\]

    \[\begin{split} a\left( 16 \right) &\approx \frac{v\left( 16 \right) - v\left( 14 \right)}{2}\\ &= \frac{392.07 - 334.24}{2}\\ &= 28.915\ \text{m/s}^{2}\end{split} \nonumber\]

    (b) The exact value of the acceleration at \(t = 16\ \text{s}\) from Example \(\PageIndex{1.1}\) is

    \[a\left( 16 \right) = 29.674\ \text{m/s}^{2} \nonumber\]

    The absolute relative true error for the answer in part (a) is

    \[\begin{split} \left| \epsilon_{t} \right| &= \left| \frac{29.674 - 28.915}{29.674} \right| \times 100\\ &= 2.5584\% \end{split} \nonumber\]

    Audiovisual Lecture

    Title: Backward Divided Difference

    Summary: Learn the backward divided difference formula to approximate the first derivative of a function.

    Central Divided Difference Approximation of the First Derivative

    If we took a point forward and backward of \(x\) by a distance of \(h\), then the slope of the secant line (Rise/Run) as shown in Figure \(\PageIndex{1.3}\), and approximating it as the first derivative of the function at \(h,\)

    \[\begin{split} f^{\prime}\left( x \right) &\approx \frac{f\left( x + h \right) - f\left( x - h \right)}{\left( x + h \right) - (x - h)}\\ &= \frac{f\left( x + h \right) - f\left( x - h \right)}{2h}\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{1.3})\end{split} \nonumber\]

    Graphical representation of central difference approximation of first derivative.
    Figure \(\PageIndex{1.3}\). Graphical representation of central difference approximation of first derivative.
    Example \(\PageIndex{1.3}\)

    The velocity of a rocket is given by

    \[v\left( t \right) = 2000\ln\left\lbrack \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100t} \right\rbrack - 9.8t, \ 0 \leq t \leq 30. \nonumber\]

    (a) Use the central difference approximation of the first derivative of \(v\left( t \right)\) to calculate the acceleration at \(t = 16\ \text{s}\). Use a step size of \(h = 2\ \text{s}\).

    (b) Find the absolute relative true error for part (a).

    Solution

    (a) \[a(t)\approx \frac{v(t+h) -v( t-h)}{2h} \nonumber\]

    \[t = 16 \nonumber\]

    \[h = 2 \nonumber\]

    \[\begin{split} a\left( 16 \right) &\approx \frac{v\left( 16 + 2 \right) - v\left( 16 - 2 \right)}{2\left( 2 \right)}\\ &= \frac{v\left( 18 \right) - v\left( 14 \right)}{4}\end{split} \nonumber\]

    \[\begin{split} v\left( 18 \right) &= 2000\ln\left\lbrack \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100\left( 18 \right)} \right\rbrack - 9.8\left( 18 \right)\\ &= 453.02\ \text{m/s}\end{split} \nonumber\]

    \[\begin{split} v\left( 14 \right) &= 2000\ln\left\lbrack \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100\left( 14 \right)} \right\rbrack - 9.8\left( 14 \right)\\ &= 334.24\ \text{m/s}\end{split} \nonumber\]

    \[\begin{split} a\left( 16 \right) &\approx \frac{v\left( 18 \right) - v\left( 14 \right)}{4}\\ &= \frac{453.02 - 334.24}{4}\\ &= 29.694\ \text{m/s}^{2}\end{split} \nonumber\]

    (b) The exact value of the acceleration at \(t = 16\ \text{s}\) from Example \(\PageIndex{1.1}\) was found as

    \[a\left( 16 \right) = 29.674\ \text{m/s}^{2} \nonumber\]

    The absolute relative true error for the answer in part (a) is

    \[\begin{split} \left| \epsilon_{t} \right| &= \left| \frac{\text{True Value} - \text{Approximate Value}}{\text{True Value}} \right| \times 100\\ &= \left| \frac{29.674 - 29.694}{29.674} \right| \times 100\\ &= 0.069157\% \end{split} \nonumber\]

    Audiovisual Lecture

    Title: Central Divided Difference

    Summary: Learn the central divided difference formula to approximate the first derivative of a function.

    Order of Accuracy of Divided Difference Schemes

    When using the divided difference schemes, errors are introduced due to their approximate nature. However the order of the error is not the same.

    The order of accuracy in the forward divided difference method is of \(O\left( h \right).\)

    \[f^{\prime}\left( x \right) = \frac{f\left( x + h \right) - f\left( x \right)}{h} + O\left( h \right)\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{1.4}) \nonumber\]

    The order of accuracy in the backward divided difference method is of \(O\left( h \right).\)

    \[f^{\prime}\left( x \right) = \frac{f\left( x \right) - f\left( x-h \right)}{h} + O\left( h \right) \;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{1.5}) \nonumber\]

    The order of accuracy in the central divided difference method is of \(O\left( h^2 \right).\)

    \[f^{\prime}(x) = \frac{f(x+h) - f( x-h)}{2h} + O\left( h^2 \right) \;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{1.6}) \nonumber\]

    The derivation and application of the order of the accuracy of the three divided difference schemes as given by Equations \((\PageIndex{1.4}) \text{-} (\PageIndex{1.6})\) is given in the next lesson in the textbook.

    Lesson 2: Numerical Differentiation of Continuous Functions - Second Derivative

    Learning Objectives

    After successful completion of this lesson, you should be able to:

    1) derive formulas for approximating for higher-order derivatives,

    2) use the developed formulas in examples to find higher derivatives of a function

    Introduction

    We used trigonometry and calculus to find the approximation of the first derivatives in the previous lessons. To find higher-order derivatives by such means is cumbersome and hinders a general approach to developing the numerical methods of approximating derivatives of any order.

    One can use the Taylor series to approximate a higher-order derivative. As an illustration, here we derive the central difference approximation of the second derivative of a function \(f\left( x \right)\) .

    The Taylor series is given by

    \[f\left( x + h \right) = f\left( x \right) + f^{\prime}\left( x \right)\ h + \frac{f^{\prime\prime}\left( x \right)}{2!}\left( h \right)^{2} + \frac{f^{\prime\prime\prime}\left( x \right)}{3!}\left( h \right)^{3} + \frac{f^{\prime\prime\prime\prime}(x)}{4!}{(h)}^{4} + \ldots\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{2.1}) \nonumber\]

    We can rewrite the Taylor series by substituting \(- h\) for \(h\),

    \[f\left( x - h \right) = f\left( x \right) + f^{\prime}\left( x \right)\ ( - h) + \frac{f^{\prime\prime}\left( x \right)}{2!}\left( - h \right)^{2} + \frac{f^{\prime\prime\prime}\left( x \right)}{3!}\left( - h \right)^{3} + \frac{f^{\prime\prime\prime\prime}(x)}{4!}{( - h)}^{4}+\ldots \nonumber\]

    to get

    \[f\left( x - h \right) = f\left( x \right) - f^{\prime}\left( x \right)\ h + \frac{f^{\prime\prime}\left( x \right)}{2!}h^{2} - \frac{f^{\prime\prime\prime}\left( x \right)}{3!}h^{3} + \frac{f^{\prime\prime\prime\prime}(x)}{4!}h^{4}+\ldots\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{2.2}) \nonumber\]

    Adding Equations \((\PageIndex{2.1})\) and \((\PageIndex{2.2})\) gives

    \[f\left( x + h \right) + f\left( x - h \right) = 2f\left( x \right) + 2\frac{f^{\prime\prime}\left( x \right)}{2!}h^{2} + 2\frac{f^{\prime\prime\prime\prime}(x)}{4!}h^{4} + \ldots \nonumber\]

    Moving all terms other than the \(f^{\prime\prime}\left( x \right)\) to the left side gives

    \[f\left( x + h \right) + f\left( x - h \right) - 2f\left( x \right) - 2\frac{f^{\prime\prime\prime\prime}(x)}{4!}h^{4} - \ldots = f^{\prime\prime}\left( x \right)h^{2} \nonumber\]

    \[f^{\prime\prime}\left( x \right) = \frac{f\left( x + h \right) - 2f\left( x \right) + f\left( x - h \right)}{h^{2}} - 2\frac{f^{\prime\prime\prime\prime}(x)}{4!}h^{2} - \ldots \nonumber\]

    Hence

    \[f^{\prime\prime}\left( x \right) \approx \frac{f\left( x + h \right) - 2f\left( x \right) + f\left( x - h \right)}{h^{2}}\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{2.3}) \nonumber\]

    Example \(\PageIndex{2.1}\)

    The velocity of a rocket is given by

    \[v\left( t \right) = 2000\ln\left\lbrack \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100t} \right\rbrack - 9.8t,\ 0 \leq t \leq 30 \nonumber\]

    (a) Use the central difference approximation of the second derivative of \(v\left( t \right)\) to calculate the jerk at \(t = 16\ \text{s}\). Use a step size of \(h = 2\ \text{s}\).

    (b) Calculate the exact value of the jerk at \(t = 16\ \text{s}\).

    Solution

    (a) The second derivative of velocity with respect to time is called jerk. The second-order approximation of jerk then is

    \[j\left( t \right) \approx \frac{v\left( t + h \right) - 2v\left( t \right) + v\left( t - h \right)}{h^{2}} \nonumber\]

    \[t = 16 \nonumber\]

    \[h = 2 \nonumber\]

    \[\begin{split} t + h &= 16 + 2\\ &= 18\end{split}\] \[\begin{split} t - h &= 16 - 2\\ &= 14\end{split} \nonumber\]

    \[j\left( 16 \right) \approx \frac{v\left( 18 \right) - 2v\left( 16 \right) + v\left( 14 \right)}{\left( 2 \right)^{2}} \nonumber\]

    \[\begin{split} v\left( 18 \right)&= 2000\ln\left\lbrack \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100\left( 18 \right)} \right\rbrack - 9.8\left( 18 \right)\\ &= 453.02 \text{ m/s}\end{split} \nonumber\]

    \[\begin{split} v\left( 16 \right) &= 2000\ln\left\lbrack \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100\left( 16 \right)} \right\rbrack - 9.8\left( 16 \right)\\ &= 392.07\ \text{m/s}\end{split} \nonumber\]

    \[\begin{split} v\left( 14 \right) &= 2000\ln\left\lbrack \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100\left( 14 \right)} \right\rbrack - 9.8\left( 14 \right)\\ &= 334.24\ \text{m/s}\end{split} \nonumber\]

    Hence

    \[\begin{split} j\left( 16 \right) &\approx \frac{v\left( 18 \right) - 2v\left( 16 \right) + v\left( 14 \right)}{\left( 2 \right)^{2}}\\ &= \frac{453.02 - 2\left( 392.07 \right) + 334.24}{4}\\ &= 0.77969\ \text{m/s}^{3}\end{split} \nonumber\]

    (b) The exact value of \(j\left( 16 \right)\) can be calculated by performing two successive differentiations of

    \[v\left( t \right) = 2000\ln\left\lbrack \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100t} \right\rbrack - 9.8t. \nonumber\]

    Now

    \[a\left( t \right) = \frac{d}{dt}\left\lbrack v\left( t \right) \right\rbrack \nonumber\]

    Knowing that

    \[\frac{d}{dt}\left\lbrack \ln\left( {at} \right) \right\rbrack = \frac{1}{t},\ \text{and} \nonumber\]

    \[\frac{d}{dt}\left\lbrack \frac{a}{b - ct} \right\rbrack = - \frac{ac}{(b - ct)^{2}} \nonumber\]

    \[\begin{split} a\left( t \right) &= 2000\left( \frac{14 \times 10^{4} - 2100t}{14 \times 10^{4}} \right)\frac{d}{dt}\left( \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100t} \right) - 9.8\\ &= 2000\left( \frac{14 \times 10^{4} - 2100t}{14 \times 10^{4}} \right)\left( - 1 \right)\left( \frac{(14 \times 10^{4})\left( - 2100 \right)}{\left( 14 \times 10^{4} - 2100t \right)^{2}} \right) - 9.8\\ &= \frac{- 4040 - 29.4t}{- 200 + 3t}\end{split} \nonumber\]

    \[\begin{split} j\left( t \right) &= \frac{d}{dt}\left\lbrack a\left( t \right) \right\rbrack\\ &= \frac{d}{dt}\left\lbrack \frac{- 4040 - 29.4t}{- 200 + 3t} \right\rbrack \end{split} \nonumber\]

    Knowing that

    \[\frac{d}{dt}\left\lbrack \frac{a + bt}{c + dt} \right\rbrack = - \frac{ad - bc}{(c + dt)^{2}}, \nonumber\]

    we get

    \[j\left( t \right) = \frac{18000}{( - 200 + 3t)^{2}}. \nonumber\]

    Hence

    \[\begin{split} j\left( 16 \right) &= - \frac{\left( - 4040)(3 \right) - \left( - 29.4 \right)( - 200)}{\left( - 200 + 3\left( 16 \right) \right)^{2}}\\ &= 0.77908\ \text{m/s}^{3}\end{split} \nonumber\]

    The absolute relative true error is

    \[\begin{split} \left| \epsilon_{t} \right| &= \left| \frac{\text{True Value} - \text{Approximate Value}}{\text{True Value}} \right| \times 100\\ &= \left| \frac{0.77908 - 0.77969}{0.77908} \right| \times 100\\ &= 0.077992\% \end{split} \nonumber\]

    Audiovisual Lecture

    Title: Differentiation of Continuous Functions – Second Derivative: Theory

    Summary: Learn how you can use the Taylor series to derive finite difference formulas for the second derivative of a function.

    Lesson 3: Error Analysis of Finite Difference Approximations

    Learning Objectives

    After successful completion of this lesson, you should be able to:

    1) derive formulas from the Taylor series for approximating the first derivative of a function,

    2) find the order of accuracy of divided difference formulas

    3) use the order of accuracy results to derive more efficient numerical methods such as Richardson’s extrapolation formula.

    Introduction

    The finite difference formulas we develop in previous lessons for the first and second derivatives of a function are approximate, as they have a truncation error.

    Look at the example from the previous lessons, which asked to find the value of the acceleration (first derivative) at \(t = 16{s}\) using a step size of \(h = 2{ s}\) by forward, backward, and central divided difference formulas. The velocity of a rocket was given by

    \[v\left( t \right) = 2000\ln\left\lbrack \frac{14 \times 10^{4}}{14 \times 10^{4} - 2100t} \right\rbrack - 9.8t,0 \leq t \leq 30. \nonumber\]

    The results, along with the relative approximate true errors from the three difference approximations, are given in Table \(\PageIndex{3.1}\).

    Table \(\PageIndex{3.1}\). Summary of \(a\left( {16} \right)\) using different difference approximations

    \(\text{Type of difference approximation}\)

    \(a(16)\)

    \(({m/}{s^2})\)

    \(\left | \epsilon_{t} \right|\%\)

    \(\text{Forward}\)

    \(\text{Backward}\)

    \(\text{Central}\)

    \(30.475\)

    \(28.915\)

    \(29.695\)

    \(2.6967\)

    \(2.5584\)

    \(0.069157\)

    So the question arises that why is the central divided difference (CDD) approximation better than the forward divided difference (FDD) and backward divided difference (BDD) approximations. Is it an isolated case? The true errors in the forward and backward divided difference approximations are of the same order. Is that also an isolated case? To illustrate this, we derive the order of accuracy of the three divided difference schemes.

    Example \(\PageIndex{3.1}\)

    The forward divided difference scheme for finding the approximate first derivative of a function \(f\left( x \right)\) is given by

    \[f^{\prime}\left( x \right) \approx \frac{f\left( x + h \right) - f\left( x \right)}{h} \nonumber\]

    Show that the order of the accuracy of the above formula is of the order of \(h\).

    Solution

    Taylor’s theorem says that if you know the value of a function \(f(x)\) at a point \(x\) and all its derivatives at that point, provided the derivatives are continuous between \(x\) and \(x + h\), then

    \[f\left( x + h \right) = f\left( x \right) + f^{\prime}\left( x \right)h + \frac{f^{\prime\prime}\left( x \right)}{2!}h^{2} + \frac{f^{\prime\prime\prime}\left( x \right)}{3!}h^{3} + \ldots\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.E1.1}) \nonumber\]

    Taking the first term of the right-hand side of Equation \((\PageIndex{3.E1.1})\) to the left-hand side gives

    \[f\left( x + h \right) - f\left( x \right) = f^{\prime}\left( x \right)h + \frac{f^{\prime\prime}\left( x \right)}{2!}h^{2} + \frac{f^{\prime\prime\prime}\left( x \right)}{3!}h^{3} + \ldots \nonumber\]

    Taking the first derivative term to the left-hand side and the function terms to the right-hand side gives

    \[f^{\prime}\left( x \right)h = f\left( x + h \right) - f\left( x \right) - \frac{f^{\prime\prime}\left( x \right)}{2!}h^{2} - \frac{f^{\prime\prime\prime}\left( x \right)}{3!}h^{3} - \ldots \nonumber\]

    Dividing both sides by \(h\), to find \(f^{\prime}\left( x \right)\), gives

    \[f^{\prime}\left( x \right) = \frac{f\left( x + h \right) - f\left( x \right)}{h} - \frac{f^{\prime\prime}\left( x \right)}{2!}h - \frac{f^{\prime\prime\prime}\left( x \right)}{3!}h^{2} - \ldots\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.E1.2}) \nonumber\]

    The truncation error in the FDD formula for \(f^\prime(x)\) is hence given by

    \[E_{t} = - \frac{f^{\prime\prime}\left( x \right)}{2!}h - \frac{f^{\prime\prime\prime}\left( x \right)}{3!}h^{2} - \ldots\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.E1.3}) \nonumber\]

    For small values of \(h\), the predominant terms will be the first one in Equation \((\PageIndex{1.6})\), and hence the order of accuracy is determined to be of the \(O\left( h \right).\)

    \[f^{\prime}\left( x \right) = \frac{f\left( x + h \right) - f\left( x \right)}{h} + O\left( h \right)\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.E1.4}) \nonumber\]

    If you repeat the process for BDD, you will find the same order of accuracy

    \[f^{\prime}\left( x \right) = \frac{f\left( x \right) - f\left( x-h \right)}{h} + O\left( h \right) \text{ for BDD.} \;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.E1.5}) \nonumber\]

    Example \(\PageIndex{3.2}\)

    The central divided difference scheme for finding the approximate first derivative of a function \(f\left( x \right)\) is given by

    \[f^{\prime}\left( x \right) \approx \frac{f\left( x + h \right) - f\left( x - h \right)}{2h} \nonumber\]

    Show that the order of the accuracy of the above formula is of the order of \(h^{2}\).

    Solution

    Using the Taylor series, we write the value of the function \(f\left( x \right)\) at \(\left( x + h \right)\) in terms of the value of the function and its derivatives at \(x\) as

    \[f\left( x + h \right) = f\left( x \right) + f^{\prime}\left( x \right)h + \frac{f^{\prime\prime}\left( x \right)}{2!}h^{2} + \frac{f^{\prime\prime\prime}\left( x \right)}{3!}h^{3} + \frac{f^{\prime\prime\prime\prime}\left( x \right)}{4!}h^{4} + \frac{f^{\prime\prime\prime\prime\prime}\left( x \right)}{5!}h^{5} + \ldots\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.E2.1}) \nonumber\]

    Using the Taylor series again, we write the value of the function \(f\left( x \right)\) at \(\left( x - h \right)\) in terms of the value of the function and its derivatives at \(x\) simply by substituting \(\left( - h \right)\) for \(h\) in Equation \((\PageIndex{3.E2.1})\)

    \[\begin{split} f\left( x - h \right) &= f\left( x \right) + f^{\prime}\left( x \right)( - h) + \frac{f^{\prime\prime}\left( x \right)}{2!}( - h)^{2} + \frac{f^{\prime\prime\prime}\left( x \right)}{3!}( - h)^{3} + \frac{f^{\prime\prime\prime\prime}\left( x \right)}{4!}\left( - h \right)^{4}\\ & \ \ \ + \frac{f^{\prime\prime\prime\prime\prime}\left( x \right)}{5!}{( - h)}^{5} + \ldots\\ &=f(x)-f^{\prime} (x)h + \frac{f^{\prime\prime}(x)}{2!}h^2 - \frac{f^{\prime\prime\prime}(x)}{3!}h^3+\frac{f^{\prime\prime\prime\prime}(x)}{4!}h^4-\frac{f^{\prime\prime\prime\prime\prime}(x)}{5!}h^5+\ldots\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.E2.2}) \end{split} \nonumber\]

    Subtracting Equation \((\PageIndex{3.E2.2})\) from Equation \((\PageIndex{3.E2.1})\) gives

    \[f\left( x + h \right) - f\left( x - h \right) = 2f^{\prime}\left( x \right)h + \frac{2f^{\prime\prime\prime}\left( x \right)}{3!}h^{3} + \frac{2f^{\prime\prime\prime\prime\prime}\left( x \right)}{5!}h^{5} + \ldots\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.E2.3}) \nonumber\]

    Taking the first derivative term to the left-hand side and the function terms to the right-hand side

    \[2f^{\prime}\left( x \right)h = f\left( x + h \right) - f\left( x - h \right) - \frac{2f^{\prime\prime\prime}\left( x \right)}{3!}h^{3} - \frac{2f^{\prime\prime\prime\prime\prime}\left( x \right)}{5!}h^{5} + \ldots\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.E2.4}) \nonumber\]

    Dividing both sides by \(2h\), to find \(f^{\prime}\left( x \right)\) gives

    \[f^{\prime}\left( x \right) = \frac{f\left( x + h \right) - f\left( x - h \right)}{2h} - \frac{f^{\prime\prime\prime}\left( x \right)}{3!}h^{2} - \frac{f^{\prime\prime\prime\prime\prime}\left( x \right)}{5!}h^{4} - \ldots\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.E2.5}) \nonumber\]

    The truncation error in the CDD formula for \(f^{\prime}\left( x \right)\) is hence given by

    \[E_{t} = - \frac{f^{\prime\prime\prime}\left( x \right)}{3!}h^{2} - \frac{f^{\prime\prime\prime\prime\prime}\left( x\right)}{5!}h^{4} - \ldots\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.E2.6}) \nonumber\]

    For small values of \(h\), the predominant terms will be the first one in Equation \((\PageIndex{3.E2.6})\), and hence the order of accuracy is determined to be of the \(O\left( h^{2} \right).\)

    \[f^{\prime}\left( x \right) = \frac{f\left( x + h \right) - f\left( x - h \right)}{2h} + O\left( h^{2} \right)\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.E2.7}) \nonumber\]

    Since the order of accuracy is higher for CDD than FDD and BDD, the true error being much smaller in CDD is not an isolated incident. Since the order of accuracy is of similar order in FDD and BDD, the true error being of a similar order for FDD and BDD is not an isolated incident either.

    Example \(\PageIndex{3.3}\)

    To further investigate the issue of the true error for CDD being of the order of the square of the step size, that is, \(h^2\), take the example of being asked to find the approximate value of the first derivative of \(2e^{1.5x}\)at \(x = 3\) using CDD scheme. The exact value (up to 5 significant digits) using differential calculus is found to be \(=270.05\). The central divided difference approximation of the first derivative with \(h = 0.1\) and then continuing to halve the step size are given in Table \(\PageIndex{3.2}\).

    Table \(\PageIndex{3.2}\). Effect of step size on the error in CDD.

    \(\text{Step Size,}\)

    \(h\)

    \(\text{Central Divided Difference Approximation}\)

    \(\frac{f(x+h) - f(x-h)}{2h}\)

    \(\text{True Error} = \text{True Value} - \text{Approximate Value}\)

    \(0.1\) \(271.07\) \(-1.0138\)
    \(0.05\) \(270.30\) \(-0.25324\)
    \(0.025\) \(270.11\) \(-0.06330\)
    \(0.0125\) \(270.06\) \(-0.015824\)
    \(0.00625\) \(270.05\) \(-0.0039558\)

    Comment on your observation of how the true error reduces with the step size.

    Solution

    In Table \(\PageIndex{3.2}\), we can observe that as the step size is halved, the true error is getting approximately quartered. This observation is in line with the derivation of the true error being of the order of \(h^{2}\). Let’s look at the contribution of the truncation terms as the step size decreases. That information is given in Table \(\PageIndex{3.3}\). The second column shows the true error.

    Table \(\PageIndex{3.3}\). Contribution to true error as step size decreases in CDD.

    \(\text{step size}\)

    \(h\)

    \(\text{True Error}\)

    \(E_t\)

    \(\text{First Term of True Error}\)

    \(-\displaystyle\frac{f^{\prime\prime\prime}(x_i)}{3!}h^2\)

    \(\text{Rest of the True Error}\)

    \(-\displaystyle\frac{f^{\prime\prime\prime\prime\prime}(x_i)}{5!}h^4-...\)

    \(\text{True Error divided by}\)

    \(h^2\)

    \(0.1\) \(-1.0138\) \(-1.0127\) \(- 1. 1399 \times 10^{- 3}\) \(-101.38\)
    \(0.05\) \(-0.25324\) \(-0.25317\) \(- 7. 1216 \times 10^{- 5}\) \(-101.30\)
    \(0.025\) \(-0.06330\) \(-0.063293\) \(- 4. 4520 \times 10^{- 6}\) \(-101.27\)
    \(0.0125\) \(-0.015824\) \(-0.015823\) \(- 2. 7970 \times 10^{- 7}\) \(-101.27\)
    \(0.00625\) \(-0.0039558\) \(-0.0039556\) \(- 1. 8955 \times 10^{- 8}\) \(-101.27\)

    In Table \(\PageIndex{3.3}\), you are able to see that the magnitude of the first term of the true error is much bigger than the magnitude of the rest of the true error terms and hence dominates the magnitude of the true error. Note that the value of the true error divided by \(h^{2}\) also gets close to be a constant as \({h }\)becomes smaller. In fact, the value would converge to the coefficient term of \(h^{2}\) in the true error term in Equation \((\PageIndex{3.E2.6})\) which is \(110.27\) and is calculated as follows.

    \[f\left( x \right) = 2e^{1.5x} \nonumber\]

    \[\begin{split} f^{\prime}(x) &= 2(1.5)e^{1.5x}\\ &= 3e^{1.5x} \end{split} \nonumber\]

    \[\begin{split} f^{\prime\prime}\left( x \right) &= 3(1.5)e^{1.5x}\\ &= 4.5e^{1.5x} \end{split} \nonumber\]

    \[\begin{split} f^{\prime\prime\prime}\left( x \right) &= 4.5(1.5)e^{1.5x}\\ &= 6.750e^{1.5x} \end{split} \nonumber\]

    Hence,

    \[\begin{split} \frac{f^{\prime\prime\prime}(x)}{3!}\ &= \frac{6.750e^{1.5x}}{3!}\\ &= 110.27 \end{split} \nonumber\]

    This value of \(110.27\) is close to the number we have in the last column of Table \(\PageIndex{3.3}\) as \(h\) becomes small.

    Audiovisual Lecture

    Title: Accuracy of Finite Difference Formulas for Differentiation

    Summary: This video discusses the accuracy of the finite difference formulas for finding the derivative of a function.

    Richardson’s Extrapolation Formula for Central Divided Difference Approximation of First Derivative

    Recognizing that the true error in the central divided difference formula for the first derivative is of the order the square of the step size, it allows us to develop more computationally efficient formulas for differentiation. These formulas are called Richardson’s extrapolation formulas for numerical differentiation.

    Since the true error

    \[E_{t} = O(h^{2}) \nonumber\]

    \[E_{t} \approx Ch^{2}\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.1}) \nonumber\]

    Let \((AV)_{h}\) denote the approximate value of the first derivative as calculated by using the equation

    \[f^{\prime}\left( x \right) \approx \frac{f\left( x + h \right) - f\left( x - h \right)}{2h}\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.2}) \nonumber\]

    and using the definition

    \[E_{t} = \text {True Value - Approximate Value}\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.3}) \nonumber\]

    we get,

    \[Ch^{2} \approx \left( {TV} \right) - (AV)_{h}\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.4}) \nonumber\]

    where,

    \[{TV} = \text{True value} \nonumber\]

    If we decrease the step size by half to \(\displaystyle \frac{h}{2}\) , and \(\displaystyle (AV)_{\frac{h}{2}}\) denotes the approximate value of the first derivative calculated using the central divided difference equation, then

    \[\displaystyle C\left( \frac{h}{2} \right)^{2} \approx \left( {TV} \right) - {({AV})}_{\frac{h}{2}}\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.5}) \nonumber\]

    Multiplying Equation \((\PageIndex{3.5})\) by \(4\) gives

    \[Ch^{2} \approx 4\left( {TV} \right) - 4{({AV})}_{\frac{h}{2}}\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.6}) \nonumber\]

    Subtracting Equation \((\PageIndex{3.6})\) from Equation \((\PageIndex{3.4})\) gives

    \[Ch^{2} - Ch^{2} \approx \left( \left( {TV} \right) - \left( {AV} \right)_{h} \right) - \left( 4\left( {TV} \right) - 4({AV})_{\frac{h}{2}} \right) \nonumber\]

    \[0 \approx - 3\left( {TV} \right) - \left( {AV} \right)_{h} + 4({AV})_{\frac{h}{2}} \nonumber\]

    Taking the \(\left( {TV} \right)\) term to the left side,

    \[\displaystyle \begin{split} 3\left( {TV} \right) &\approx - \left( {AV} \right)_{h} + 4{({AV})}_{\frac{h}{2}}\\ \left( {TV} \right) &\approx \frac{- \left( {AV} \right)_{h} + 4{({AV})}_{\frac{h}{2}}}{3} \end{split}\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.7}) \nonumber\]

    The above formula will allow us to find a better estimate of the first derivative just from the approximate values obtained using the step sizes \(h\) and \(\displaystyle \frac{h}{2}\) .

    Equation \((\PageIndex{3.7})\) is generally rewritten as

    \[\begin{split} \left( {TV} \right) &\approx \frac{- \left( {AV} \right)_{h} + 3\left( {AV} \right)_{\frac{h}{2}} + \left( {AV} \right)_{\frac{h}{2}}}{3}\\ &=(AV)_{\frac{h}{2}} + \frac{(AV)_{\frac{h}{2}}-(AV)_{h}}{3}\end{split}\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.8}) \nonumber\]

    One of the reasons to write it this way is to show that adding a third of the difference between the approximate values obtained using step sizes of \(h\) and \(\displaystyle \frac{h}{2}\) to the most recent approximate value will give you a better estimate of the true value.

    Example \(\PageIndex{3.4}\)

    Table 4 shows the approximate values of the first derivative of \(f\left( x \right) = 2e^{1.5x}\) at \(x = 3\) using different step sizes for the central divided difference scheme. Use the last two values of the scheme and Richardson’s extrapolation formula to get a better estimate of \(f^{\prime}(3)\).

    Table \(\PageIndex{3.4}\). CDD approximate values as a function of step size.

    \(\text{Step Size,}\)

    \(h\)

    \(\text{Central Divided Difference Approximation}\)

    \(0.1\) \(271.07\)
    \(0.05\) \(270.30\)
    \(0.025\) \(270.11\)
    Solution

    Using the last two values, we have

    \[{({AV})}_{0.05} \approx 270.30 \nonumber\]

    \[{({AV})}_{0.025} \approx 270.11 \nonumber\]

    Using Equation \((\PageIndex{3.8})\)

    \[\begin{split} TV &\approx {\ ({AV})}_{\frac{h}{2}} + \frac{\left( {AV} \right)_{\frac{h}{2}} - \left( {AV} \right)_{h}}{3}\\ &= (AV)_{0.025} + \frac{\left( {AV} \right)_{0.025} - \left( {AV} \right)_{0.05}}{3}\\ &= 270.11 + \frac{270.11 - 270.30}{3}\\ &= 270.05 \end{split} \nonumber\]

    Coincidentally, this is the exact value of \(f^\prime(3)\) up to 5 significant digits.

    Example \(\PageIndex{3.5}\)

    Using

    \[f^{\prime}\left( x \right) \approx \frac{f\left( x + h \right) - f\left( x - h \right)}{2h}\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{1.3}) \nonumber\]

    two approximate values of \(f^{\prime}\left( 10 \right)\) are calculated using two different values of the step size \(h\).

    For \(h = 2\), \[f^{\prime}\left( 10 \right) \cong 1315. \nonumber\]

    For \(h = 0.5\), \[f^{\prime}\left( 10 \right) \cong 626. \nonumber\]

    Based on this information, can you get a better estimate of \(f^{\prime}\left( 10 \right)\)? Find it.

    Solution

    The above approximate formula

    \[f^{\prime}\left( x \right) \approx \frac{f\left( x + h \right) - f\left( x - h \right)}{2h} \nonumber\]

    is the central divided difference formula for \(f^{\prime}\left( x \right)\).

    The true error, \(E_{t}\), associated with the formula is of the order of \(h^{2}\). Hence the true error for a step size of \(h_1\) is approximately \(C{h_{1}}^{2}\), where \(C\) is a constant of proportionality.

    Since

    \[\text{True Error} = \text{True Value} - \text{Approximate Value} \nonumber\]

    we have

    \[C{h_{1}}^{2} \approx {TV} - ({AV})_{h_{1}}\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.E5.1}) \nonumber\]

    where

    \[TV = \text{True value} \text{ of } f^{\prime}\left( x \right) \nonumber\]

    \[(AV)_{h_{1}} = \text{ Approximate Value of } f^{\prime}\left( x \right) \text{ using step size } h_{1} \nonumber\]

    Similarly, for a different step size \(h_{2}\), the true error for a step size of \(h_{2}\) is approximately \(C{h_{2}}^{2}\).

    Since

    \[\text{True Error} = \text{True Value} - \text{Approximate Value} \nonumber\]

    \[C{h_{2}}^{2} \approx {TV} - ({AV})_{h_{2}}\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.E5.2}) \nonumber\]

    where

    \[(AV)_{h_{2}}= \text{ Approximate Value of } f^{\prime}\left( x \right) \text{ using step size } h_{2} \nonumber\]

    Dividing Equation \((\PageIndex{3.E5.1})\) by Equation \((\PageIndex{3.E5.2})\), we get

    \[\frac{C{h_{1}}^{2}}{C{h_{2}}^{2}} \approx \frac{TV - (AV)_{h_{1}}}{TV - (AV)_{h_{2}}} \nonumber\]

    which gives

    \[{TV} \approx \frac{({AV})_{h_{1}}{h_{2}}^{2} - ({AV})_{h_{2}}{h_{1}}^{2}}{\left( h_{2} - h_{1} \right)\left( h_{2} + h_{1} \right)}\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{3.E5.3}) \nonumber\]

    In our case,

    \[{h_{1} = 2,\ ({AV})_{h_{1}} = 1315,} \nonumber\]

    \[{h_{2} = 0.5,\ ({AV})_{h_{2}} = 626,} \nonumber\]

    Then from Equation \((\PageIndex{3.E5.3})\), we get

    \[\begin{split} TV &\approx \frac{({AV})_{h_{1}}{h_{2}}^{2} - ({AV})_{h_{2}}{h_{1}}^{2}}{\left( h_{2} - h_{1} \right)\left( h_{2} + h_{1} \right)}\\ &= \frac{1315 \times 0.5^{2} - 626 \times 2^{2}}{\left( 0.5 - 2 \right)\left( 0.5 + 2 \right)}\\ &= 580.1 \end{split} \nonumber\]

    Audiovisual Lecture

    Title: Richardson's extrapolation formula for differentiation
    Summary: Learn Richardson's extrapolation formula for differentiation. The central divided difference scheme for the first derivative is used as the basis of the used formula

    Appendix

    The formulas for the first derivative of a continuous function talked about in this and the previous lessons for forward and backward divided difference have the accuracy of the order of the step-size.

    For FDD

    \[f^{\prime}\left( x \right) = \frac{f\left( x + h \right) - f\left( x \right)}{h} + O\left( h \right)\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{A.1}) \nonumber\]

    For BDD

    \[f^{\prime}\left( x \right) = \frac{f\left( x \right) - f\left( x - h \right)}{h} + O\left( h \right)\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{A.2}) \nonumber\]

    The question arises, are there more accurate formulas for the forward and backward divided difference for the first derivative of a function. Yes, there are and they are also derivable by manipulating the Taylor series. For example, note the following.

    For FDD, we can derive the three-point formula

    \[f^{\prime}\left( x \right) = \frac{- 3f\left( x \right) + 4f\left( x + h \right) - f\left( x + 2h \right)}{2h} + O\left( h^{2} \right)\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{A.3}) \nonumber\]

    For BDD, we can derive the three-point formula

    \[f^{\prime}\left( x \right) = \frac{f\left( x - 2h \right) - 4f\left( x - h \right) + 3f(x)}{2h} + O\left( h^{2} \right)\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{A.4}) \nonumber\]

    Both the above formulas have the same accuracy as the two-point CDD formula

    \[f^{\prime}\left( x \right) = \frac{f\left( x + h \right) - f\left( x - h \right)}{2h} + O\left( h^{2} \right)\;\;\;\;\;\;\;\;\;\;\;\; (\PageIndex{A.5}) \nonumber\]

    Getting matching accuracy becomes critical in the efficiency of solving for an application where one may be forced to use combinations of the FDD, BDD, and CDD formulas.

    Multiple Choice Test

    (1). The definition of the first derivative of a function \(f(x)\) is

    (A) \(\displaystyle f^{\prime}(x) = \frac{f(x + \Delta x) + f(x)}{\Delta x}\)

    (B) \(\displaystyle f^{\prime}(x) = \frac{f(x + \Delta x) - f(x)}{\Delta x}\)

    (C) \(\displaystyle f^{\prime}(x) = \lim_{\Delta x \rightarrow 0}\frac{f(x + \Delta x) + f(x)}{\Delta x}\)

    (D) \(\displaystyle f^{\prime}(x) = \lim_{\Delta x \rightarrow 0}\frac{f(x + \Delta x) - f(x)}{\Delta x}\)

    (2). The exact derivative of \(f(x) = x^{3}\) at \(x = 5\) is most nearly

    (A) \(25.00\)

    (B) \(75.00\)

    (C) \(106.25\)

    (D) \(125.00\)

    (3). Using the forwarded divided difference approximation with a step size of \(0.2\), the derivative of \(f(x) = 5e^{2.3x}\) at \(x = 1.25\) is

    (A) \(163.4\)

    (B) \(203.8\)

    (C) \(211.1\)

    (D) \(258.8\)

    (4). A student finds the numerical value of \(\displaystyle \frac{d}{dx}(e^{x}) = 20.220\) at \(x = 3\) using a step size of \(0.2\). Which of the following methods did the student use to conduct the differentiation?

    (A) Backward divided difference

    (B) Calculus, that is, exact

    (C) Central divided difference

    (D) Forward divided difference

    (5). Using the backward divided difference approximation, \(\displaystyle \frac{d}{dx}(e^{x}) = 4.3715\) at \(x = 1.5\) for a step size of \(0.05\). If you keep halving the step size to find \(\displaystyle \frac{d}{dx}(e^{x})\) at \(x = 1.5\) before two significant digits can be considered to be at least correct in your answer, the step size would be (you cannot use the exact value to determine the answer)

    (A) \(0.05/2\)

    (B) \(0.05/4\)

    (C) \(0.05/8\)

    (D) \(0.05/16\)

    (6). The heat transfer rate \(q\) over a surface is given by

    \[\displaystyle q = - {kA}\frac{dT}{dy} \nonumber\]

    where

    \[k = \text{thermal conductivity}\ \left( \frac{\text{J}}{\text{s} \cdot \text{m} \cdot \text{K}} \right) \nonumber\]

    \[A = \text{surface area}\ \left( \text{m}^{2} \right) \nonumber\]

    \[T = \text{temperature}\ (\text{K}) \nonumber\]

    \[y = \text{distance normal to the surface}\ \left( \text{m} \right) \nonumber\]

    Given

    \[k = 0.025\frac{\text{J}}{\text{s} \cdot \text{m} \cdot \text{K}} \nonumber\]

    \[A = 3{\ }\text{m}^{2} \nonumber\]

    the temperature \(T\) over the surface varies as

    \[T = - 1493y^{3} + 2200y^{2} - 1076y + 500 \nonumber\]

    The heat transfer rate \(q\) at the surface most nearly is

    (A) \(-1076\ \text{W}\)

    (B) \(37.5\ \text{W}\)

    (C) \(80.7\ \text{W}\)

    (D) \(500\ \text{W}\)

    For complete solution, go to

    http://nm.mathforcollege.com/mcquizzes/02dif/quiz_02dif_continuous_solution.pdf

    Problem Set

    (1). Find the exact value of \(\displaystyle \frac{dy}{dx}(x = 5)\), given

    \[y = e^{x} + \sin(x) \nonumber\]

    Answer

    \(148.69\)

    (2). Given the function \(f(x) = \sin(2x)\) and using a step size of \(h = 0.1\), find

    a) \(f^{\prime}(\displaystyle \frac{\pi}{3})\) using the forward divided difference scheme. Also, find the absolute relative true error.

    b) \(f^{\prime}(\displaystyle \frac{\pi}{3})\) using the backward divided difference scheme. Also, find the absolute relative true error.

    c) \(f^{\prime}(\displaystyle \frac{\pi}{3})\) using the central divided difference scheme. Also, find the absolute relative true error.

    Answer

    \(a)\ -1.1660,\ 0.1660\ \ b)\ -0.8207,\ 0.1792\ \ c)\ -0.99334,\ 0.0067\)

    (3). Using forward divided difference scheme, find the first derivative of the function \(f(x) = \sin(2x)\) at \(x = \displaystyle \frac{\pi}{3}\) correct within 2 significant digits. Start with a step size of \(h = 0.01\) and keep halving it till you find the answer.

    Answer

    \(-1.0043,\ \text{abs rel approx error}\ =0.42\%, h=0.0025\)

    (4). The velocity of a body is given by

    \[v(t) = 20 \ln(120 - 4t), 0 < t < 10 \nonumber\]

    where \(t\) is in seconds and \(v\) is in \(\text{m/s}\).

    a) What is the exact acceleration at \(t = 2\) s?

    b) What is the acceleration at \(t = 2\) s using any divided difference scheme of numerical differentiation with a step size of \(0.25\) s?

    c) Use any numerical scheme to find jerk (rate of change of acceleration) at \(t = 2\) s using a step size of \(0.25\) s.

    Answer

    \(a)\ -0.7143\ \text{m/s}^2\)

    \(b)\ -0.7174\ \text{m/s}^2\ \text{(FDD)},\ -0.7111\ \text{m/s}^2\ \text{(BDD)},\ -0.7143\ \text{m/s}^2\ \text{(CDD)}\)

    \(c)\ -0.0255\ \text{m/s}^2\ \text{using CDD}\) Add texts here. Do not delete this text first.

    (5). Using forward divided difference method, the first derivative of a function \(f(x)\) is found at \(x = 0.8\). With a step size of \(0.2\), \(f^{\prime}(0.8) \approx 0.95375\), while with a step size of \(0.1\), \(f^{\prime}(0.8) \approx 0.96851\). Find a better estimate of \(f^{\prime}(0.8)\) with the above information knowing that the order of accuracy of the forward divided difference scheme is \(O\)(step size).

    Answer

    \(0.98327\)

    (6). The error in using central divided difference scheme to find the first derivative of the function, \(f(x)\) is of \(O(h^{2})\), where \(h\) is the step size. If the true error in finding \(f^{\prime}(\alpha)\) with a step size \(h = 0.5\) is \(1.6\), estimate the true error in finding \(f^{\prime}(\alpha)\) with a step size of \(h = 0.125\).

    Answer

    \(0.1\)

    (7). The voltage of a variable power source is given by

    \[v(t) = 3\frac

    UndefinedNameError: reference to undefined name 'dc' (click for details)
    Callstack:
        at (Workbench/Numerical_Methods_with_Applications_(Kaw)/2:_Differentiation/2.02:_Numerical_Differentiation_of_Continuous_Functions), /content/body/div/div/div[16]/div/p[17]/span[1], line 1, column 1
    
    UndefinedNameError: reference to undefined name 'dt' (click for details)
    Callstack:
        at (Workbench/Numerical_Methods_with_Applications_(Kaw)/2:_Differentiation/2.02:_Numerical_Differentiation_of_Continuous_Functions), /content/body/div/div/div[16]/div/p[17]/span[2], line 1, column 1
    
    + 5c, \nonumber\]

    where \(c\) is the current in amperes, time is in seconds, and \(v\) is the voltage in volts. Find the voltage in volts at \(t = 6\) s if \(c = 5\cos(2t)\).

    Answer

    \(37.194\ \text{V}\)


    This page titled 2.02: Numerical Differentiation of Continuous Functions is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Autar Kaw via source content that was edited to the style and standards of the LibreTexts platform.