Numerical Analysis I Chapter III - VI
Numerical Analysis I Chapter III - VI
Ax b (2)
Where a 21 a 22 . . . a 2 n x2 b2
A , x and b (3)
. .
a a .. . a
n1 n2 nn xn bn
Crammer’s rule
Gauss elimination
Gauss Jordan
Triangular factorization (LUD)
Matrix inversion
The above are direct methods for solving system of linear equations the detail you know
from your linear algebra course.
This is an iterative method. An iterative technique to solve the nn linear system
Ax b starts with an initial approximation
1
0
x1 x1
to the solution and generates a
0
( 0) x2 x2
x x .
.
0 x
xn n
x1
1 x1
2
sequence of vectors xk
k 1
x1
.
2
1
,
x2
.
2
2
, . .
. .
that converges to x.
xn xn
Iterative technique here involves a process that converts the system Ax b into an
equivalent system of the form
x Tx c (4)
for some fixed matrix T and vector c as follows.
Solving the ith equation in Ax b for xi to obtain (provided aii 0 )
x1
1
a12 x2 a13 x3 . . . a1n xn b1
a11 a11
1 b
x2 ( a21 x1 a23 x3 . . . a2 n xn ) 2 (5)
a22 a22
1 b
xn (an1 x1 an 2 x2 . . . an ( n 1) xn 1 n
ann ann
x= , T=
x2
.
xn
a12 a13 a1n
0 . . .
a11 a11 an n
a2 1 a2 3 a2 n
0 . . .
a2 2 a22 ann
an1 an 2 an 3 an ( n 1)
. . .
an n an n an n an n
b1
a 11
b2
and c =
.
a2 2
bn
an n
2
n aij x j bi
xi a
a for i 1,2,..., n (7 )
j 1 ii ii
j i
Note: - The absolute error or relative error of the approximate solution can be obtained
using either the l 2 norm or the l norm.
Definition: - The l 2 and l norms for the vector x ( x1 , x2 ,....., xn ) t are defined by
1
n 2
x 2
xi2 and x
max xi
i 1 ii n
Example: - solve the following linear system using Jacobi method accurate to within
10-2 in l 2 norm .
20 x1 x2 2 x3 17
3 x1 20 x2 x3 18
2 x1 3 x2 20 x3 25
Solution: - Solving the ith equation for xi (i 1,2,3) we get
1
x1 (17 x 2 2 x3 )
20
1
x2 (18 3x1 x3 )
20
1
x3 (25 2 x1 3x 2 )
20
And from Jacobi Method we have
1
x1( k ) (17 x2( k 1) 2 x3( k 1) )
20
1
x2( k ) ( 18 3 x1( k 1) x3( k 1) )
20
1
x3( k ) ( 25 2 x1( k 1) 3x2( k 1) )
20
1
x1(1) (17 x2( 0) 2 x3( 0) ) 0.85
20
1
x2(1) (18 3 x1( 0) x3( 0) ) 0.9
20
1
x3(1) (25 2 x1( 0) 3x2( 0) ) 1.25
20
3
Additional iterates, x ( k ) ( x1( k ) , x2( k ) , x3( k ) ) t , are generated in a similar manner and are
presented as in the table below
-------------------------------------------------------------
Iteration (k) x1k x2k x3k
-------------------------------------------------------------
1 0.85000 -0.90000 1.25000
2 1.02000 -0.96500 1.03000
3 1.00125 -1.00150 1.00325
4 1.00040 -1.00003 0.99965
5 0.99997 -1.00008 0.99996
6 1.00000 -1.00000 0.99999
7 1.00000 -1.00000 1.00000
---------------------------------------------------------------
Example: - solve the following linear system using Gauss-Seidel method accurate to
within 10-2 in l 2 norm .
20 x1 x2 2 x3 17
3 x1 20 x2 x3 18
2 x1 3 x2 20 x3 25
4
1
x1 (17 x 2 2 x3 )
20
1
x2 (18 3x1 x3 )
20
1
x3 (25 2 x1 3x 2 )
20
1
x1(1) (17 x2( 0) 2 x3( 0) ) 0.85
20
1
x2(1) ( 18 3 x1(1) x3( 0) ) 1.0275
20
1
x3(1) ( 25 2 x1(1) 3 x2(1) ) 1.01087
20
Additional iterates, x ( k ) ( x1( k ) , x2( k ) , x3( k ) ) t are generated in a similar manner and are
presented as in the table below
--------------------------------------------------------------
Iteration (k) x1k x2k x3k
---------------------------------------------------------------
1 0.85000 -1.02750 1.01087
2 1.00246 -0.99983 0.99978
3 0.99997 -1.00001 1.00000
4 1.00000 -1.00000 1.00000
---------------------------------------------------------------
Remarks: -
1. Since the most recent approximation of the unknowns are used while proceeding
to the next step, the convergence in the Gauss-Seidel Method is faster than that of
Jacobi’s Meyhod
5
n
initial approximation, both the Jacobi and Gauss-Seidel Methods give sequences
of approximations x ( k ) k 1 that converges to the unique solution of Ax b .
Example: - Solve the following linear system accurate to within 10-2 in l 2 norm .
3 x1 x2 x3 1
3 x1 3x2 7 x3 4
3 x1 6 x2 2 x3 0
a. Using Jacobi Method
b. Using Gauss-Seidel Method
Solution: -
First we arrange the given system for diagonal dominancy
3 x1 x2 x3 1
3 x1 6 x2 2 x3 0
3 x1 3x2 7 x3 4
6
------------------------------------------------------------
Iteration (k) x1k x2k x3k
-------------------------------------------------------------
1 0.33333 0.00000 0.57143
2 0.14286 -0.35714 0.42857
3 0.07143 -0.21429 0.66327
4 0.04082 -0.25680 0.63265
5 0.03685 -0.23129 0.66399
6 0.03490 -0.23976 0.65476
7 0.03516 -0.23571 0.65922
8 0.03502 -0.23732 0.65738
------------------------------------------------------------
1
x1(1) (1 x2( 0) x3( 0) ) 0.33333
3
1
x2(1) (3 x1(1) 2 x3(0) ) 1.66667
6
1
x3(1) (4 3 x1(1) 3x2(1) ) 0.50000
7
---------------------------------------------------------------
Iteration (k) x1k x2k x3k
----------------------------------------------------------------
1 0.33333 -0.16667 0.50000
2 0.11111 -0.22222 0.61905
3 0.05291 -0.23280 0.64853
4 0.03956 -0.23595 0.65560
5 0.03615 -0.23661 0.65734
6 0.03535 -0.23679 0.65776
-----------------------------------------------------------------
Exercise: -
7
1. Solve the following linear system using Jacobi method with tolerance 0.01 .
2 x1 2 x3 5 x3 1
a) 4 x1 x2 x3 5
x1 3 x2 x3 4
x 2 2 x3 0
1
x1 2 x2 x3 4
b) 2
1
2 x1 x2 x3 4
2
4 x2 8 x3 x4 11
10 x1 5 x2 6
c)
x3 5 x4 11
5 x1 10 x2 4 x3 25
Expanding each of the functions in (2) by Taylor’s series for function of two variables to
first degree term, we get approximately
f ( x0 , y0 ) hf x ( x0 , y0 ) kf y ( x0 , y0 ) 0
(3)
g ( x0 , y0 ) hg x ( x0 , y0 ) kg y ( x0 , y0 ) 0
8
Solving equation (3) for h and k , we get a new approximation to the root as
( x1 , y1 ) ( x0 h , y0 k )
This process is repeated till we get the values to the desired accuracy.
Note: -
1. This method will not converge unless the starting values of the root chosen are
close to the actual root.
2. The method can be extended to 3 equations in 3 unknowns. But it is very
cumbersome to obtain a meaningful solution unless the entire information about
the equations and their physical context is available.
Example: -Use Newton’s Method to compute x ( 2) for the following nonlinear equation.
x 2 y 11
x y2 7
Solution: -
Initial approximation to the solution using the graphing facility of MATHLAB as below
9
20
10
D B
0
C A
-10
-20
-30
-40
-8 -6 -4 -2 0 2 4 6 8
f x ( x, y ) 2 x , f y ( x, y ) 1
g x ( x , y ) 1 , g y ( x, y ) 2 y
To approximate the solution at B chose a point near A. Let ( x0 , y0 ) ( 2.5, 3) and check
that the first three approximations to the solution are
10
( x1 , y1 ) (3.017241, 2.163793)
( x2 , y 2 ) (2.998983 , 2.006434)
( x3 , y3 ) (2.999998, 2.000011)
Check also that at point B the exact solution is (3, 2).
Also approximate the solution at the points C and D.
Exercise: - Use Newton’s Method for system of nonlinear equations to solve the
following. Perform only two iterations in each case. Try to interpret each equation
graphically to obtain an initial approximation.
x2 y 5
a)
y2 x 3
x 2( y 1)
b)
y 2 3 xy 7
xy x 9
c)
y2 x2 y2
x2 y2 4
d)
x 2 y 2 16
CHAPTER FOUR
FINITE DIFFERENCES
Forward and backward differences
Let y f (x) be a function which take the set of discrete values y 0 , y1 , y 2 , , y n to the
corresponding values x 0 , x1 , x 2 , , x n of x , where xi x0 ih , i 1,2,3,..., n and h
is the step length (or size). To determine the values of f ( x) or f '( x ) for some
intermediate or outside values of x , two types of differences are very useful namely
forward differences and backward differences.
11
Argument / x x0 x1 x2 x3 xn
Entry / y y0 y1 y2 y3 yn
where is called the forward difference operator and y 0 , y1 , y 2 , , y n are called
first forward differences and in general
y r y r 1 y r
The differences of the first forward differences are called second forward differences and
2 y r y r 1 y r
Similarly one can define third forward differences, fourth forward differences etc.
The following table which is called the forward difference table shows how the forward
differences of all orders can be formed from the following tabulated data.
X x0 x1 x2 x3 x4 x5 x6
Y=f(x) y0 y1 y2 y3 y4 y5 y6
x y 2 3 4 5 6
x0 y0 y 0 2 y0 3 y 0 4 y0 5 y0 6 y0
x1 y1 y1 2 y1 3 y1 4 y1 5 y1
12
x2 y2 y 2 2 y 2 3 y 2 4 y 2
x3 y3 y3 2 y3 3 y3
x4 y4 y 4 2 y 4
x5 y5 y5
x6 y6
Remark: - Any higher order forward differences can be expressed in terms of the entries
(or values of y) like
2 y0 (y0 ) ( y1 y0 ) y1 y 0 y 2 y1 y1 y 0 y 2 2 y1 y 0
3 y0 (2 y0 ) ( y 2 2 y1 y0 ) y 2 2y1 y0
( y3 y 2 ) 2 y 2 y1 ( y1 y0 )
y3 3 y 2 3 y1 y 0
y0 (3 y0 ) y3 3 y 2 3 y1 y0 y3 3y 2 3y1 y0
4
y 4 4 y3 6 y 2 4 y1 y
Generally,
n n n n
n y0 yn yn1 yn2 yn3 1 k y0 , k 0,1,2,3,. . .
0 1 2 3
Example: - Construct the forward difference table for the data below
x 0 1 2 3 4
y 1.0 1.5 2.2 3.1 4.6
You can read the above differences directly from the difference table as
y 2 0.9 , 2 y 2 0.6 , 3 y1 0.4 and 4 y0 0.4
13
4 4 4 4 4
4 y0 y 4 y3 y 2 y1 y0
0 1 2 3 4
y4 4 y3 6 y2 4 y1 y0
4.6 4(3.1) 6(2.2) 4(1.5) 1
0.4
n, the nth forward difference of p (x ) i.e. n p ( x) a n n!h n and all higher order
differences of p(x) are zero.
Exercise: - Evaluate 10 (1 ax 2 )(1 bx 2 )(1 cx 2 )(1 dx 4 )
Answer = abcd (10!) h10
difference operator. Similarly, the second and higher order backward differences are
obtained by:
2 y n y n y n 1
3 y n 2 y n 2 y n 1
4 y n 3 y n 3 y n 1
k y n k 1 y n k 1 y n 1
14
Moreover;
n n n n
n yn yn yn1 yn2 yn3 1 k y0 , k 0,1,2,3
0 1 2 3
The following table which is called the backward difference table shows how the
forward differences of all orders can be formed from the following tabulated data.
X x0 x1 x2 x3 x4 x5 x6
Y=f(x) y0 y1 y2 y3 y4 y5 y6
x Y 2 3 4 5 6
x0 y0
x1 y1 y1
x2 y2 y 2 2 y2
x3 y3 y 3 2 y3 3 y3
x4 y4 y 4 2 y4 3 y4 4 y4
x5 y5 y 5 2 y5 3 y5 4 y5 5 y5
x6 y6 y 6 2 y6 3 y6 4 y6 5 y6 6 y6
Example: - Write the forward difference table for the following data.
X 0 1 2 3 4 5
y 18 21 25 27 30 34
y3 2 , 2 y 2 1 , 3 y 4 3 , 4 y5 3 and 5 y5 9
15
Exercise: - Form the table of backward differences of the function
f ( x) x 3 3 x 2 5 x 7 for x 2 , 1, 0 ,1, 2 , 3, 4
4u 0 and 4 y 4
1 n 1 1 1
c. tan tan 2
n 2n
Solution: -
1 1 1 f ( x ) f ( x h) f ( x h) f ( x )
a) f ( x h) f ( x ) f ( x ) f ( x h )
f ( x ) f ( x ) f ( x h)
f ( x)
f ( x ) f ( x h)
b) Exercise
1 n 1 1 n
c) Let f (n) tan & take h=1.Then f (n 1) tan
n n 1
Now,
n 1 n 1
f (n) f (n h) f (n) tan 1 tan
n 1 n
n n 1
tan 1 n 1 n tan 1 1
1 n n 1 2n 2
n 1 n
Let tan 1
x & tan 1 y tan x & tan y
tan tan x y
Now, tan( )
1 tan tan 1 xy
x y
( ) tan 1
1 xy
x y
tan 1 x tan 1 y ta 1
1 xy
16
1 n 1 1 1
Thus, tan tan 2
n 2n
CHAPTER FIVE
INTERPOLATION
Introduction
Suppose we are given the following values of y f (x) for a set of values of x as given
by the table below
x x0 x1 x2 ……….. xn
Y = f(x) y0 y1 y2 ….……. yn
(1)
Then the process of finding the value of y corresponding to any value of x between
x0 and xn is called Interpolation, while the technique of computing the value of y
outside the range [ x0 , xn ] is called Extrapolation. The term Interpolation is often taken
to include Extrapolation.
If y f (x) is known explicitly then the value of y corresponding to any value of x can
be easily found. Conversely, if y f (x) is given with the help of tabulated data as in (1)
above, f (x ) is replaced by another function (x ) which assumes the same values as
those of f (x ) at the tabulated set of points. Any other value may be calculated from
(x ) which is known as the Interpolating function. If (x ) is a polynomial then it is
called the Interpolating Polynomial and the process is called the polynomial
interpolation.
17
Given the tabulated data like (1) in it is to find a polynomial pn (x) of the n th degree
such that y and pn (x) agree at the tabulated points. For this let the values of x be
Where the constants a i , i 1, 2 , 3 , , n are to be determines using the idea that y and
pn (x) should agree at tabulated points. Thus
p n ( x0 ) a 0 y 0 a 0 y 0
pn ( x1 ) y1 a0 a1 ( x1 x0 ) y0 a1 ( x1 x0 )
y1 y 0 y 0
a1
x1 x0 h
pn ( x2 ) y 2 a0 a1 ( x2 x0 ) a2 ( x2 x0 )( x2 x1 )
y1 y0
y 2 y0 2h a2 2h.h
h
y 2 2 y1 y0 2h 2 a2
y 2 2 y1 y0
a2
2h 2
2 y0
a2
2h 2
Similarly on substituting x x3 , x4 , x5 , xn in ( 2), we get :
3 y 0 4 y 0 n y 0
a3 , a 4 , , a n
3!h 3 4!h 4 n!h n
Substituting these values of a0 , a1 , a2 , a n in (2), we get :
y0 2 y0 3 y0
pn ( x) y0 ( x x0 ) ( x x 0 )( x x1 ) ( x x0 )( x x1 )( x x2 )
h 2!h 2 3!h 3
(3)
n y0
( x x0 )( x x1 )( x x2 )( x xn 1 )
n!h n
Or, more specially, if it is required to evaluate pn (x) for x x0 uh where u R ,
then from (3)
18
x x0 uh
x x1 x0 uh ( x0 h) uh h h(u 1)
x x2 x0 uh ( x0 2h) uh 2h h u 2
x xn 1 x0 uh ( x0 (n 1)h) uh ( n 1)h h(u ( n 1))
(5)
and then impose the condition that y & pn ( x) should agree at the tabulated points
x n , x n 1 , x n 2 , , x 2 , x1 , x 0 we obtain
u u (u 1) 2 u (u 1)(u 2) 3
p n ( x ) y n y n yn yn
1! 2! 3!
u (u 1)(u 2) (u (n 1)) n
y n … (6)
n!
x xn
where u
h
(6) is called Newton’s backward difference interpolation formula and it used for
interpolating the values of y near the end of a set of tabulated values.
Example: - From the following table estimate y when x 1.75 , x 1.85 and x 2.4 .
using Newton’s interpolation formula.
19
x 1.7 1.8 1.9 2.0 2.1 2.2 2.3
y ex 5.474 6.050 6.686 7.389 8.166 9.025 9.974
Solution: -
Forming the difference table first,
x y Dy D2y D3 y D4 y D5 y D6 y
1.7 5.474
0.576
1.8 6.05 0.06
0.636 0.007
1.9 6.686 0.067 0
0.703 0.007 0.001
2 7.389 0.074 0.001 -0.002
0.777 0.008 -0.001
2.1 8.166 0.082 0
0.859 0.008
2.2 9.025 0.09
0.949
2.4 9.974
x y Vy V2y V3 y V4 y V5 y V6 y
x 1.75 is near the beginning of the data, therefore we use Newton’s forward formula.
x x0
x0 1.7 , h 0.1 , u 0.5
h
u u (u 1) 2 u (u 1)(u 2) 3
y ( x) p 6 ( x) y 0 y 0 y0 y0
1! 2! 3!
u (u 1)(u 2) (u 5) 6
y0
n!
y (1.75) 5.755006
x 1.85 is very near the beginning of the data than near the end, therefore we use
Newton’s forward formula.
x x0
x0 1.8 , h 0.1 , u 0.5
h
u u (u 1) 2 u (u 1)(u 2) 3 u (u 1)(u 2)(u 3) 4
y ( x) p5 ( x) y 0
y 0 y0 y0 y0
1! 2! 3! 4!
u (u 1)(u 2) (u 4) 5
y0
n!
y (1.85) 6.359997
x 2.4 is very near the end of the data, therefore we use Newton’s backward formula.
20
x x6
x6 2.3 , h 0.1 , u 1
h
u u (u 1) 2 u (u 1)(u 2) 3
y ( x ) p 6 ( x ) y n y n yn yn
1! 2! 3!
u (u 1)(u 2) (u 5) 6
yn
n!
y (2.4) 11.018021
Example: - From the following table, estimate the number of students who obtained
marks between 40 and 45.
Marks Number of students
30-40 31
40-50 42
50-60 51
60-70 35
70-80 31
We need to find y(45) that is equal to the number of students who got marks less than 45
and for this we use Newton’s forward difference formula(why?).
Forming the difference table first,
x y Dy D2y D3 y D4 y
40 31
42
50 73 9
51 -15
60 124 -16 37
35 12
70 159 -4
31
80 190
x x0
x 45 , x0 40 , h 10 , u 0.5
h
21
u u (u 1) 2 u (u 1)(u 2) 3 u (u 1)(u 2)(u 3) 4
y ( x) p 4 ( x) y 0 y 0 y0 y0 y0
1! 2! 3! 4!
y ( 45) 47.867 48
Since y ( 40) is 31, the number of students who scored between 40 and 45 is:
48 – 31 = 17
Exercise: -
1. The population of a certain city in the census was as under
2. 4.8 , 8.4 , 14.5 , 23.6 , 36.2 , 52.8 , 73.9 are consecutive terms of a sequence
of
which 23.6 is the 6th term. Find the first and the tenth term of the sequence.
Answer: - tenth term = 100.000038
3. The following table gives the population of a town during six censuses. Estimate the
increase in the population during the period from 1976 to 1978.
22
Let y f (x) be a function which passes through (n+1) given points
( x0 , y0 ) , ( x1 , y1 ) ,, ( xn , y n ) . We can represent f (x ) as a polynomial in x of degree
n as follows.
pn ( x) a0 ( x x1 )( x x2 )( x xn ) a1 ( x x0 )( x x2 )( x xn )
a2 ( x x0 )( x x1 )( x x3 )( x xn ) an ( x x0 )( x x1 )( x xn 1 ) ... (7)
where ai , i 1,2,3,..., n are coefficients whose values are to be determined here also
using the idea that y and pn (x) should agree at tabulated points. Thus
pn ( x0 ) a0 ( x0 x1 )( x0 x2 )( x0 xn ) y0
y0
a0
( x0 x1 )( x0 x2 )( x0 xn )
pn ( x1 ) a1 ( x1 x0 )( x1 x2 )( x1 xn ) y1
y1
a1
( x1 x0 )( x1 x2 )( x1 xn )
Solution: -
23
See that the arguments are not equally spaced.
( x x1 )( x x 2 )( x x3 ) ( x x0 )( x x 2 )( x x3 )
log10 656 y0 y1
( x0 x1 )( x0 x 2 )( x0 x3 ) ( x1 x0 )( x1 x 2 )( x1 x3 )
( x x0 )( x x1 )( x x3 ) ( x x0 )( x x1 )( x x 2 )
y2 y3 2.8168
( x 2 x0 )( x 2 x1 )( x 2 x3 ) ( x3 x0 )( x3 x1 )( x3 x 2 )
log10 660 2.81957
Exercise: -
1. Use Lagrange’s interpolation formula to find f (6) and f (11)
x 2 5 7 10 12
f (x )
18 180 448 1210 2028
Answer: f(6) = 294 and f(11) = 1584
2. Find the Lagrange’s polynomial that passes through the points (0, 1), (1, 3) and (3, 2).
5 2 17
Answer : f x x x 1
6 6
x x0 x1 x2 x3 …………. xn
y=f(x) y0 y1 y2 y3 …………. yn
Then the first divided difference for the arguments x 0 and x1 is defined by the relation
y y0
[ x 0 , x1 ] 1
x1 x 0
Similarly
y y1 y y1 y y n 1
[ x1 , x 2 ] 2 , [ x 2 , x3 ] 3 , . . . , [ x n 1 , x n ] n
x 2 x1 x3 x 2 x n x n 1
Then the second divided difference for the arguments x 0 , x1 and x 2 is defined by the
relation
24
[ x1 , x 2 ] [ x 0 , x1 ]
[ x 0 , x1 , x 2 ] ,
x2 x0
[ x 2 , x3 ] [ x1 , x 2 ] [ x3 , x 4 ] [ x 2 , x 3 ]
Similarly , [ x1 , x 2 , x3 ] , [ x 2 , x3 , x 4 ] etc.
x3 x1 x4 x2
Then the third divided difference for the arguments x0 , x1 , x 2 and x3 is defined by
the relation
[ x1 , x2 , x3 ] [ x0 , x1 , x2 ]
[ x0 , x1 , x2 , x3 ]
x3 x0
[ x 2 , x3 , x 4 ] [ x1 , x 2 , x3 ]
Similarly , [ x1 , x 2 , x3 , x 4 ] ,
x 4 x1
and so on.
[ x , x , x ] [ x 2 , x3 , x 4 ]
[ x 2 , x3 , x 4 , x5 ] 3 4 5 etc.
x5 x 2
Remarks: -
The divided differences are symmetrical in their arguments i.e. independent of the order
of the arguments for it is easy to write
y0 y1
[ x0 , x1 ] [ x1 , x0 ]
x0 x1 x1 x0
y0 y1 y2
[ x0 , x1 , x 2 ]
( x0 x1 )( x0 x 2 ) ( x1 x0 )( x1 x 2 ) ( x 2 x 0 )( x 2 x1 )
and so on.
Example: - Construct the forward difference table for the data below
x 5 7 11 13 17
y 150 392 1452 2366 5202
Solution: -
-----------------------------------------------------------------------------
5 150 121 24 1 0
7 392 265 32 1
25
11 1452 457 42
13 2366 709
17 5202
-----------------------------------------------------------------------------
y y0
[ x , x0 ]
x x0
So that
y y 0 ( x x0 )[ x , x0 ] . . . (1)
[ x , x 0 ] [ x 0 , x1 ]
Again [ x , x0 , x1 ]
x x1
Which gives
[ x , x 0 ] [ x 0 , x1 ] ( x x1 )[ x , x 0 , x1 ]
Substituting this value of [ x , x 0 ] in (1), we get
y y 0 ( x x0 )[ x0 , x1 ] ( x x0 )( x x1 )[ x , x 0 , x1 ] . . . ( 2)
[ x , x0 , x1 ] [ x 0 , x1 , x 2 ]
Also [ x , x 0 , x1 , x 2 ]
x x2
Which gives
[ x , x0 , x1 ] [ x0 , x1 , x 2 ] ( x x 2 )[ x , x0 , x1 , x 2 ]
y p n ( x) y 0 ( x x 0 )[ x 0 , x1 ] ( x x 0 )( x x1 )[ x 0 , x1 , x 2 ] ( x x 0 )( x x1 )( x x 2 )[ x 0 , x1 , x 2 , x 3 ]
. . . ( x x 0 )( x x1 ) . . . ( x x n 1 )[ x 0 , x1 , x 2 , . . . , x n ]
This is called Newton Divided Difference Interpolation Formula.
x 5 7 11 13 17
Y=f(x) 150 392 1452 2366 5202
26
x y D[1] D[2] D[3] D[4]
-----------------------------------------------------------------------------
5 150 121 24 1 0
7 392 265 32 1
11 1452 457 42
13 2366 709
17 5202
-----------------------------------------------------------------------------
y p n ( x ) y 0 ( x x 0 )[ x 0 , x1 ] ( x x 0 )( x x1 )[ x 0 , x1 , x 2 ] ( x x 0 )( x x1 )( x x 2 )[ x 0 , x1 , x 2 , x 3 ]
( x x 0 )( x x1 )( x x 2 )( x x 3 )[ x 0 , x1 , x 2 , x 3 , x 4 ]
y (9) 810
y (12) 1872
y (15) 3600
Exercise: -
1. Find the Divided Difference Polynomial that passes through the points (-4, 1245),
(-1, 33), (0, 5), (2, 9) and (5, 1335).
Answer : f x 3x 4 5 x 3 6 x 2 14 x 5
27
CHAPTER VI
Numerical Differentiation and Integration
Numerical Differentiation
Numerical differentiation is a process of computing derivatives of a function f (x) at
some desired values of x, when the function is defined by a set of tabulated data.
For this, we first replace the exact relation y f (x) by the best interpolating formula
and then
dy
If the values of x are equidistant and is
dx
i. required near the beginning of the data we employ Newton’s forward formula
ii. required near the end of the data we employ Newton’s backward formula
If the values of x are not equidistant we use Lagrange’s formula as an interpolating
polynomial.
Derivative using Newton’s forward formula
u u (u 1) 2 u (u 1)(u 2) 3
y y 0 y 0 y0 y0
1! 2! 3!
u(u 1)(u 2)(u 3) 4
y 0 ....
4!
x x0
where x x0 uh u
h
dy dy du 1 dy
dx du dx h du
1 2u 1 2 3u 2 6u 2 3 4u 3 18u 2 22u 6 4
y 0 y0 y0 y 0
h 2 3! 4!
28
d 3x d 4x
Similarly we can proceed to obtain , ,...
dx 3 dx 4
dy d2y
If we want to find and at exactly x x0 u 0
dx dx 2
dy 1 1 1 1
y0 2 y0 3 y0 4 y0 .......
dx x x0 h 2 3 4
d2y 1 2 11 4 5
2
2
y 0 3 y0 y0 5 y 0 .......
dx x x0
h 12 6
dy dy du 1 dy
dx du dx h du
1 2u 1 2 3u 2 6u 2 3 4u 3 18u 2 22u 6 4
y n yn yn y n
h 2 3! 4!
d 3x d 4x
Similarly we can proceed to obtain , ,...
dx 3 dx 4
dy d2y
If we want to find and at exactly x x n u 0
dx dx 2
dy 1 1 1 1
y n 2 y n 3 y n 4 y n .......
dx x x h 2 3 4
n
d2y 1 2 11 4 5
yn 3 yn y n 5 y n .......
dx 2 x xn h 2 12 6
dy d2y
Example: - Evaluate and at x 1.2 , x 2 & x 2.2 from the following
dx dx 2
table.
29
Solution: - Forming the difference table
x y Dy D2y D3 y D4 y D5 y D6 y
1 2.7183
0.6018
1.2 3.3201 0.1333
0.7351 0.0294
1.4 4.0552 0.1627 0.0067
0.8978 0.0361 0.0013
1.6 4.953 0.1988 0.008 0.0001
1.0966 0.0441 0.0014
1.8 6.0496 0.2429 0.0095
1.3395 0.0535
2 7.3891 0.2964
1.6359
2.2 9.025
x y Vy V2y V3 y V4 y V5 y V6 y
dy 1 1 1 1 1
y 0 2 y 0 3 y 0 4 y 0 5 y 0 3.32032
dx x1.2 h 2 3 4 5
dy 1 1 1 1
y5 2 y5 3 y5 4 y5 5 y 7.3895
dx x2 h 2 3 4 5
dy 1 1 1 1
y 6 2 y 6 3 y6 4 y 6 5 y 6 y 9.8562
dx x2.2 h 2 3 4 6 6
Exercise: -
1. Given that
dy d2y
find the values of and at x 1.1 , 1.6 and 1.5
dx dx 2
2. Find the first and the second derivatives of the function tabulated below at the
points x 1.1 and 1.9
30
3. A slider machine moves along a fixed straight rod. Its distance y cm. along the
rod is given below for various values of the time t seconds. Find the velocity and
acceleration of the slider when t 0.1 , 0.5 and 0.6 seconds.
Numerical Integration
The process of integrating a definite integral from a set of tabulated values of the
integrand f(x) is called Numerical Integration. This process when applied to a function
of one variable is called Quadrature formula. In particular, this process can be used for
those definite integrals that have no explicit antiderivative or whose antidervative is not
easy to obtain.
6 1 2
e x sin x cos( x 3)
e dx , cos( x )dx , ln x tan( x 3) dx , etc.
2
x 2
Like,
0 0 1
31
To apply numerical integration, we first represent f(x) by interpolation formula, for this
case we use Newton Forward Difference Interpolation Formula.
2 y 0 3 y 0 n y 0
f ( x) y 0 uy 0 u (u 1) u (u 1)(u 2) ........u (u 1)(u 2)....(u (n 1))
2! 3! n!
x x0
where u
h
b
Let I f ( x) dx
a
Dividing the interval [a, b] into n subintervals of width h we form the following table
x x0 x1 x2 x3 …………. xn
y=f(x) y0 y1 y2 y3 …………. yn
Where xi x 0 ih , i 0, 1, 2, 3, 4, ...........
Trapezoidal Rule
b
To approximate f ( x)dx
a
using this rule, we first divide [a, b] into subintervals of step
x x0 x1 x2 x3 …………. xn
y=f(x) y0 y1 y2 y3 …………. yn
For each interval [xi, xi+1] i=0, 1, 2, 3…, we approximate f(x) by a linear forward
difference interpolation formula
y
f(x)
…………
x
a=x0 x1 x2 x3 x4 xn-1 xn
32
b xn x1 x2 x3 xn
a
f ( x) dx
x0
f ( x) dx
x0
f ( x) dx
x1
f ( x) dx
x2
f ( x) dx ..... f ( x)dx
xn 1
...... (1)
x1
To evaluate f ( x)dx
x0
x x0 uh dx hdu
x x0 u 0 and x x1 x 0 h u 1
x1 1
1
u2 1 h
x0
f ( x) dx h ( y 0 uy 0 ) du h y 0 u y 0
0
h y 0 y 0 [ y 0 y1 ]
2 0 2 2
x1
h
f ( x)dx 2 [ y
x
0 y1 ] .................... ( 2)
0
To evaluate
x2
f ( x)dx
x1
x x1 uh dx hdu
x x1 u 0 and x x 2 u 1
x2 1
1
u2 1 h
x f ( x ) dx h 0 1
( y u y1 ) du h y
1
u y1 h y1 y1 [ y1 y 2 ]
2 0 2 2
1
x2
h
f ( x)dx 2 [ y
x
1 y2 ] .................... (3)
1
Similarly
x3
h
f ( x)dx 2 [ y
x2
2 y3 ] .................... (4)
x4
h
f ( x)dx 2 [ y
x3
3 y4 ] .................... (5)
.
.
.
xn
h
x
f ( x ) dx
2
[ y n 1 y n ] ..............
n 1
33
b xn
h
a
f ( x)dx f ( x)dx 2 [( y
x
0 y n ) 2( y1 y 2 y3 ..... y n 1 )
0
And this is known as Trapezoidal Rule. This formula gives exact value if f(x) is a
polynomial function of degree at most 1.
To approximate f ( x)dx
a
using this rule subdivide [a, b] into an even number of
f(x)
..………..
x
a=x0 x2 x4 xn-2 b= xn
For each interval [x2i, x2i+2], i = 0, 1, 2…, we approximate f(x) by a quadratic Newton
Forward Difference Interpolating Polynomial.
For this
b xn x2 x4 x6 xn
a
f ( x )dx
x0
f ( x)dx
x0
f ( x)dx
x2
f ( x )dx
x4
f ( x)dx ...... f ( x)dx
xn 2
...... (1)
x2
To evaluate f ( x)dx
x0
x x 0 uh dx hdu
x x 0 u 0 and x x 2 u 2
34
x2 2
u (u 1) 2 h
x
f ( x) dx h ( y 0 uy 0
0
2!
y 0 )du [ y 0 4 y1 y 2 ]
3
........ ( 2)
0
x4
To evaluate f ( x)dx
x2
x x 2 uh dx hdu
x x 2 u 0 and x x 4 u 2
x4 2
u (u 1) 2 h
x
f ( x) dx h ( y 2 uy 2
0
2!
y 2 ) du [ y 2 4 y 3 y 4 ]
3
........ (3)
2
Similarly
x6
h
f ( x)dx 3 [ y
x
4 4 y5 y6 ] .......... .... ( 4)
4
.
.
xn
h
x
f ( x)dx 3 [ y n2 4 y n 1 y n ]
n2
b xn
h
a
f ( x)dx f ( x)dx 3 [( y
x
0 y n ) 4( y1 y3 ..... y n 1 ) 2( y 2 y 4 ..... y n 2 )
0
and this is Simpson' s 1 / 3 Rule
Note: - This rule requires the division of [a, b] in to an even number of subintervals of
width h and this formula gives exact value if f(x) is a polynomial function of degree at
most 2.
To approximate f ( x)dx
a
using this rule subdivide [a, b] into equal subintervals of
number multiple of 3.
35
y
f(x)
..………..
x
a=x0 x3 x6 xn-3 b= xn
For each interval [x3i, x3i+3], i = 0, 1, 2…, we approximate f(x) by Newton Forward
Difference Interpolating Polynomial of degree 3.
For this
b xn x3 x6 x9 xn
a
f ( x ) dx
x0
f ( x ) dx
x0
f ( x ) dx
x3
f ( x) dx
x6
f ( x ) dx ...... f ( x)dx
xn 3
...... (1)
x3
To evaluate
x0
f ( x)dx
x x0 uh dx hdu
x x0 u 0 and x x3 u 3
x3 3
u (u 1) 2 u (u 1)(u 2) 3 3
x
f ( x) dx h ( y 0 uy 0
0
2!
y0
3!
y 0 )du h[ y 0 3 y1 3 y 2 y 3 ] ........ ( 2)
8
0
x6
To evaluate
x3
f ( x)dx
x x3 uh dx hdu
x x3 u 0 and x x6 u 3
x6 3
u (u 1) 2 u (u 1)(u 3) 3 3
x
f ( x) dx h ( y 3 uy 3
0
2!
y3
3!
y 3 )du h[ y 3 3 y 4 3 y 5 y 6 ]........ (3)
8
3
Similarly
x6
3
f ( x)dx 8 h[ y
x
6 3 y 7 3 y 8 y 9 ] .......... ... ( 4)
3
.
.
.
36
xn
3
x
f ( x)dx 8 h[ y n 3 3 y n 2 3 y n 1 y n ] .............
n 3
b xn
a
f ( x)dx f ( x)dx
x0
3h
[( y0 y n ) 3( y1 y 2 y 4 y5 ..... y n 2 y n1 ) 2( y3 y6 ..... y n3 )
8
and this is Simpson' s 3 / 8 Rule
Note: - While applying Simpson’s 3/8 rule the number of subintervals should be taken as
multiple of 3 and this formula give exact value if f(x) is a polynomial function of degree
at most 3.
Remark: - In every rule accuracy could be increased by decreasing the step size h.
6
dx
Example: - By considering six subintervals evaluate 2 , using
0 1 x
a. Trapezoidal rule
b. Simpson’s 1/3 rule
c. Simpson’s 3/8 rule
60 1
Solution: - Dividing [0, 6] into 6 subintervals means h 1 . And f ( x )
6 1 x2
x 0 1 2 3 4 5 6
y = f(x) 1 0.5 0.2 0.1 0.0588 0.0385 0.027
6
dx h
a. 1 x
0
2
2
[( y 0 y 6 ) 2( y1 y 2 y 3 y 4 y 5 )] 1.4108
6
dx h
b. 1 x
0
2
3
[( y 0 y 6 ) 4( y1 y 3 y 5 ) 2( y 2 y 4 ) 1.3662
6
dx 3h
c. 1 x
0
2
8
[( y 0 y 6 ) 3( y1 y 2 y 4 y 5 ) 2( y 3 ) 1.3571
And from the following table we can see that accuracy in each method increases as h
decrease.
6
dx
Exact solution of 1 x
0
2
[tan 1 x]60 tan 1 6 1.40564765
37
12 0.5 1.40547621 1.403702 1.3996111
24 0.25 1.40560222 1.4056442 1.4055574
48 0.125 1.40563631 1.4056478 1.4056478
1
dx
Example: - Evaluate 1 x
0
using Simpson’s 1/3 rule for h = 0.25.
Solution: -
x 0 0.25 0.50 0.75 1.00
y = f(x) 1 0.8 0.6667 0.5714 0.5
1
dx h
1 x 3 [( y
0
0 y 4 ) 4( y1 y 3 ) 2 y 2 0.69325399
And from the following table we can see that accuracy in each method increases as h
decrease.
1
dx
1 x [ln(1 x)] ln 2 0.693147181
1
Exact solution of 0
0
Exercise: -
6
e
x2
1. Evaluate dx using Simpson’s 1/3 rule for h = 1.
0
2
x
3
2. Evaluate cos x 2 dx for h = 0.5 using
1
a. Trapezoidal rule
b. Simpson’s 1/3 rule
c. Simpson’s 3/8 rule.
38