Numerical Copy
Numerical Copy
There are two main uses of these approximating polynomials. The first use is to reconstruct
the function f(x) when it is not given explicitly and only values of f(x) and/ or its certain order
derivatives are given at a set of distinct points called nodes or tabular points. The second use
is to perform the required operations which were intended for f(x), like determination of roots,
differentiation and integration etc. can be carried out using the approximating polynomial
P(x). The approximating polynomial P(x) can be used to predict the value of f(x) at a non-
tabular point. The deviation of P(x) from f(x), that is f(x) P(x), is called the error of approxi-
mation.
Let f(x) be a continuous function defined on some interval [a, b], and be prescribed
at n + 1 distinct tabular points x0, x1,..., xn such that a = x0 < x1 < x2 < ... < xn = b. The distinct
tabular points x0, x1,..., xn may be non-equispaced or equispaced, that is xk+1 xk = h, k = 0, 1,
2, , n 1. The problem of polynomial approximation is to find a polynomial Pn(x), of degree
n, which fits the given data exactly, that is,
Pn(xi) = f(xi), i = 0, 1, 2, , n. (2.1)
The polynomial Pn(x) is called the interpolating polynomial. The conditions given in
(2.1) are called the interpolating conditions.
Remark 1 Through two distinct points, we can construct a unique polynomial of degree 1
(straight line). Through three distinct points, we can construct a unique polynomial of degree
2 (parabola) or a unique polynomial of degree1 (straight line). That is, through three distinct
points, we can construct a unique polynomial of degree 2. In general, through n + 1 distinct
points, we can construct a unique polynomial of degree n. The interpolation polynomial
fitting a given data is unique. We may express it in various forms but are otherwise the same
polynomial. For example, f(x) = x2 2x 1 can be written as
x2 2x 1 = 2 + (x 1) + (x 1) (x 2).
Let the data
x x0 x1 x2 ... xn
be given at distinct unevenly spaced points or non-uniform points x0, x1,..., xn. This data may
also be given at evenly spaced points.
For this data, we can fit a unique polynomial of degree n. Since the interpolating
polynomial must use all the ordinates f(x0), f(x1),... f(xn), it can be written as a linear combina-
tion of these ordinates. That is, we can write the polynomial as
Pn(x) = l0(x) f(x0) + l1(x) f(x1) + ... + ln(x) f(xn)
= l0(x) f0 + l1(x) f1 + ... + ln(x) f(xn) (2.2)
where f(xi) = fi and li(x), i = 0, 1, 2, ,n are polynomials of degree n. This polynomial fits the
data given in (2.1) exactly.
At x = x0, we get
f(x0) Pn(x0) = l0(x0) f(x0) + l1(x0) f(x1) + ... + ln(x0) f(xn).
This equation is satisfied only when l0(x0) = 1 and li(x0) = 0, i 0.
At a general point x = xi, we get
f(xi) Pn(xi) = l0(xi) f(x0) + ... + li(xi) f(xi) + ... + ln(xi) f(xn).
This equation is satisfied only when li(xi) = 1 and lj(xi) = 0, i j.
Therefore, li(x), which are polynomials of degree n, satisfy the conditions
0, i j
li(xj) = 1, i j. (2.3)
( x x 0 ) ( x x1 )...( x x i 1 )( x x i 1 )...( x x n )
Therefore, li(x) = (2.4)
( x i x 0 ) ( x i x1 )...( x i x i 1 ) ( x i x i 1 )...( x i x n )
Note that the denominator on the right hand side of li(x) is obtained by setting x = xi in
the numerator.
The polynomial given in (2.2) where li(x) are defined by (2.4) is called the Lagrange
interpolating polynomial and li(x) are called the Lagrange fundamental polynomials.
We can write the Lagrange fundamental polynomials li(x) in a simple notation.
Denote w(x) = (x x0) (x x1)...(x xn)
which is the product of all factors. Differentiating w(x) with respect to x and substituting x = xi
we get
w (xi) = (xi x0) (xi x1)...(xi xi1) (xi xi+1)...(xi xn)
since all other terms vanish. Therefore, we can also write li(x) as
w( x )
li(x) = . (2.5)
(x xi ) w ( xi )
( x x1 ) (x x0 )
l0(x) = , l (x) = . (2.6)
( x 0 x1 ) 1 ( x1 x 0 )
(x x1 ) ( x x 2 ) (x x0 ) (x x2 ) (x x 0 ) ( x x1 )
l0(x) = , l (x) = , l (x) = .
(x0 x1 ) ( x 0 x 2 ) 1 ( x1 x 0 ) ( x1 x 2 ) 2 (x2 x 0 ) ( x 2 x1 )
The Lagrange quadratic interpolation polynomial is given by
P1(x) = l0(x) f(x0) + l1(x) f(x1) + l2(x) f(x2). (2.8)
Error of interpolation
We assume that f(x) has continuous derivatives of order up to n + 1 for all x (a, b).
Since, f(x) is approximated by Pn(x), the results contain errors. We define the error of interpo-
lation or truncation error as
E(f, x) = f(x) Pn(x). (2.9)
Without giving the derivation, we write the expression for the error of interpolation as
E(f, x) = f(x) Pn(x)
(x x 0 ) ( x x1 )...( x xn ) w( x )
= f (n+1) ( ) = f (n+1) ( ) (2.10)
( n 1) ! ( n 1) !
where min(x0, x1,..., xn, x) < < max(x0, x1,..., xn, x).
Since, is an unknown, it is difficult to find the value of the error. However, we can find
a bound of the error. The bound of the error is obtained as
1
E(f, x) = (x x0) (x x1)...(x xn) f (n+1) ( )
(n 1) !
1
max ( x x0 ) (x x1 ) ...( x xn ) max f (n 1)
(x)
(n 1) ! a x b a x b
(2.11)
Note that in (2.11), we compute the maximum absolute value of
w(x) = (x x0)(x x1)...(x xn), that is max w(x) and not the maximum of w(x).
Since the interpolating polynomial is unique, the error of interpolation is also unique,
that is, the error is same whichever form of the polynomial is used.
Example 2.1 Using the data sin(0.1) = 0.09983 and sin (0.2) = 0.19867, find an approximate
value of sin (0.15) by Lagrange interpolation. Obtain a bound on the error at x = 0.15.
Solution We have two data values. The Lagrange linear polynomial is given by
( x x1 ) (x x0 )
P1(x) = f(x0) + f(x1)
( x 0 x1 ) ( x1 x 0 )
( x 0.2) ( x 0.1)
= (0.09983) + (0.19867).
( 0.1 0.2) ( 0.2 0.1)
(x x0 ) (x x1 ) (x 0.1) ( x 0.2 )
T.E = f ( )= ( sin ), 0.1 < < 0.2.
2 2
since f(x) = sin x. At x = 0.15, we obtain the bound as
(0.15 0.1) (0.15 0.2)
T.E = ( sin ) = 0.00125 sin
2
and T.E = 0.00125 sin 0.00125 max sin x
0.1 x 0.2
x 0 1 3
(x x0 ) (x x2 ) x ( x 3) 1
l1(x) = (3x x2).
( x1 x 0 ) ( x1 x 2 ) (1) ( 2) 2
1 1
f(x) = l1(x) f(x1) = (3x x2) (1) = (3x x2).
2 2
Example 2.3 Given that f(0) = 1, f(1) = 3, f(3) = 55, find the unique polynomial of degree 2 or
less, which fits the given data.
(x x0 ) ( x x2 ) x ( x 3) 1
l1(x) = (3x x2).
( x1 x 0 ) ( x1 x 2 ) (1) ( 2) 2
(x x 0 ) ( x x1 ) x ( x 1) 1 2
l2(x) = (x x).
(x2 x 0 ) ( x 2 x1 ) (3) ( 2) 6
Hence, the Lagrange quadratic polynomial is given by
P2(x) = l0(x) f(x0) + l1(x) f(x1) + l2(x) f(x2)
1 2 1 55 2
= (x 4x + 3) + (3x x2) (3) + (x x) = 8x2 6x + 1.
3 2 6
Example 2.4 The following values of the function f(x) = sin x + cos x, are given
Construct the quadratic Lagrange interpolating polynomial that fits the data. Hence, find
f ( /12). Compare with the exact value.
Solution Since the value of f at /12 radians is required, we convert the data into radian
measure. We have
(x x1 ) ( x x 2 ) ( x 0.3491) ( x 0.5236 )
l0(x) =
(x0 x1 ) ( x 0 x 2 ) ( 01746
. ) ( 0.3491)
(x x0 ) (x x2 ) (x 0.1745 ) ( x 0.5236 )
l1(x) =
( x1 x 0 ) ( x1 x 2 ) ( 0.1746) ( 0.1745)
(x x 0 ) ( x x1 ) (x 0.1745 ) ( x 0.3491)
l2(x) =
(x2 x 0 ) ( x 2 x1 ) ( 0.3491) ( 0.1745)
Example 2.5 Construct the Lagrange interpolation polynomial for the data
x 1 1 4 7
f (x) 2 0 63 342
Hence, interpolate at x = 5.
Solution The Lagrange fundamental polynomials are given by
( x x1 ) ( x x 2 ) ( x x 3 ) ( x 1) ( x 4 ) ( x 7 )
l0(x) =
(x 0 x1 ) ( x 0 x 2 ) (x 0 x3 ) ( 1 1) ( 1 4 ) ( 1 7 )
1
= (x3 12x2 + 39x 28).
80
(x x0 ) ( x x 2 ) (x x3 ) ( x 1) ( x 4 ) ( x 7)
l1(x) =
( x1 x 0 ) ( x1 x 2 ) ( x1 x 3 ) (1 1) (1 4 ) (1 7)
1
= (x3 10x2 + 17x + 28).
36
( x x 0 ) ( x x1 ) ( x x 3 ) ( x 1) ( x 1) ( x 7)
l2(x) =
( x 2 x 0 ) ( x 2 x1 ) ( x 2 x 3 ) ( 4 1) ( 4 1) ( 4 7)
1
= (x3 7x2 x + 7).
45
( x x 0 ) ( x x1 ) ( x x 2 ) ( x 1 ) ( x 1) ( x 4 )
l3(x) =
( x 3 x 0 ) ( x 3 x1 ) ( x 3 x 2 ) ( 7 1) ( 7 1 ) ( 7 4 )
1
= (x3 4x2 x + 4).
144
Note that we need not compute l1(x) since f(x1) = 0.
The Lagrange interpolation polynomial is given by
P3(x) = l0(x) f(x0) + l1(x) f(x1) + l2(x) f(x2) + l3(x) f(x3)
1 1
= (x3 12x2 + 39x 28) ( 2) (x3 7x2 x + 7) (63)
80 45
1
+ (x3 4x2 x + 4) (342)
144
Remark 2 For a given data, it is possible to construct the Lagrange interpolation polynomial.
However, it is very difficult and time consuming to collect and simplify the coefficients of xi, i
= 0, 1, 2, , n. Now, assume that we have determined the Lagrange interpolation polynomial
of degree n based on the data values (xi, f(xi)), i = 0, 1, 2, , n at the (n + 1) distinct points.
Suppose that to this given data, a new value (xn+1, f(xn+1)) at the distinct point xn+1 is added at
the end of the table. If we require the Lagrange interpolating polynomial for this new data,
then we need to compute all the Lagrange fundamental polynomials again. The nth degree
Lagrange polynomial obtained earlier is of no use. This is the disadvantage of the Lagrange
interpolation. However, Lagrange interpolation is a fundamental result and is used in prov-
ing many theoretical results of interpolation.
Remark 3 Suppose that the data (xi, f(xi)), i = 0, 1, 2, , n, is given. Assume that a new value
(xn+1, f(xn+1)) at the distinct point xn+1 is added at the end of the table. The data, (xi, f(xi)),
i = 0, 1, 2, , n + 1, represents a polynomial of degree (n + 1). If this polynomial of degree
(n + 1) can be obtained by adding an extra term to the previously obtained nth degree inter-
polating polynomial, then the interpolating polynomial is said to have the permanence property.
We observe that the Lagrange interpolating polynomial does not have the permanence property.
Divided differences
Let the data, (xi, f(xi)), i = 0, 1, 2, , n, be given. We define the divided differences as follows.
First divided difference Consider any two consecutive data values (xi, f(xi)), (xi+1, f(xi+1)). Then,
we define the first divided difference as
f ( xi 1 ) f ( xi )
f [xi, xi+1] = , i = 0, 1, 2, , n 1. (2.12)
xi 1 xi
f ( x1 ) f ( x0 ) f ( x2 ) f ( x1 )
Therefore, f [x0, x1] = , f[x1, x2] = etc.
x1 x0 x2 x1
f ( xi ) f ( xi 1 )
Note that f [xi, xi+1] = f [xi+1, xi] = .
xi xi 1 xi 1 xi
We say that the divided differences are symmetrical about their arguments.
Second divided difference Consider any three consecutive data values (xi, f(xi)), (xi+1, f(xi+1)),
(xi+2, f(xi+2)). Then, we define the second divided difference as
f [ xi 1 , x i 2 ] f [ xi , x i 1 ]
f [xi xi+1, xi+2] = i = 0, 1, 2, ,n2 (2.13)
xi 2 xi
f [ x1, x 2 ] f [ x0 , x1 ]
Therefore, f [x0, x1, x2] = etc.
x2 x0
We can express the divided differences in terms of the ordinates. We have
1 f2 f1 f1 f0
f [x0, x1, x2] =
x2 x0 x2 x0 x1 x0
f0 f1 1 1 f2
=
( x0 x1 )( x0 x2 ) ( x2 x0 ) x2 x1 x1 x0 ( x2 x0 )( x2 x1 )
f0 f1 f2
=
( x0 x1 )( x0 x2 ) ( x1 x0 )( x1 x2 ) ( x2 x0 )( x2 x1 )
Notice that the denominators are same as the denominators of the Lagrange funda-
mental polynomials. In general, we have the second divided difference as
f [ xi 1 , x i 2 ] f [ xi , x i 1 ]
f [xi xi+1, xi+2] =
xi 2 xi
fi fi 1 fi 2
=
( xi xi 1 )( xi xi 2 ) ( xi 1 xi )( xi 1 xi 2 ) ( xi 2 xi )( xi 2 xi 1 )
The nth divided difference using all the data values in the table, is defined as
f [ x1 , x 2 ,..., x n ] f [ x 0 , x1 ,..., x n 1]
f [x0, x1, ..., xn] = (2.14)
xn x0
The nth divided difference can also be expressed in terms of the ordinates fi. The de-
nominators of the terms are same as the denominators of the Lagrange fundamental polyno-
mials.
The divided differences can be written in a tabular form as in Table 2.1.
x0 f0
f [x0, x1]
x1 f1 f [x0, x1, x2]
f [x1, x2] f [x0, x1, x2, x3]
x2 f2 f [x1, x2, x3]
f [x2, x3]
x3 f3
Example 2.6 Find the second divided difference of f(x) = 1/x, using the points a, b, c.
Solution We have
f (b) f ( a) 1 1 1 a b 1
f [a, b] = ,
b a b a b a (b a) ab ab
f (c) f (b) 1 1 1 b c 1
f [b, c] = ,
c b c b c b (c b)bc bc
f [b, c] f [ a, b] 1 1 1 c a 1
f [a, b, c] = .
c a c a bc ab (c a) abc abc
Example 2.7 Obtain the divided difference table for the data
x 1 0 2 3
1 8
3 8
= 11
0 1
1 11
0 3 =4
2 1
1 3 4 4
1 =2
2 0 3 1
11 1
2 1 4
3 0
12 1
= 11
3 2
3 12
We mentioned earlier that the interpolating polynomial representing a given data values is
unique, but the polynomial can be represented in various forms.
We write the interpolating polynomial as
f(x) = Pn(x)
= c0 + (x x0) c1 + (x x0)(x x1) c2 + ... + (x x0)(x x1)...(x xn1) cn. (2.15)
The polynomial fits the data Pn(xi) = f(xi) = fi.
Setting Pn(x0) = f0, we obtain
Pn(x0) = f0 = c0
since all the remaining terms vanish.
Setting Pn(x1) = f1, we obtain
f1 c0 f1 f0
f1 = c0 + (x1 x0) c1, or c1 = = f [x0, x1].
x1 x0 x1 x0
Setting Pn(x2) = f2, we obtain
f2 = c0 + (x2 x0) c1 + (x2 x0)(x2 x1) c2,
f2 f0 ( x2 x0 ) f [ x0 , x1 ]
or c2 =
( x2 x0 )( x2 x1 )
1 f1 f0
= f2 f0 ( x2 x0 )
( x2 x0 )( x2 x1 ) x1 x0
f0 f1 f2
=
( x0 x1 )( x0 x2 ) ( x1 x0 )( x1 x2 ) ( x2 x0 )( x2 x1 )
Remark 4 From the divided difference table, we can determine the degree of the interpolat-
ing polynomial. Suppose that all the kth divided differences in the kth column are equal (same).
Then, all the (k + 1)th divided differences in the (k + 1)th column are zeros. Therefore, from
(2.16), we conclude that the data represents a kth degree polynomial. Otherwise, the data
represents an nth degree polynomial.
x 4 1 0 2 5
4 1245
404
1 33 94
28 14
0 5 10 3
2 13
2 9 88
442
5 1335
Example 2.9 Find f(x) as a polynomial in x for the following data by Newtons divided differ-
ence formula
x 2 1 0 1 3 4
f(x) 9 16 17 18 44 81
2 9
7
1 16 3
1 1
0 17 0 0
1 1
1 18 4 0
13 1
3 44 8
37
4 81
Example 2.10 Find f(x) as a polynomial in x for the following data by Newtons divided differ-
ence formula
x 1 3 4 5 7 10
Hence, interpolate at x = 3.5 and x = 8.0. Also find, f (3) and f (1.5).
Solution We form the divided difference table for the data.
1 3
14
3 31 8
38 1
4 69 12 0
62 1
5 131 16 0
110 1
7 351 22
220
10 1011
Since, the fourth order differences are zeros, the data represents a third degree
polynomial. Newtons divided difference formula gives the polynomial as
f(x) = f(x0) + (x x0) f [x0, x1] + (x x0)(x x1) f [x0, x1, x2]
+ (x x0)(x x1)(x x2) f [x0, x1, x2, x3]
= 3 + (x 1)(14) + (x 1)(x 3)(8) + (x 1)(x 3)(x 4)(1)
= 3 + 14x 14 + 8x2 32x + 24 + x3 8x2 + 19x 12 = x3 + x + 1.
Hence f(3.5) P3(3.5) = (3.5)3 + 3.5 + 1 = 47.375,
f(8.0) P3(8.0) = (8.0)3 + 8.0 + 1 = 521.0.
Now, P 3(x) = 3x2 + 1, and P 3(x) = 6x.
Therefore, f (3) P (3) = 3(9) + 1 = 28, f (1.5) P (1.5) = 6(1.5) = 9.
Inverse interpolation
Suppose that a data (xi, f(xi)), i = 0, 1, 2, , n, is given. In interpolation, we predict the
value of the ordinate f(x ) at a non-tabular point x = x In many applications, we require the
value of the abscissa x for a given value of the ordinate f(x ). For this problem, we consider the
given data as ( f (xi), xi), i = 0, 1, 2, , n and construct the interpolation polynomial. That is, we
consider f(x) as the independent variable and x as the dependent variable. This procedure is
called inverse interpolation
1. Use the Lagranges formula to find the quadratic polynomial that takes these values
x 0 1 3
y 0 1 0
x 0 1 2 5
f(x) 2 3 12 147
x 0 1 2 4
y 12 0 6 12
x 14 17 31 35
x 5 7 11 13 17
x 1 2 4 5
x 0 1 2 3 4
y 1 3 9 81
x 0 1 2 4 5
f(x) 1 14 15 5 6
18. Using Newtons divided difference interpolation, find y(10) given that
y(5) = 12, y(6) = 13, y(9) = 14, y(11) = 16.
19. Using divided difference formula, find u(3) given
u(1) = 26, u(2) = 12, u(4) = 256, and u(6) = 844. (A.U Nov/Dec. 2004)
20. Find f(8) by Newtons divided difference formula, for the data
x 4 5 7 10 11 13
x 1 2 4 5
x f(x) f 2f 3f
x0 f(x0)
f0 = f1 f0
x1 f(x1) 2 f0 = f1 f0
f1 = f2 f1 3f = 2f 2f
0 1 0
x2 f(x2) 2f = f2 f1
1
f2 = f3 f2
x3 f(x3)
x f(x) f 2f 3f
x0 f(x0)
f1 = f1 f0
2
x1 f(x1) f2 = f2 f1
f2 = f2 f1 3f = 2 f3 2 f2
3
x2 f(x2) 2 f3 = f3 f2
f3 = f3 f2
x3 f(x3)
Remark 6 From the difference tables 2.2, 2.3, we note that the numbers (values of differ-
ences) in all the columns in the two tables are same. We identify these numbers as the re-
quired forward or backward difference. For example, from the columns of the table, we have
f0 = f1, f1 = f2, f2 = f3, ..., 3f = 3f
0 3.
Example 2.11 Construct the forward difference table for the data
x 1 0 1 2
f(x) 8 3 1 12
x f(x) f 2f 3f
1 8
3 + 8 = 11
0 3 2 11 = 13
13=2 13 + 13 = 26
1 1 11 + 2 = 13
12 1 = 11
2 12
Example 2.12 Construct the backward difference table for the data
x 1 0 1 2
f(x) 8 3 1 12
x f(x) f 2f 3f
1 8
3 + 8 = 11
0 3 2 11 = 13
13=2 13 + 13 = 26
1 1 11 + 2 = 13
12 1 = 11
2 12
2 3
x f(x) f f f
x0 f(x0)
f1/2 = f1 f0
3 2 2
f3/2 = f2 f1 f3/2 = f2 f1
2
x2 f(x2) f2 = f5/2 f3/2
f5/2 = f3 f2
x3 f(x3)
Very often, we may denote the reference point as x0 and the previous points as x1, x2,
... and the later points as x1, x2, .... Then, the central difference table can be written as in
Table 2.5. Note that all the differences of even order lie on the same line as the abscissa and
the ordinate.
Remark 7 We show that nf = nf = n fi+(n/2).
i i+n
Remark 8 Let Pn(x) = a0xn + a1xn1 + a2xn2 + ... + an be a polynomial of degree n. Then,
k Pn(x) = 0, for k > n, and k Pn(x) = 0, for k > n,
= a0(n !), for k = n = a0 (n !), for k = n.
x f(x) f 2f 3f 4f
x2 f2
f3/2
x1 f1 2 f1
f1/2 3f
1/2
x0 f0 2 f0 4f
0
f1/2 3f
1/2
x1 f1 2 f1
f3/2
x2 f2
Remark 9 For well behaved functions, the forward differences, backward differences and
central differences decrease in magnitude along each column. That is, the second difference is
smaller in magnitude than the first difference, the third difference is smaller in magnitude
than second difference etc.
1 h h 1 1 1/ 2 1/ 2
f(xi) = f xi f xi fi 1/ 2 fi 1/ 2 E E fi
2 2 2 2 2
Solution We have
3(1 2x)(1 3x)(1 4x) = 3( 24x3 + lower order terms)
= 24 (3 !) = 144
since 3 (polynomial of degree 2 and less) = 0.
Example 2.14 Construct the forward difference table for the sequence of values
f(0, 0, 0, , 0, 0, 0)
where is the magnitude of the error in one ordinate value and all other ordinates are exact.
Show that the errors propagate and increase in magnitude and that the errors in each column
are binomial coefficients.
Solution We have the following difference table. From the table, it can be observed that the
errors propagate and increase in magnitude and that the errors in each column are binomial
coefficients.
f(x) f 2 f 3 f 4 f 5 f 6 f
0
0
0 0
0
0 4
3 10
2 6 20
3 10
0 4
0
0 0
0
0
2 1/ 2 1/ 2
1 1
1 1 (E E 2)
4 4
1 1 1 1/2
= [E E 2]1/ 2 [E + E1/2 ] = .
2 2
2
(iii) (fi2) = fi 1 fi2 ( fi 1 fi )( fi 1 fi ) ( fi 1 fi ) f i .
f ( x) f (x h) f ( x) f (x h) g( x) f (x) g (x h)
(iv)
g ( x) g( x h) g( x) g ( x) g( x h)
g( x)[ f ( x h) f ( x)] f ( x)[ g ( x h) g( x)]
=
g ( x) g ( x h)
g( x) f ( x) f ( x) g( x)
= .
g(x) g(x h)
Relations between differences and derivatives
We write Ef(x) as
h2
Ef(x) = f(x + h) = f(x) + hf (x) + f (x) + ...
2
h2 D2
= 1 hD ... f(x) = ehD f(x).
2!
h2 h2
= f ( x) hf ( x) f ( x) ... f ( x) hf ( x) f ( x) + ...
2 2
4 h2 8h 3
= f ( x) 2 hf ( x) f ( x) f ( x) ...
2 6
h2 h3
2 f ( x) hf ( x) f ( x) f ( x) ... + f(x)
2 6
2f(x)
1
h2 f (x), or f (x) 2 f(x). (2.36)
h2
The error term is given by
1 2
f ( x) f ( x) h f ( x) ...
h2
Hence, we call the approximation given in (2.36) as a first order approximation or of
order O(h).
Similarly, we have the following results for backward differences.
1
f(x) hf (x), or f ( x) f ( x) [O(h) approximation] (2.37)
h
1 2
2 f(x) h2f (x), or f ( x ) f ( x ) . [O(h) approximation] (2.38)
h2
For the central differences, we obtain
h h
f ( x) f x f x
2 2
h h2 h3
= f ( x) f ( x) f ( x) f ( x) ...
2 8 48
h h2 h3
f ( x) f ( x) f ( x) f ( x) ...
2 8 48
h3
= hf (x) + f ( x) ...
24
Neglecting the higher order terms, we get the approximation
1
f(x) h f (x), or f (x) f(x). (2.39)
h
The error term is given by
1 h2
f ( x) f ( x) f ( x) ...
h 24
Hence, we call the approximation given in (2.39) as a second order approximation or of
order O(h2).
We have 2 f(x) = f(x + h) 2f(x) + f(x h)
h2 h2
= f ( x) hf ( x) f ( x) ... 2 f(x) + f ( x) hf ( x) f ( x) ...
2 2
2 1
f(x) h2 f (x), or f (x) 2 f(x). (2.40)
h2
The error term is given by
1 2 h 2 ( iv)
f (x) 2 f(x) = f ( x) + ...
h 12
Hence, we call the approximation given in (2.35) as a second order approximation or of
order O(h2).
Note that the central differences give approximations of higher order because of sym-
metry of the arguments.
The divided differences are also related to forward differences and backward differences.
In the uniform mesh case, the divided differences can be written as
f ( xi 1 ) f ( xi ) 1 1
f [ xi , x i 1 ] fi fi 1.
xi 1 xi h h
f [ xi 1 , x i 2 ] f [ xi , x i 1 ] (1/h) fi 1 (1/h) fi
f [ xi , x i 1 , x i 2 ]
xi 2 xi 2h
1 2 1 2
= fi fi 2.
2! h2 2 ! h2
By induction we can prove that the nth divided difference can be written as
1 n 1 n
f [ x0 , x1 , ..., x n ] f0 fn . (2.41)
n ! hn n !hn
n
f0
+ (x x0)(x x1)...(x xn1) (2.42)
1! hn
This relation is called the Newtons forward difference interpolation formula.
Suppose that we want to interpolate near the point . Set x = x0 + sh. Then,
x xi = x0 + sh (x0 + ih) = (s i)h.
Therefore, x x0 = sh, x x1 = (s 1)h, x x2 = (s 2)h, etc.
Substituting in (2.42), we obtain
f(x) = f(x0 + sh)
s(s 1) 2 s(s 1)(s 2) ... (s n 1) n
= f(x0) + s f0 + f0 ... f0 (2.43)
2! n!
s( s 1)( s 2)..( s n)
= hn 1
f (n 1)
( ) sCn 1 hn 1
f (n 1)
( ) (2.44)
( n 1) !
where 0 < < n. The coefficient in the error expression is the next binomial coefficient sCn+1.
Remark 10 The Newtons forward difference formula has the permanence property. Suppose
we add a new data value (xn+1, f(xn+1)) at the end of the given table of values. Then, the
(n + 1)th column of the forward difference table has the (n + 1)th forward difference. Then, the
Newtons forward difference formula becomes
2
f0 f0
f(x) = f(x0) + (x x0) (x x0 )( x x1 ) + ...
1! h 2 ! h2
n 1
f0
+ (x x0)(x x1)...(x xn) 1
(n 1) ! h n
Example 2.16 Derive the Newtons forward difference formula using the operator relations.
Solution We have
f(x0 + sh) = Es f(x0) = (1 + )s f(x0).
Symbolically, expanding the right hand side, we obtain
f(x0 + sh) = (sC0 + sC1 + sC2 2 + ...) f(x0)
= sC0 f(x0) + sC1 f(x0) + sC2 2 f(x0) + ... + sCn n f(x0) + ...
We neglect the (n + 1)th and higher order differences to obtain the Newtons forward
difference formula as
f(x0 + sh) = (sC0 + sC1 + sC2 2 + ...) f(x0)
= sC0 f(x0) + sC 1 f(x0) + sC2 2f(x n
0) + ... + sCn f(x0).
Example 2.17 For the data
x 2 1 0 1 2 3
f (x) 15 5 1 3 11 25
x f(x) f 2f 3f
2 15
10
1 5 6
4 0
0 1 6
2 0
1 3 6
8 0
2 11 6
14
3 25
From the table, we conclude that the data represents a quadratic polynomial. We have
h = 1. The Newtons forward difference formula is given by
2
f0 f0
f(x) = f(x0) + (x x0) (x x0 )( x x1 )
h 2 h2
6
= 15 + (x + 2)( 10) + (x + 2) (x + 1)
2
= 15 10x 20 + 3x2 + 9x + 6 = 3x2 x + 1.
We obtain f(0.5) = 3(0.5)2 0.5 + 1 = 0.75 0.5 + 1 = 1.25.
Again, we use the Newtons divided difference interpolation polynomial to derive the Newtons
backward difference interpolation formula. Since, the divided differences are symmetric with
respect to their arguments, we write the arguments of the divided differences in the order
xn, xn1,..., x1, x0. The Newtons divided difference interpolation polynomial can be written as
f(x) = f(xn) + (x xn) f [xn, xn1] + (x xn)(x xn1) f [xn, xn1, xn2] + ...
+ (x xn)(x xn1) ... (x x1) f [xn, xn1,..., x0] (2.45)
Since, the divided differences are symmetric with respect to their arguments, we have
1
f [xn, xn1] = f [xn1, xn] = fn ,
h
1 2
f[xn, xn1, xn2] = f [xn2, xn1, xn] = fn , ....,
2 ! h2
1 n
f [xn, xn1, ..., x0] = f [x0, x1,..., xn] = fn .
n ! hn
Substituting in (2.45), we obtain the Newtons backward difference interpolation formula as
1 1 2
f(x) = f(xn) + (x xn) f ( xn ) ( x xn )( x xn 1 ) f ( xn ) ...
1! h 2 ! h2
1 n
+ (x xn)(x xn1) ... (x x1) f ( xn ) . (2.46)
n ! hn
Let x be any point near xn. Let x xn = sh. Then,
x xi = x xn + xn xi = x xn + (x0 + nh) (x0 + ih)
= sh + h(n i) = (s + n i)h, i = n 1, n 2, ..., 0.
Therefore, x xn = sh, x xn1 = (s + 1)h, x xn2 = (s + 2)h, ..., x x1 = (s + n 1)h.
Substituting in (2.46), we obtain the formula as
s(s 1)
f(x) = f(xn + sh) = f(xn) + s f(xn) + 2 f(xn) + ...
2!
Example 2.18 Derive the Newtons backward difference formula using the operator relations.
Solution Let x = xn + sh. Then, s = [(x xn)/h] < 0
We have f(xn + sh) = Es f(xn) = (1 )s f(xn)
Symbolically, expanding the right hand side, we obtain
2
s( s 1) ... ( s n 1) n
f(xn + sh) = f(xn) + s f(xn) + f(xn) + ... + f(xn) + ...
n!
We neglect the (n + 1)th and higher order differences to obtain the Newtons backward
difference formula as
2
s(s 1) ... ( s n 1) n
f(xn + sh) = f(xn) + s f(xn) + f(xn) + ... + f(xn).
n!
Example 2.19 For the following data, calculate the differences and obtain the Newtons
forward and backward difference interpolation polynomials. Are these polynomials different?
Interpolate at x = 0.25 and x = 0.35.
Solution The step length is h = 0.1. We have the following difference table.
Since, the third and higher order differences are zero, the data represents a quadratic
polynomial. The third column represents the first forward/ backward differences and the fourth
column represents the second forward/ backward differences.
The forward difference polynomial is given by
2
f0 f0
f(x) = f(x0) + (x x0) + (x x0) (x x1)
h 2 ! h2
0.16 0.04
= 1.4 + (x 0.1) (x 0.1)( x 0.2)
0.1 0.02
= 2x2 + x + 1.28.
The backward difference polynomial is given by
2
fn fn
f(x) = f(xn) + (x xn) (x xn )( x xn 1 )
h 2 ! h2
0.28 0.04
= 2.28 + (x 0.5) (x 0.5)( x 0.4)
0.1 0.02
= 2x2 + x + 1.28.
Both the polynomials are identical, since the interpolation polynomial is unique. We obtain
f(0.25) = 2(0.25)2 + 0.25 + 1.28 = 1.655
f(0.35) = 2(0.35)2 + (0.35) + 1.28 = 1.875.
x f(x) f 2f 3f 4f
0.1 1.40
0.16
0.2 1.56 0.04
0.20 0.0
0.3 1.76 0.04 0.0
0.24 0.0
0.4 2.00 0.04
0.28
0.5 2.28
Solution The step length is h = 0.2. We have the difference table as given below.
Since the fourth and higher order differences are zero, the data represents a third de-
gree polynomial. The Newtons backward difference interpolation polynomial is given by
1 1 2
f(x) = f(xn) + (x xn) f(xn) + (x xn)(x xn1) f(xn)
1! h 2 ! h2
1 3
+ (x xn)(x xn1)(x xn2) f ( xn )
3 ! h3
1.202 0.216
= 2.631 + (x 1.1) + (x 1.1)(x 0.9)
0.2 2(0.04)
0.048
+ (x 1.1)(x 0.9)(x 0.7)
6( 0.008)
= 2.631 + 6.01(x 1.1) + 2.7(x 1.1)(x 0.9) + (x 1.1)(x 0.9)(x 0.7)
Since, we have not been asked to find the interpolation polynomial, we may not sim-
plify this expression. At x = 1.0, we obtain
f(1.0) = 2.631 + 6.01(1.0 1.1) + 2.7(1.0 1.1)(1.0 0.9) + (1.0 1.1)(1.0 0.9)(1.0 0.7)
= 2.631 + 6.01( 0.1) + 2.7( 0.1)(0.1) + ( 0.1)(0.1)( 0.3) = 2.004.
x f(x) f 2f 3f 4f 5f
0.1 1.699
0.626
0.3 1.073 0.072
0.698 0.048
0.5 0.375 0.120 0.0
0.818 0.048 0.0
0.7 0.443 0.168 0.0
0.986 0.048
0.9 1.429 0.216
1.202
1.1 2.631
1. Write the expression for the derivative operator D in terms of the forward difference
operator .
Solution The required expression is
1 2
1 3
hD = ln(E) = ln(1 + ) = + ...
2 3
1 1 1 1 2 1 3
or D= ln(E) = ln (1 + ) = ...
h h h 2 3
2. Write the expression for the derivative operator D in terms of the backward difference
operator .
Solution The required expression is
1 1
hD = ln(E) = ln(1 )1 = ln(1 )= + 2 + 3 + ...
2 3
1 1 1 1 1 2 1 3
or D= ln(E) = ln (1 )1 = ln(1 )= ... .
h h h h 2 3
1
3. What is the order of the approximation f (x) f(x) ?
h
1 h
Solution The error term is given by f (x) f(x) = f ( x) ...
h 2
Hence, it is a first order approximation or of order O(h).
1 2
4. What is the order of the approximation f ( x) f ( x) ?
h2
1 2
Solution The error term is given by f ( x) f ( x) h f ( x) ...
h2
Hence, it is a first order approximation or of order O(h).
1 2
5. What is the order of the approximation f ( x) f ( x) ?
h2
1 h2 (iv)
Solution The error term is given by f ( x) 2
f ( x) f ( x) ...
h2 12
Hence, it is a second order approximation or of order O(h2).
6. Give the relation between the divided differences and forward or backward differences.
Solution The required relation is
1 n 1 n
f [x0, x1, ..., xn] = f0 fn .
n ! hn n ! hn
7. Does the Newtons forward difference formula has permanence property ?
Solution Yes. The Newtons forward difference formula has permanence property.
Suppose we add a new data value (xn+1, f(xn+1)) at the end of the given table of values.
Then, the (n + 1)th column of the forward difference table has the (n + 1)th forward
difference. Then, the Newtons forward difference formula becomes
2
f0 f0
f(x) = f(x0) + (x x0) (x x0 )( x x1 ) + ...
1! h 2 ! h2
n 1
f0
+ (x x0)(x x1) ... (x xn) 1
(n 1) ! h n
8. For performing interpolation for a given data, when do we use the Newtons forward
and backward difference formulas?
Solution We use the forward difference interpolation when we want to interpolate
near the top of the table and backward difference interpolation when we want to
interpolate near the bottom of the table.
9. Can we decide the degree of the polynomial that a data represents by writing the forward
or backward difference tables?
Solution Given a table of values, we can determine the degree of the forward/ backward
difference polynomial using the difference table. The kth column of the difference table
contains the kth forward/ backward differences. If the values of these differences are
same, then the (k + 1)th and higher order differences are zero. Hence, the given data
represents a kth degree polynomial.
10. If x = x0 + sh, write the error expression in the Newtons forward difference formula.
Solution The error expression is given by
s(s 1)(s 2)..(s n)
En(f, x) = hn 1
f (n 1)
( ) sCn 1h n 1 f (n 1)
( ). 0 n.
(n 1) !
11. If x = xn + sh, write the error expression in the Newtons backward difference formula.
Solution The error expression is given by
s( s 1)( s 2)..(s n)
E n(f, x) = hn 1
f (n 1)
( ). 0 n.
(n 1) !
x 4 6 8 10
x 0 1 2 3
y 1 2 1 10
Evaluate y(4) using Newtons backward interpolation formula. Is it the same as ob-
tained from the cubic polynomial found above?
5. Obtain the interpolating quadratic polynomial for the given data by using the Newtons
forward difference formula
x 0 2 4 6
y 3 5 21 45
x 0 5 10 15
Estimate the value of f(0.5) using the Newtons backward difference interpolation. Com-
pare with the exact value.
11. The following data are part of a table for , where x is in radians.
Calculate f(0.12), (i) by interpolating directly from the table, (ii) by first tabulating x
f(x) and then interpolating from the table. Explain the difference between the results.
In the earlier days of development of engineering devices, the draftsman used a device to
draw smooth curves through a given sets of points such that the slope and curvature are also
continuous along the curves, that is, f(x), f (x) and f (x) are continuous on the curves. Such a
device was called a spline and plotting of the curve was called spline fitting.
We now define a spline.
Let the given interval [a, b] be subdivided into n subintervals [x0, x1], [x1, x2], ...,
[xn1, xn] where a = x0 < x1 < x2 < ... < xn = b. The points x0, x1, ..., xn are called nodes or knots and
x1, ..., xn1 are called internal nodes.
Spline function A spline function of degree n with nodes x0, x1, ..., xn, is a function F(x)
satisfying the following properties.
(i) F(xi) = f(xi), i = 0, 1, ...., n. (Interpolation conditions).
(ii) On each subinterval [xi1, xi], 1 i n, F(x) is a polynomial of degree n.
(iii) F(x) and its first (n 1) derivatives are continuous on (a, b).
For our discussion, we shall consider cubic splines only. From the definition, a cubic spline
has the following properties.
(i) F(xi) = f(xi), i = 0, 1, ..., n. (Interpolation conditions).
(ii) On each subinterval [xi1, xi], 1 i n, F(x) is a third degree (cubic) polynomial.
(iii) F(x), F (x) and F (x) are continuous on (a, b).
Let F(x) = Pi(x) = aix3 + bix2 + cix + di on [xi1, xi]
and F(x) = Pi+1(x) = ai+1x3 + bi+1x2 + ci+1x + di+1 on [xi, xi+1].
On each interval, we have four unknowns ai, bi, ci and di, i = 1, 2, ..., n. Therefore, the
total number of unknowns is 4n.
Continuity of F(x), F (x) and F (x) on (a, b) implies the following.
(i) Continuity of F(x) :
On [xi1, xi] : Pi (xi) = f(xi) = ai xi3 bi xi2 ci x i di
xi x x xi 1
= F ( xi 1 ) F ( xi ) (2.53)
xi xi 1 xi xi 1
( xi x) 2 ( x xi 1 ) 2
F (x) = Mi 1 Mi a. (2.54)
2( xi xi 1 ) 2( xi xi 1 )
Integrating (2.54) again with respect to x, we get
( xi x) 3 ( x xi 1 ) 3
F(x) = Mi 1 Mi ax b (2.55)
6( xi xi 1 ) 6( xi xi 1 )
where a, b are arbitrary constants to be determined by using the conditions
F(xi1) = f(xi1) and F(xi) = f(xi ). (2.56)
Denote xi xi1 = hi, f(xi1) = fi1, and f(xi) = fi. Note that hi is the length of the interval
[xi1, xi].
To ease the computations, we write
ax + b = c(xi x) + d(x xi1) where a = d c, b = c xi d xi1.
That is, we write (2.55) as
( xi x) 3 (x xi 1 ) 3
F(x) = Mi 1 Mi c( xi x) d( x xi 1 ) .
6 hi 6 hi
Using the condition F(xi1) = f(xi1) = fi1, we get
( xi xi 1 ) 3 hi3
fi1 = Mi 1 c( xi xi 1 ) Mi 1 chi
6 hi 6 hi
1 hi2
or c= fi 1 Mi 1 .
hi 6
( xi xi 1 ) 3 hi3
fi = Mi d ( xi xi 1 ) Mi dhi
6 hi 6 hi
1 hi2
or d= fi Mi .
hi 6
Substituting the expressions for c and d in (2.55), we obtain the spline in the interval [xi1, xi]
as
1 ( xi x) hi2
Fi(x) = [( xi x) 3 M i 1 (x xi 1 ) 3 Mi ] fi 1 Mi 1
6hi hi 6
(x xi 1 ) hi2
+ fi Mi (2.57)
hi 6
Note that the spline second derivatives Mi1, Mi are unknowns and are to be determined.
Setting i = i + 1 in (2.57), we get the spline valid in the interval [xi, xi+1] as
1 ( xi x) hi2 1
Fi+1(x) = [( xi 1 x) 3 M i (x xi )3 Mi 1 ] 1
fi Mi
6hi 1 hi 1 6
( x xi ) hi2 1
+ fi 1 Mi 1 (2.58)
hi 1 6
1 hi2 1 hi2
fi 1 Mi 1 fi Mi (2.59)
hi 6 hi 6
valid in the interval [xi1, xi], and
1
F i+1(x) = [ 3( x i 1 x )2 M i 3( x xi )2 M i 1 ]
6hi 1
1 hi2 1 1 hi2 1
fi Mi + fi 1 Mi 1 (2.60)
hi 1 6 hi 1 6
hi 1 1 hi 1 1 hi 1
= Mi fi Mi fi 1 Mi 1
2 hi 1 6 hi 1 6
hi 1 hi 1 1 1
or Mi 1 ( hi hi 1 ) M i Mi 1 ( fi 1 fi ) ( fi fi 1 )
6 3 6 hi 1 hi
i = 1, 2, ..., n 1. (2.61)
This relation gives a system of n 1 linear equations in n + 1 unknowns M0, M1, ..., Mn.
The two additional conditions required are the natural spline conditions M0 = 0 = Mn. These
equations are solved for M1, M2, ..., Mn1. Substituting these values in (2.57), we obtain the
spline valid in the interval [xi1, xi]. If the derivative is required, we can find it from (2.59).
Equispaced data When the data is equispaced, we have hi = hi+1 = h and xi = x0 + ih. Then, the
spline in the interval [xi1, xi], given in (2.57) and the relation between the second derivatives
given in (2.61) simplify as
1
F i(x) = [( x i x )3 M i 1 (x x i 1 )3 M i ]
6h
( xi x) h2 (x xi 1) h2
fi 1 Mi 1 + fi Mi (2.62)
h 6 h 6
6
M i1 + 4Mi + Mi+1 = ( fi 1 2 fi fi 1 ) (2.63)
h2
i = 1, 2, ..., n 1.
Remark 12 Splines provide better approximation to the behaviour of functions that have
abrupt local changes. Further, splines perform better than higher order polynomial approxi-
mations.
Example 2.22 Obtain the cubic spline approximation for the following data.
x 0 1 2
f(x) 1 3 29
1 1 1
F(x) = [(x1 x)3 M0 + (x x0)3 M1] + (x1 x) f0 M0 (x x0 ) f1 M1
6 6 6
1 1
= (33)x3 + (1 x)( 1) + x 3 (33)
6 6
1
= (11x3 3x 2).
2
On [1, 2]:
1 1 1
F(x) = [( x2 x) 3 M 1 (x x1 ) 3 M2 ] ( x2 x) f1 M1 (x x1 ) f2 M2
6 6 6
1 1
= [(2 x) 3 (33)] (2 x) 3 (33) (x 1) [29]
6 6
11 63
= (2 x) 3 x 34.
2 2
Since, 0.5 lies in the interval (0, 1), we obtain
1 11 3 17
F(0.5) = 2 .
2 8 2 16
Since, 1.5 lies in the interval (1, 2), we obtain
1 223
F(1.5) = [11(2 . )3
15 63(1.5) 68] .
2 16
Example 2.23 Obtain the cubic spline approximation for the following data.
x 0 1 2 3
f(x) 1 2 33 244
1 3 1
= x ( 24) (1 x) x 2 ( 24) 4 x3 5x 1.
6 6
On [1, 2]:
1 1 1
F(x) = [( x2 x)3 M 1 (x x1 ) 3 M2 ] ( x2 x) f1 M1 + (x x1) f2 M2
6 6 6
1 1 1
= [(2 x)3 ( 24) + (x 1)3 (276)] + (2 x) 2 ( 24) (x 1) 33 (276)
6 6 6
1
= [(8 12x + 6x2 x3)( 24) + (x3 3x2 + 3x 1)(276)] + 6(2 x) 13(x 1)
6
= 50x3 162x2 + 167x 53.
On [2, 3]:
1 1 1
F(x) = [( x3 x) 3 M2 (x x2 ) 3 M 3 ] ( x3 x) f 2 M2 + (x x2) f3 M3
6 6 6
1 1
= [(3 x) 3 (276)] (3 x) 33 (276) + (x 2)(244)
6 6
1
= [(27 27x + 9x2 x3) (276)] 13(3 x) + 244(x 2)
6
= 46x3 + 414 x2 985 x + 715.
The estimate at x = 2.5 is
F(2.5) = 46(2.5)3 + 414(2.5)2 985(2.5) + 715 = 121.25.
2. Write the relation between the second derivatives in cubic splines with equal
mesh spacing.
Solution The required relation is
6
Mi1 + 4Mi + M i+1 = ( fi+1 2fi + fi1), i = 1, 2, ..., n 1.
h2
3. Write the end conditions on Mi(x) in natural cubic splines.
Solution The required conditions are M0(x) = 0, Mn(x) = 0.
x 1 2 3 4
f(x) 3 10 29 65
7. Obtain the cubic spline approximation valid in the interval [1, 2], for the function given
in the tabular form, under the natural cubic spline conditions f (0) = M(0) = 0, and f (3)
= M(3) = 0. Hence, interpolate at x = 1.5.
x 0 1 2 3
f(x) 1 4 10 8
8. Fit the following four points by the cubic spline using natural spline conditions
M(1) = 0, M(4) = 0.
x 1 2 3 4
f(x) 1 5 11 8
x 1 2 3 4
f(x) 0 1 0 0
x 1 2 3 4
f(x) 1 2 5 11
Find the cubic splines and evaluate y(1.5). (A.U. Nov/Dec 2004)
1. (3x x2)/2; 1. 2. 8x2 19x + 12.
3. (x3 5x2 + 8x 2)/2. 4. (3x3 70x2 + 557x 690)/60; 44/3.
5. x3 + x2 x + 2; 35. 6. (x3 9x2 + 32x 24)/2; 6.
7. Profit in the year 2000 = 100. 8. 49.2819.
9. x3 + x2 ; 810. 10. 10x3 27x2 + 3x + 35; 71.
11. 2x3 4x2 + 4x + 1; 31.
12. (x2 200x + 6060)/32. Roots of f(x) = 0 are x = 162.7694 and x = 37.2306.
13. For f(x) = x n+1, f n+1 ( ) = (n + 1) !. 15. [x2x3(x1 + x4) + x1x4(x2 + x3)]/[x12 x22 x32 x42].
16. ( 1)n/(x0 x1 ... xn). 17. x3 9x2 + 21x + 1; 10.
18. (3x3 70x2 + 557x 690); 44/3. 19. 3x3 + 7x2 4x 32; 99.
20. x3 x2 ; 448. 21. 0.5118199.
22. 10x3 27x2 + 3x + 35; 71.
Approximation to the derivatives can be obtained numerically using the following two
approaches
(i) Methods based on finite differences for equispaced data.
(ii) Methods based on divided differences or Lagrange interpolation for non-uniform data.
1 1
+ s(s 1)(s 2)(s 3) 4f + s(s 1)(s 2)(s 3)(s 4) 5 f0 + ...
4! 0 5!
df df ds 1 df
dx ds dx h ds
1 1 2 1 1
= f0 (2s 1) f0 (3 s2 6s 2) 3
f0 (4 s3 18 s2 22s 6) 4
f0
h 2 6 24
1
(5 s4 40 s3 105 s2 100 s 24) 5
f0 ... (3.3)
120
At x = x0, that is, at s = 0, we obtain the approximation to the derivative f (x) as
1 1 2 1 3 1 4 1 5
f (x0) = f0 f0 f0 f0 f0 ... (3.4)
h 2 3 4 5
Differentiating (3.3) with respect to x, we get
d2 f 1 d df ds 1 d df
2
dx h ds ds dx h 2 ds ds
1 2 1 3 1
= f0 (6s 6) f0 (12s 2 36s 22) 4
f0
h2 6 24
1
+ (20 s3 120 s2 210 s 100) 5
f0 ... (3.5)
120
At x = x0, that is, at s = 0, we obtain the approximation to the derivative f (x) as
1 2 3 11 4 5 5 137 6
f (x0) = 2
f0 f0 f0 f0 f0 ... . (3.6)
h 12 6 180
We use formulas (3.3) and (3.5) when the entire data is to be used.
Very often, we may require only lower order approximations to the derivatives. Taking
a few terms in (3.4), we get the following approximations.
Taking one term in (3.4), we get
1 1
f (x0) = f0 = [f(x1) f(x0)],
h h
1 1
or, in general, f (xk) = fk = [f(xk+1) f(xk)]. (3.7)
h h
Taking two terms in (3.4), we get
1 1 2 1 1
f (x0) = f0 f0 { f ( x1 ) f ( x0 )} { f ( x2 ) 2 f ( x1 ) f ( x0 )}
h 2 h 2
1
= [ 3 f ( x0 ) 4 f ( x1 ) f ( x2 )] (3.8)
2h
1
or, in general, f (xk) = [ 3f(xk) + 4f(xk+1) f(xk+2)]. (3.9)
2h
Similarly, we have the approximation for f (x0) as
1 2 1
f (x0) = f0 [ f ( x2 ) 2 f ( x1 ) f ( x0 )]
h2 h2
1
or, in general, f (xk) = [ f (xk 2 ) 2 f ( xk 1 ) f ( x k )] . (3.10)
h2
Errors of approximations. Using Taylor series approximations, we obtain the error in the
formula (3.7) for f (x) at x = xk as
1
E(f, xk) = f (xk) [ f ( xk h) f ( x k )]
h
1 h2
= f (xk) { f ( xk ) hf ( x k ) f ( xk ) ...} f ( xk )
h 2
h
= f ( xk ) + ... (3.11)
2
The error is of order O(h), or the formula is of first order.
The error in the formula (3.8) for f (x) at x = xk is obtained as
1
E(f, xk) = f (xk) [ 3 f(xk) + 4f(xk+1) f(xk+2)]
2h
1 h2 h3
= f (xk ) 3 f ( xk ) 4 f ( xk ) hf ( x k ) f ( xk ) f ( xk ) ...
2h 2 6
(2h) 2 (2h) 3
f ( xk ) 2 hf ( xk ) f ( xk ) f ( xk ) ...
2 6
h2
= f ( x k ) + ... (3.12)
3
The error is of order O(h2), or the formula is of second order.
The error in the formula (3.9) for f (x) at x = xk is obtained as
1
E(f, xk) = f (xk) [f(xk + 2h) 2 f(xk + h) + f(xk)]
h2
1 (2h) 2 (2h) 3
= f (xk) f (xk ) 2hf ( x k ) f ( xk ) f ( xk ) ...
h2 2 6
h2 h3
2 f ( xk ) hf ( x k ) f (xk ) f (xk ) ... f ( xk )
2 6
Remark 1 It can be noted that on the right hand side of the approximation to f (x), we have
the multiplying factor 1/h, and on the right hand side of the approximation to f (x), we have
the multiplying factor 1/h2. Since h is small, this implies that we may be multiplying by a
large number. For example, if h = 0.01, the multiplying factor on the right hand side of the
approximation to f (x) is 100, while the multiplying factor on the right hand side of the
approximation to f (x) is 10000. Therefore, the round-off errors in the values of f(x) and hence
in the forward differences, when multiplied by these multiplying factors may seriously effect
the solution and the numerical process may become unstable. This is one of the drawbacks of
numerical differentiation.
Remark 2 Numerical differentiation must be done with care. When a data is given, we do not
know whether it represents a continuous function or a piecewise continuous function. It is
possible that the function may not be differentiable at some points in its domain. What happens
if we try to find the derivatives at these points where the function is not differentiable? For
example, if f(x) = | x |, and a data is prepared in the interval [ 1, 1], what value do we get
when we try to find f (x) at x = 0, where the function is not differentiable?
Remark 3 We use the forward difference formulas for derivatives, when we need the values
of the derivatives at points near the top of the table of the values.
Example 3.1 Find dy/dx at x = 1 from the following table of values
x 1 2 3 4
y 1 8 27 64
x y y 2y 3y
1 1
7
2 8 12
19 6
3 27 18
37
4 64
2 3 4 5
= ... f(x0)
2 3 4 5
1 1 2 1 3 1 4 1 5
or f (x0) = f0 f0 f0 f0 f0 ...
h 2 3 4 5
2 3 4 5 2
= ... f(x0)
2 3 4 5
2 3 11 4 5 5 137 6
= ... f ( x0 )
12 6 180
1 2 3 11 4 5 5 137 6
or f (x0) = 2
f0 f0 f0 f0 f0 ...
h 12 6 180
Example 3.3 Find f (3) and f (3) for the following data:
x f(x) f 2f 3f 4f 5f
3.0 14
3.968
3.2 10.032 0.768
4.736 0.464
3.4 5.296 0.304 2.048
5.040 1.584 5.120
3.6 0.256 1.888 3.072
6.928 1.488
3.8 6.672 0.400
7.328
4.0 14
1 1 2 1 3 1 4 1 5
f (x0) = f0 f0 f0 f0 f0
h 2 3 4 5
1 1 1 1 1
f (3.0) = 3.968 (0.768) ( 0.464) (2.048) ( 5.120) = 9.4667.
0.2 2 3 4 5
1 2 3 11 4 5 5
f (x0) = 2
f0 f0 f0 f0
h 12 6
1 11 5
f (3.0) = 0.768 0.464 (2.048) ( 5.12) = 184.4
0.04 12 6
Example 3.4 The following data represents the function f(x) = e2x. Using the forward differ-
ences and the entire data, compute the approximation to f (0.3). Also, find the first order and
second order approximations to f (0.3). Compute the approximation to f (0.3) using the entire
data and the first order approximation. Compute the magnitudes of actual errors in each case.
Solution The step length is h = 0.3 and x = x0 + sh = 0.0 + s(0.3). For x = 0.3, we get
s = 1. We have the following forward difference table.
x f(x) f 2f 3f 4f
0.0 1.0000
0.8221
0.3 1.8221 0.6759
1.4980 0.5556
0.6 3.3201 1.2315 0.4570
2.7295 1.0126
0.9 6.0496 2.2441
4.9736
1.2 11.0232
1 1 2 1 3 1 4
f (x0 + sh) = f (x0 + h) = f0 f0 f0 f0
h 2 6 12
1 1 1 1
f (0.3) = 0.8221 ( 0.6759) ( 0.5556) ( 0.4570) = 3.6851.
0.3 2 6 12
1 1
f (0.3) = f(0.3) = [f (0.6) f(0.3)]
h 0.3
1 1.4980
= [3.3201 1.8221] = = 4.9933.
0.3 0.3
1
From (3.9), f (xk) = [ 3 f(xk) + 4 f(xk+1) f(xk+2)].
2h
We get the second order approximation as
1
f (0.3) = [ 3 f(0.3) + 4 f(0.6) f(0.9)]
0.6
1
= [ 3(1.8221) + 4(3.3201) 6.0496] = 2.9408.
0.6
The exact value is f (0.3) = 2e0.6 = 2(1.8221) = 3.6442.
The errors in the approximations are as follows:
First order approximation: | 4.9933 3.6442 | = 1.3491.
Second order approximation: | 2.9408 3.6442 | = 0.7034.
Full data: | 3.6851 3.6442 | = 0.0409.
From (3.5), we have the following approximation for s = 1.
1 2 1 4
f (x0 + sh) = f (x0 + h) = 2
f0 f0
h 12
1 1
f (0.3) = 0.6759 (0.4570) 7.0869 .
0.09 12
The first order approximation gives
1 2
1
f (0.3) = f(0.3) = [f(0.9) 2f(0.6) + f(0.3)]
h2 h2
1
= [6.0496 2(3.3201) + 1.8221] = 13.6833.
0.09
The exact value is f (0.3) = 4e0.6 = 7.2884
The errors in the approximations are as follows:
First order approximation: | 13.6833 7.2884 | = 6.3949.
Full data: | 7.0869 7.2884 | = 0.2015.
Example 3.5 The following data gives the velocity of a particle for 8 seconds at an interval of
2 seconds. Find the initial acceleration using the entire data.
Time (sec) 0 2 4 6 8
dv
Solution If v is the velocity, then initial acceleration is given by .
dt t 0
We shall use the forward difference formula to compute the first derivative at t = 0. The
step length is h = 2.
We form the forward difference table for the given data.
x f(x) f 2f 3f 4f
0 0
172
2 172 960
1132 960
4 1304 1920 0
3052 960
6 4356 2880
5932
8 10288
1 1 1
f (0) = 172 (960) (960) = 6.
2 2 3
1 n
+ (x xn)(x xn1) ... (x x1) f(xn). (3.14)
n ! hn
Let x be any point near xn. Let x xn = sh. Then, the formula simplifies as
s(s 1) 2
s( s 1)(s 2) 3
f(x) = f(xn + sh) = f(xn) + s f(xn) + f(xn) + f(xn)
2! 3!
df df ds 1 df
dx ds dx h ds
1 1 2 1 1
= fn ( 2s 1) fn (3s 2 6s 2) 3
fn ( 4s 3 18s 2 22s 6) 4
fn
h 2 6 24
1
+ (5s 4 40 s 3 105s 2 100s 24) 5
fn ... . (3.16)
120
At x = xn, we get s = 0. Hence, we obtain the approximation to the first derivative f (xn) as
1 1 2 1 3 1 4 1 5
f (xn) = fn fn fn fn fn ... . (3.17)
h 2 3 4 5
1 1 2 1 3 1 4 1 5
f (xn1) = fn fn fn fn fn ... . (3.18)
h 2 6 12 20
d2 f 1 d df ds 1 d df
2
dx h ds ds dx h 2 ds ds
1 2 1 3 1
= fn (6 s 6) fn (12s 2 36 s 22) 4
fn
h2 6 24
1
+ (20 s3 120 s2 210 s 100) 5
fn ... . (3.19)
120
At x = xn, that is, at s = 0, we obtain the approximation to the second derivative f (x) as
1 2 3 11 4 5 5 137 6
f (xn) = 2
fn fn fn fn fn ... . (3.20)
h 12 6 180
1 2 1 4 1 5
f (xn1) = fn fn fn ... . (3.21)
h2 12 12
We use the formulas (3.17), (3.18), (3.20) and (3.21) when the entire data is to be used.
Remark 4 We use the backward difference formulas for derivatives, when we need the values
of the derivatives near the end of table of values.
Example 3.6 Using the operator relation, derive approximations to the derivatives
f (xn), f (xn) in terms of the backward differences.
2 3 4 5
= ... f(xn)
2 3 4 5
1 1 2 1 3 1 4 1 5
or f (xn) = fn fn fn fn fn ...
h 2 3 4 5
2 3 4 5 2
2 3 11 4 5 5
= ... f ( xn )
12 6
1 2 3 11 4 5 5
or f (xn) = fn fn fn fn ... .
h2 12 6
Example 3.7 Find f (3) using the Newtons backward difference formula, for the data
Solution The step length is h = 0.5 and x = xn + sh = 3.0 + s(0.5). For x = 3.0, we get
s = 0. We have the following backward difference table.
2 3 4
x f(x) f f f f
1.0 1.5
1.375
1.5 2.875 0.75
0.625 0.75
2.0 3.5 1.5 0.0
0.875 0.75
2.5 2.625 2.25
3.125
3.0 0.5
From the formula
1 1 2 1 3 1 4 1 5
f (xn) = fn fn fn fn fn ... ,
h 2 3 4 5
1 1 1
we obtain f (3) = 3.125 (2.25) (0.75) = 9.
0.5 2 3
Example 3.8 Find f (2.5), f (2) and f (2.5) using the Newtons backward difference method,
for the data of the function f(x) = ex + 1.
x f(x) f 2f 3f
1.0 3.7183
1.7634
1.5 5.4817 1.1440
2.9074 0.7420
2.0 8.3891 1.8860
4.7934
2.5 13.1825
1 1 1
we obtain f (2.5) = 4.7934 (18860
. ) (0.7420) = 11.9675.
0.5 2 3
The exact value is f (2.5) = e2.5 = 12.1875. The magnitude of the error in the solution is
| Error | = | 12.1875 11.9675 | = 0.2150.
For x = 2.0, we get s = 1. From the formula
1 1 2 1 3 1 4 1 5
f (xn1) = fn fn fn fn fn ... ,
h 2 6 12 20
1 1 2 1 3
we get f (2) = fn fn fn
0.5 2 6
1 1 1
= 4.7934 (1.8860) (0.7420) = 7.4535.
0.5 2 6
The exact value is f (2) = e2 = 7.3891. The magnitude of the error in the solution is
| Error | = | 7.3891 7.4535 | = 0.0644.
For x = 2.5, we get s = 0. From the formula
1 2 3 11 4 5 5
f (xn) = 2
fn fn fn fn ... ,
h 12 6
1
we get f (2.5) = [1.8660 + 0.7420] = 10.5120.
0.25
The exact value is f (2.5) = e2.5 = 12.1875. The magnitude of the error in the solution is
| Error | = | 12.1875 10.5120 | = 1.6705.
Example 3.9 The following data represents the function f(x) = e 2x.
Find f (1.2) f (0.9) and f (1.2), using the Newtons backward difference method.
Compute the magnitudes of the errors.
Solution The step length is h = 0.3. We have the following backward difference table.
x f(x) f 2f 3f 4f
0.0 1.0000
0.8221
0.3 1.8221 0.6759
1.4980 0.5556
0.6 3.3201 1.2315 0.4570
2.7295 1.0126
0.9 6.0496 2.2441
4.9736
1.2 11.0232
From x = xn + sh = 1.2 + s(0.3), we get for x = 1.2, s = 0. Using the formula
1 1 2 1 3 1 4 1 5
f (xn) = fn fn fn fn fn ... ,
h 2 3 4 5
1 1 1 1
we get f (1.2) = 4.9736 (2.2441) (1.0126) (0.4570) = 21.8248.
0.3 2 3 4
1 1 2 1 3 1 4 1 5
f (xn1) = fn fn fn fn fn ... ,
h 2 6 12 20
1 1 1 1
we get f (0.9) = 4.9736 (2.2441) (1.0126) (0.4570) = 12.1490.
0.3 2 6 12
1 2 3 11 4 5 5
f (xn) = fn fn fn fn ... ,
h 2 12 6
1 11
we get f (1.2) = 2.2441 1.0126 (0.4570) = 40.8402.
0.09 12
1.0 0.00000
0.81094
1.5 0.40547 0.235580
0.57536 0.061157
2.0 0.69315 0.113267
0.40546
3.0 1.09861
1 h2
E(f, xk) = f (xk) [ 3 f(xk) + 4f(xk+1) f(xk+2)] = f ( xk ) + ...
2h 3
1. The following data gives the velocity of a particle for 20 seconds at an interval of 5
seconds. Find the initial acceleration using the entire data.
Time (sec) 0 5 10 15 20
x 0 1 2 3 4
x 2 1 0 1 2 3 4
4. Find the value of x for which f(x) is maximum in the range of x given, using the follow-
ing table. Find also the maximum value of f(x).
x 9 10 11 12 13 14
(deg) 31 32 33 34
11. Using the Newtons forward difference formula, find f (1.5) from the following data.
Find the magnitude of the actual error, if the data represents the function ex + 1.
12. Given the following data, find y (6), y (5) and the maximum value of y.
x 0 2 3 4 7 9
x 0 2 3 4 7 8