Next: Numerical Integration Up: Main

6. Numerical Differentiation:

The basic idea behind numerical differentiation is very simple. If given the set of values $ (x_i,
f_i)$ i=0,1,...,n, we determine the interpolating polynomial $ p(x)$ through these points. We then differentiate this polynomial to obtain $ p'(x)$ whose values for any $ x$ is taken as an approximation to . Let us very briefly describe this interpolating polynomial.
Let $ x_i,\,\, i=0,1,...,n$ be $ n+1$ distinct points on an interval I and let $ f(x)$ be a real valued function which takes on the values $ f(x_i)=f_i,i=0,1,..,n$, at these n+1 points. To construct a polynomial of degree not exceeding n which passes through the n+1 points $ (x_i, f_i),\,\,i=0,1,..n,$ we use the method of Lagrange. We begin by expressing the desired polynomial as

where each is a polynomial of degree not exceeding n. The interpolating condition $ p(x_i)=f_i$ will be satisfied if the satisfy:

It is easy to verify that the function defined by

have this property.
The error in approximating $ f(x)$ by such a polynomial $ p(x)$ is given by

where $ \psi (x)=(x-x_0)(x-x_1)...(x-x_n)$ and is some point on the interval containing $ x_i,i=0,1,...,n$ Then the error in the derivative $ p'(x)$ at a tabular point $ x=x_i$ is given by

$\displaystyle f'(x_i)-p'(x_i)=\frac{\psi'(x_i)f^{(n+1)}_{(\xi_i)}}{(n+1)!}$

where $ \xi_i$ is a point in the interval containing the points $ x_i\, ,i=0(1)n$ and

If we assume that the interpolating points are equally spaced with spacing h, and put $ S=\frac{x-x_0}{h}$ we can approximate $ f(x)$ by Newton's forward difference formula given by

..........(1)

where $ \Delta$ is the forward difference operator defined as

$\displaystyle \Delta f(x_0)=f(x_0+h)-f(x_0)$

$\displaystyle \Delta^kf(x_0)=\Delta^{k-1}f(x_0+h)-\Delta^{k-1}f(x_0)\qquad k=2,3,...$

and \begin{displaymath}\left(%
\begin{array}{c}
S \\
n \\
\end{array}%
\right)\end{displaymath} is the binomial coefficient given by

\begin{displaymath}\left(%
\begin{array}{c}
S \\
n \\
\end{array}%
\right)=\frac{S(S-1)(S-2)...(S-n+1)}{n!}\end{displaymath}

The error is .
Differentiating (1) w. r. t. x and noting that $ \frac{dP}{dx}=\frac{1}{h}\frac{dP}{dS}$ ,
we obtain

\begin{displaymath}f'(x)\simeq\frac{1}{h}\frac{dP}{dS}=\frac{1}{h}[\Delta f_0+\f...
...in{array}{c}
S \\
n \\
\end{array}%
\right)\Delta^nf_0]\end{displaymath}

If we now set $ x=x_0, \,($ie$ \,\, S
=0)$ we obtain approximation formulas for $ f'(x_0)$ for different values of n. For example, for $ n=1$, we have

$\displaystyle f'(x_0)\simeq\frac{\Delta f_0}{h}=\frac{f_1-f_0}{h}$

with the error of this formula given by

Taking now n=2,

$\displaystyle f'(x_0)\approx\frac{1}{h}(\Delta f_0-\frac{1}{2}\Delta^2f_0)$

$\displaystyle =\frac{1}{2h}(-3f_0+4f_1-f_2)$

with the error given by

Formulas for approximating higher derivatives of $ f(x)$ can be obtained in a similar manner. Differentiating (1) twice and setting $ \xi=0$, we obtain

with the error given by $ E=-hf'''(\xi) $
Another formula for the derivatives, using central difference, is given by

$\displaystyle f'(x_0)\simeq \frac{f_1-f_{-1}}{2h}$

where $ f_1=f(x_0+h); f_{-1}=f(x_0-h)$ .
Using Taylor's expansion about the $ x_0$, we get

$\displaystyle f_1=f_0+hf'_0+\frac{h^2}{2}f''_0+\frac{h^3}{6}f'''(\xi_1)\qquad x_0 < \xi_1 < x_1$

$\displaystyle f_{-1}=f_0-hf'_0+\frac{h^2}{2}f''_0-\frac{h^3}{6}f'''(\xi_2)\qquad x_{-1} < \xi_2 < x_0$

This gives

$\displaystyle \frac{f_1-f_{-1}}{2h}=f'(x_0)+\frac{h^2}{12}[f'''(\xi_1)+f'''(\xi_2)]$

If is continuous on $ [x_{-1},x_1]$, we have

$\displaystyle f'(x_0)=\frac{f_1-f_{-1}}{2h}-\frac{h^2}{6}f'''(\xi)\,, \qquad x_{-1}<\xi < x_1$

and thus the error in the formula is

$\displaystyle E=-\frac{h^2}{6}f'''(\xi)$

The simplest formula for based on central difference is

$\displaystyle f''(x_0)\simeq \frac{f_1-2f_0+f_{-1}}{h^2}$    with error


Next: Numerical Integration Up: Main