Computer Oriented Numerical Methods!
Computer Oriented Numerical Methods!
APPLICATION
BCA-PC(L)-122
Computer Oriented Numerical
Methods
2
2. Iterative Methods 21-44
2.0 Objective
2.1 Introduction
2.2 Bisection Method
2.3 Rate of Convergence
2.4 False Position or Regula Falsi Method
2.5 Order of Convergence of False Position or Regula Falsi Method
2.6 Newton Raphson Method
2.7 Convergence of Newton Raphson Method
2.8 Bairstow’s Method
2.9 Check your progress
2.10 Summary
2.11 Keywords
2.12 Self-Assessment Test
2.13 Answer to check your progress
2.14 References/ SuggestedReadings
3
3.9 Predictor – Corrector Methods
3.9.1 Milne’s Method
3.9.2 Adams – Bashforth Method
3.10 Check Your Progress
3.11 Summary
3.12 Keywords
3.13 Answer to Check Your Progress
3.14 Self Assessment Questions
3.15 References/ SuggestedReadings
4. Interpolation-1(Newton) 78-105
4.0 Objective
4.1 Introduction
4.2 Errors in Polynomial Interpolation
4.3 Finite Differences
4.4 Detection of Error by use of Difference Tables
4.5 Differences of a Polynomial
4.6 Newton’s Forward Interpolation Formula
4.7 Newton’s Backward Interpolation Formula
4.8 Check your progress
4.9 Summary
4.10 Keywords
4.11 Self-Assessment Test
4.12 Answer to check your progress
4.13 References/ SuggestedReadings
5. Interpolation-2(Lagranges) 106-124
5.0 Objective
5.1 Introduction
5.2 Central Difference Interpolation Formulae
5.2.1 Gauss’s Forward Interpolation Formula
4
5.2.1 Gauss’s Backward Interpolation Formula
5.2.3 Stirling’s Formula
5.2.4 Bessel’s Formula
5.3 Interpolation with Unequal Intervals
5.3.1 Lagrange’s Interpolation Formula
5.4 Inverse Interpolation
5.4.1 Lagrange’s Method
5.4.2 Iterative Method
5.5 Check Your Progress
5.6 Summary
5.7 Keywords
5.8 Self Assessment Questions
5.9 Answer to Check Your Progress
5.10 References/ Suggested Readings
6. Numerical Differentiation & Integration 125-153
6.0 Objective
6.1 Introduction
6.2 Numerical Differentiation
6.2.1 Derivatives using Forward Difference Formula
6.2.2 Derivatives using Backward Differences Formula
6.2.3 Derivatives using Central Differences Formulae
6.3 Maxima and Minima of a Tabulated Function
6.4 Numerical Integration
6.4.1 Trapezoidal Rule
6.4.2 Simpson’s one-third Rule
6.4.3 Simpson’s three-eighth Rule
6.5 Errors in Quadrature Formulae
6.6 Check Your Progress
6.7 Summary
6.8 Keywords
5
6.9 Self Assessment Questions
6.10 Answer to Check Your Progress
6.11 References/ SuggestedReading
6
SUBJECT: Computer Oriented Numerical Methods
Computer Arithmetic
REVISED/UPDATED SLM BY AMIT
STRUCTURE
1.0 Learning objective
1.1 Introduction
1.2 Representation of Floating PointNumbers
1.2.1 Fixed PointRepresentation
1.2.2Floating PointRepresentation
1
1.0 LEARNING OBJECTIVES
1.1 INTRODUCTION
This chapter is to emphasis two types of real numbers viz. fixed point
representation,floatingpointrepresentation;withinfloatingpoint (non-normalizedand
normalized) and their representations in computer memory. Rules to perform
arithmetic operations (Addition, Subtraction, Multiplication, and Division) with
normalized floating numbers are also considered. At the last the various types of errors
with measurement that can be introduced during numerical computation are
alsodefined.
For easier understanding we assume that computer can store and operate with decimal numbers,
although it does whole work with binary number system. Also only finite number of digits can
be stored in the memory of the computer. We will assume that a computer has a memory in
which each location can store digits with provision for sign (+ or -)
There are two methods for storing of real numbers in the memory of the computer:
2
1.2.1 Fixed Point Representation
+ 4 1 2 4 5 6 2 4
This representation is called fixed point representation, since the position of decimal point is
fixed after 6 positions from left. In such a representation largest positive number we can store
999999.99 and smallest positive number we can store 000000.01. This range is quite inadequate.
Example 1.1: Following are the examples of fixed point representations in the decimal number
system:
210000
0.0005432
65754.546
234.00345
Example 1.2: Following are the examples of fixed point representations in the binary number
system:
10111
10.11101
111.00011
0.00011
3
Inadequate range: Range of numbers that can be represented is restricted by number of
digits or bits used.
Floating point representation overcomes the above mentioned problem and in position to
accommodate a much wider range of numbers than fixed point representation.
i) Mantissa part
ii) Exponent part
In such a representation it is possible to float a decimal point within number towards left or right
side.
For example:
53436.256 = 5343.6256 x 10 1
534.36256 x 102
53.436256 x 103
5.3436256 x 104
.53436256 x 105
.054436256 x 106
and so on
= 534362.56 x 10-1
5343625.6 x 10-2
53436256.0 x 10-3
534362560.0 x 10-4
And so on
4
Floating Point Mantissa Exponent
Number
…………. ………… ……
Let us assume we have hypothetical 8-digit computer out of which four digits are used for
mantissa and two digits are used for exponent with a provision of sign of mantissa and sign of
exponent.
5
Implied decimal point
± ±
It has been noted that a number may have more than one floating point representations. In order
to have unique representation of non-zero numbers a normalized floating point representation is
used.
A floating point representation in decimal number system is normalized floating point iff
mantissa is less than 1 and greater than equal to .1 or 1/10(base of decimal number system).
i.e.
A floating point representation in binary number system is normalized floating point iff mantissa
is less than 1 and greater than equal to .5 or 1/2(base of binary number system).
i.e.
In general, a floating point representation is called normalized floating point representation iff
mantissa lies in the range:
6
± ±
Exponent
Sign of Implied Mantissa
Sign of
Mantissa Decimal point exponent
Note: In computer, storage of floating point numbers is taken place in normalized form.
All the eight digits cannot be stored, since two digits are required by exponent.
Some specific rules are to be followed when arithmetic operations are performed with such
numbers.
1.3.1 Addition
For adding two normalized floating point numbers following rules are to be followed:
7
Example 1.3
Sol. Here exponents are equal, we have to add only mantissa and exponent remains
unchanged.
Addend .3456E05
Augend .4567E05
-----------
Sum . 8023E05
Example1.4
Sol. Here exponents are not equal, therefore firstly make exponents same such that mantissa
of number with smaller exponent sifted towards R.H.S. equal to the number of digits smaller
exponent less than with larger exponent i.e. 7-5=2.
.3456E05 .0034E07 Addend
.5456E07 Augend
.5490E07 Sum
Example 1.5
Sol. Here exponents are not equal, therefore firstly make exponents same such that mantissa
of number with smaller exponent sifted towards R.H.S. equal to the number of digits smaller
exponent less than with larger exponent i.e. 7-3=4.
.5456E07 Augend
.5456E07 Sum
8
Example 1.6
Sol. Here exponents are equal, we have to add only mantissa and exponent remains
unchanged.
.3456E05 Addend
.7567E05 Augend
Example 1.7
Sol. Here exponents are equal, we have to add only mantissa and exponent remains
unchanged.
.3456E05 Addend
.7567E05 Augend
OVERFLOW
As per exponent part can not store more than two digits, the number is larger than the
largest number that can be stored in a memory location. This condition is called
overflow condition and computer will intimate an error condition.
1.3.2 Subtraction
Rules to subtract a number from other are as follows:
9
Example 1.8
Sol. Here exponents are equal, we have to subtract mantissa and exponents remain
unchanged.
.4567E05 Minuend
.3456E05 Subtrahend
.18114E05 Difference
Example 1.9
Sol. Here exponents are not equal, therefore firstly make exponents same such that mantissa
of number with smaller exponent sifted towards R.H.S. equal to the number of digits smaller
exponent less than with larger exponent i.e. 7-5=2.
.5456E07
.3456E05 .0034E07
.5422E07
Example 1.10
Sol. Here exponents are not equal, therefore firstly make exponents same such that mantissa
of number with smaller exponent sifted towards R.H.S. equal to the number of digits smaller
exponent less than with larger exponent i.e. 7-3=4.
.5433E07
.3456E03 .0000E07
10
.5433E07
Example 1.11
Sol. Here exponents are equal, we have to subtract only mantissa and exponent remains
unchanged.
.5433E05
.5345E05
.0088E05->.8800E03
Example 1.12
Sol. Here exponents are equal, we have to subtract only mantissa and exponent remains
unchanged.
.5433E-99
.5345E-99
As per exponent part can not store more than two digits, the number is smaller than the
smallest number that can be stored in a memory location. This condition is called underflow
condition and computer will intimate an error condition.
1.3.3 Multiplication
If two normalized floating point numbers are to be multiplied following rules are followed:
Example 1.13 Find the product of following normalized floating point representation with 4
digit mantissa.
Sol.
Product of mantissa
Sum of exponents
23-45 = -18
Example 1.14 Find the product of following normalized floating point representation with 4-
digit mantissa.
Sol.
Product of mantissa
Sum of exponent
23-45 = -18
Example 1.15 Find the product of following normalized floating point representation with 4-
digit mantissa.
12
.4454E50 and .3456E51
Sol.
Product of mantissa
Sum of exponent
50+51 = 101
As per exponent part cannot store more than two digits, the number is larger than the largest
number that can be stored in a memory location. This condition is called overflow condition
and computer will intimate an error condition.
Example 1.16 Find the product of following normalized floating point representation with 4
digit mantissa.
Sol.
Product of mantissa
Sum of exponent
-50-51 = -101
As per exponent part can not store more than two digits, the number is smaller than the
smallest number that can be stored in a memory location. This condition is called underflow
condition and computer will intimate an error condition.
13
1.3.4 Division
If two normalized floating point numbers are to be divided following rules are to be
followed:
a. Exponent of second number is subtracted from first number to obtain of the result.
b. Mantissas of first number is divided by second number to obtain mantissa of the result
c. Result is written in normalized form.
d. Check for overflow/underflow condition.
(m1 x 10e1 ) ÷ (m2 x10e2 ) = (m1÷m2)x10(e1- e2)
= 4.4440E-2
= .4444E-1
A computer has finite word length and so only a fixed number of digits are stored and used
during computation. This would mean that even in storing an exact decimal number in its
converted form in the computer memory, an error is introduced. This error is machine dependent.
After the computation is over, the result in the machine form is again converted to decimal form
understandable to the users and some more error may be introduced at this stage.
e1+e2
Error introduced Error introduced
when data stored
when
informationretrieve
Figure 1.4 Effect of the errors on the result
d
14
1.4.1 Measurement of errors
E true E cal
c) Relative error =
E true
E true E cal
d) Percentage error = * 100
E true
Note: For numbers close to 1, absolute error and relative error are nearly equal.
500
Relative error (Rx)= =0.005
10000
0.0102
Relative error = = 0.0102
1
e) Inherent error
For example
15
1/3 = 0.333333 ……..
2 = 1.414………
22/7 = 3.141592653589793…………..
It is noticed that every arithmetic operation performed during computation, gives rise
to some error, which once generated may decay or grow in subsequent calculations.
In some cases, error may grow so large as to make the computed result totally
redundant and we call such a procedure numerically unstable. In some case it can be
avoided by changing the calculation procedure, which avoids subtractions of nearly
equal numbers or division by a small number or discarded remaining digits of
mantissa.
A = 4.568 B= 6.762
Solution: Method I
Method II
f) Transaction Error
Transaction error arises due to representation of finite number of terms of an infinite series.
x3 x5 x7 x9
Sin x = x – + - + ………………
3 5 7 9
16
Apart from above type of errors, we face following two types of errors during computation,
we come across with large number of significant digits and it will be necessary to cut number
up to desired significant digits. Meanwhile two types of errors are introduced.
Round-off Error
Chopping-off Error
g) Round-off
Round-off a number to n significant digits, discard all digits to the right of the nth digit, and if
this discarded number is:
-less than half a unit in the nth place, leave the nth digit unaltered.
- greater than half a unit in the nth place, increase the nth place digit by unity.
- exactly half a unit in the nth place, increase the nth digit by unity if it is odd, otherwise leave
it is unchanged.
h) Chopping-off
In case of chopping-off a number to n significant digits, discard all digits to the right of the
nth digit, and leave the nth digit unaltered.
Example: The numbers given below are rounded-off to five significant digits:
2.45678 to 2.4568
1.45334 to 1.4533
2.45657 to 2.4566
2.45656 to 2.4565
Example: The numbers given below are chopped-off to five significant digits:
2.45678 to 2.4567
17
1.45334 to 1.4533
2.45657 to 2.4565
2.45656 to 2.4565
1.6 SUMMARY
Let’s take a quick review of all that we have learned about Computer Arithmetic.
2. We learn how a number is converted into normalized number. Further we learn about
the mathematic operations (Addition, Subtraction, Multiplications, Division) on
normalized number.
3. We learn in this chapter about the error. We learn how an error is accrued when a
number is converted into normalized number.
18
1.7 KEYWORDS
Fixed Point Representation: - in this type of rage of numbers that can be represented is
restricted by number of digits or bits used.
Floating Point Representation: - it overcomes the problem associate with fixed point
representation.It consiststwo-part mantissa and Exponent.
Normalized number: - Number whose mantissa part ranging between 1 and .1 are called
normalized number.
Error: -Difference Between actual value (experimental value) to calculated value is called error.
Over flow: - when exponent is greater than two digits is called over flow.
1. .1234543E07
2. .2907E04
19
3. .22040E05
4. .0288E09 (.288E08)
5. 1E04 (.1E05)
6. .0025
1.10 REFERENCES/SUGGESTEDREADINGS
1. Computer Oriented Numerical Methods, V. Rajaraman, PHI.
2. Introductory Methods of Numerical Analysis, S.S. Sastry, PHI.
3. Numerical Methods for Scientific and Engineering Computation, M.K.Jain, S.R.Lyenger,
R.K.Jain, Wiley Eastern Limited.
4. Numerical Methods with Programs in C, T. Veerarajan, T. Ramachandarn., Tata McGraw
Hill.
20
SUBJECT: Computer Oriented Numerical Methods
ITERATIVE METHODS
STRUCTURE
2.0 Objective
2.1 Introduction
2.2 Bisection Method
2.3 Rate of Convergence
2.4 False Position or Regula Falsi Method
2.5 Order of Convergence of False Position or Regula Falsi Method
2.6 Newton Raphson Method
2.7 Convergence of Newton Raphson Method
2.8 Bairstow’s Method
2.9 Check your progress
2.10 Summary
2.11 Keywords
2.12 Self-Assessment Test
2.13 Answer to check your progress
2.14 References/ SuggestedReadings
21
2.0 OBJECTIVE
The objective of this lesson is to develop Iterative methods for finding the roots of the algebraic
and the transcendental equations.
2.1 INTRODUCTION
To find roots of an equation f(x) = 0, up to a desired accuracy, iterative methods are very useful.
This method is due to Bolzano and is based on the repeated application of the intermediate value
property. Let the function f(x) be continuous between aand b. For definiteness, let f(a) be
negative &f(b) be positive. Then, the first approximation to the root is
x1 = ½ (a+b)
If f(x1) = 0, then x1 is a root of f(x) = 0. Otherwise, the root lies between a and x1 or x1 and b
according as f(x1) is positive or negative. Then, we bisect the interval as before and continue the
process until the root is found to desired accuracy. If f(x1) is +ve, so that the root lies between
aand x1. Then the second approximation to the root is x2 = ½(a+x1). If f(x2) is –ve, the root lies
1
between x1 and x2. Then the third approximation to the root is x3 = (x1+x2) and so
2
on.Graphically it can be shown as
22
Fig 2.1
At each step the interval is determined in which the root lies. Middle value is next
approximation. The process is carried out till the result upto desired accuracy is obtained.
Let x0, x1, x2, ……… be the values of a root () of an equation at the 0th, 1st, 2nd …….. iterations
while its actual value is 3.5567. The values of this root calculated by three different methods, are
as given below:
x0 5 5 5
x5 10.6 3.55676
x6 11.9 3.55671
The values in the 1st method do not converge towards the root 3.5567. In the 2nd and 3rd methods,
the values converge to the root after 6th and 4th iterations respectively. Clearly 3rd method
converges faster than the 2nd method. This fastness of convergence in any method is represented
by its rate of convergence.
23
Since in case of Bisection method, the new interval containing the root, is exactly half the length
of the previous one, the interval width is reduced by a factor of ½ at each step. At the end of the
nth step, the new interval will therefore, be of length (b-a)/2n. If on repeating this process n times,
the latest interval is as small as given , then (b – a) /2n
This gives the number of iterations required for achieving an accuracy . For example, the
minimum number of iterations required for converging to a root in the interval (0, 1) for a given
are as under:
: 10-2 10-3 10-4
n: 7 10 14
As the error decreases with each step by a factor of ½, (i.e. ex+1/ex = ½), the convergence in the
bisection method is ‘linear’.
Example: Find a root of the equation x3 – 4x – 9 = 0, using the bisection method correct to three
decimal places.
Since f(2) is –ve and f(3) is +ve, a root lies between 2 and 3.
x1 = ½(2+3) = 2.5
The root lies between x1 and 3. Thus the second approximation to the root is
x2 = ½ (x1+3) = 2.75.
Therefore, the root lies between x1and x2. Thus the third approximation to the root is
x3 = ½(x1+x2) = 2.625
24
Then f(x3) = (2.625)3- 4(2.625)-9 = -1.4121, i.e, - ve
The root lies between x2 and x3. Thus the fourth approximation to the root is x4 = ½ (x2 + x3) =
2.6875.
x11 = 2.70654,
Example: Find real positive root of the following equation by bisection method:
x3 – 7x +5 = 0
Solution:
f(0) = 5, f(1) = -1
ab
Values of a, b, and the signs + of functional values are shown as follows:
2
ab ab
a b f(a) f(b) f( )
2 2
0 1 0.5 + - +
0.5 1 0.75 + - +
0.75 1 0.875 + - -
25
0.75 0.8125 0.7812 + - +
Root is 0.783.
f ( xi ) f ( xi 1 ) Fig 2.2
y – f(xi –1) = ( x xi 1 )
xi xi 1
Putting y = 0
f ( xi ) f ( xi 1 )
– f(xi –1) = ( x xi 1 )
xi xi 1
26
xi xi 1
or x- xi –1 = – f ( xi 1 )
f ( xi ) f ( xi 1 )
( x i x i 1 ) f ( x i 1 )
x = xi –1 –
f ( x i ) f ( x i 1 )
Therefore, the iterative formula is
( x i x i 1 ) f ( x i 1 )
xi+1 = xi– 1 -
f ( x i ) f ( x i 1 )
x i 1 f ( x i ) x i f ( x i 1 )
or xi + 1 =
f ( x i ) f ( x i 1 )
xi 1 xi
= [f(xi) – f(xi-1)]
f ( xi 1 ) f ( xi )
x i 1 f ( x i ) x i f ( x i 1 )
xi+1= (1)
f ( x i ) f ( x i 1 )
Let be the root of the equation f(x) = 0 and ei-1, ei, ei+1 be the errors when xi-1, xi, xi+1are the
approximate values of the root .
27
(ei 1 ) f (ei ) (ei ) f (ei 1 )
ei+1 + =
f (ei ) f (ei 1 )
ei 1 f (ei ) ei f (ei 1 )
= +
f (ei ) f (ei 1 )
ei 1 f ( ei ) ei f ( ei 1 )
ei+1 = (2)
f ( ei ) f ( ei 1 )
2
e
= ei-1[f() +eif()+ i f " ( ) ........ ]
2!
ei21
–ei[f() +ei-1f ()+ f " ( ) ........ ]
2!
2
e e e i e i21
= [ei-1 – ei] f() + i 1 i f " ( ) ........
2!
ei 1ei (ei ei 1 )
~ f " ( )
2!
2
ei
= [ f() +eif () + f " ( ) ........ ]
2!
ei21
– [f() +ei-1f()+ f " ( ) ........ ]
2!
28
2
e i e i21
= (ei– ei-1) f() + f " ( ) ........
2!
(2) becomes
1
ei 1 ei (ei ei 1 ) f " (α )
ei+1 = 2!
(ei -ei-1 )f ' (α )
ei 1 ei f " (α )
or ei+1 = ei 1 ei k , (3)
2 f ' (α )
f " (α )
where k =
2 f ' (α )
1/ p
e 1
1 k
ei+1 = ei i k ei p (5)
k' k '1 / p
1 k
= eipk
1
ei p (7)
k '1 / p
ei1+1/p = ei p
29
1
1+ =p or p2 – p – 1 = 0
p
1 5
p=
2
5 1 3.236
Taking +ve sign, p = = = 1.618
2 2
Example: Solve x3 – 9x +1 = 0 for the root lying between 2 and 4 by the method of false
position.
f(2) = – 9, f(4) = 29
( x i x i 1 ) f ( x i 1 )
xi+1 = xi-1-
f ( x i ) f ( x i 1 )
x0 2, x1 4
Putting i = 1,
f ( x0 ) 9 f ( x1 ) 29
( x1 x 0 ) f ( x 0 )
x2 = x0 -
f ( x1 ) f ( x 0 )
(4 2)(9) 18
= 2– 2 2.47
29 (9) 38
x1 2.47, x2 4
i = 2,
f ( x1 ) 6.063 f ( x 2 ) 29
1.53 6.063
x3 = 2.47 + = 2.73
35.063
30
For third approximation x4,
x2 2.73, x3 4
i = 3,
f ( x2 ) 3.2 f ( x3 ) 29
(1.27)(3.2)
x4 = 2.73 + 2.85
32.2
f(2.85) = –2.07
(1.15)(2.07)
x5 = 2.85+ 2.92,
31.07
f(2.92) = – 0.37
and for i = 5
(1.08)(3.7)
x6 = 2.92+ 2.93
29.37
f(2.93) = 0.21
similarly, for
i=6
(1.07)(0.21)
x7 = 2.93+ 2.937
29.21
31
2.6 NEWTON-RAPHSON METHOD
Let f(x) = 0 be the equation whose solution is required. If xi be a point near the root, f(x) may be
written as
f(x) = (xi+ x xi ).
Expanding it by Taylor’s series
( x xi ) 2
f(x) = f(xi) + (x-xi) f(xi) + f " ( x i ) .... 0
2!
f ( x i )
or x = xi -
f ' ( xi )
f ( x i )
xi+1 = xi - when f(xi) 0
f ' ( xi )
Let the graph of y = f(x) be drawn and Pi be any point (xi , yi) on it.
32
Fig 2.3
Equation of the tangent at pi is
f ( x i )
x – xi = –
f ' ( xi )
f ( x i )
or x = xi -
f ' ( xi )
f ( x i )
xi+1=xi - .
f ' ( xi )
Thus in this method, we have replaced the part of the curve between the point Pi and x – axis by
a tangent to the curve at Pi and so on.
Example: Find the real root of the equation xex– 2 = 0 correct to two decimal places, using
Newton –Raphson method.
Therefore, we obtain
Hence, the required root lies in the interval(0,1)and is nearer to1. Also f (x) and f(x) do not
vanish in (0,1); f(x) and f(x) will have the same sign at x = 1. Therefore, we take the first
approximation x0= 1, and using Newton-Raphson method, we get
f ( x 0 ) e 2
x1= x0 - = = 0.867879
f ' ( x0 ) 2e
33
and f(x1) = 0.06716
f ( x1 ) 0.06716
x2=x1 - = 0.867879 - = 0.85278
f ' ( x1 ) 4.44902
and
Example: Find a real root of the equation x3–x – 1 = 0 using Newton Raphson method, correct to
four decimal places.
Solution: Let f(x) = x3 – x – 1, then we note that f(1) = –1, f(2) = 5. Therefore, the root lies in the
interval (1, 2). We also note that
and
Since f(2) and f(2) are of the same sign, we choose x0 = 2 as the first approximation to the root.
The second approximation is computed using Newton-Raphson method as
f ( x 0 ) 5
x1=x0 - =2- = 1.54545 and f(x1) = 1.14573
f ' ( x0 ) 11
1.14573
x2=1.54545 - = 1.35961, f(x2) = 0.15369
6.16525
0.15369
x3=1.35961 - = 1.32579, f(x3) = 4.60959 x 10-3
4.54562
34
4.60959 10 3
x4=1.32579 - = 1.32471, f(x4) = -3.39345 x 10-5
4.27316
3.39345 10 5
x5=1.32471+ =1.324718, f(x5) = 1.823 x 10-7
4.26457
f ( xn )
xn+1 = xn - (1)
f ' ( xn )
We compare it with the general iteration formula xn+1 = (xn), and thus obtain
f ( xn )
(xn) = xn -
f ' ( xn )
or, we write it as
f ( x)
(x) = x -
f ' ( x)
We also know that the iteration method converges if |(x)|<1. Therefore, Newton-Raphson
formula (1) converges, provided
in the interval considered. Newton-Raphson formula therefore converges, provided the initial
approximation x0 is chosen sufficiently close to the root and f(x), f(x) and f(x) are continuous
and bounded in any small interval containing the root.
35
Definition:
Let
xn = + εn, xn+1 = + εn+1
where is a root of f(x) = 0. If we can prove that εn+1 = K εp, where K is a constant and n is the
error involved at the nth step, while finding the root by an iterative method, then the rate of
convergence of the method is p.
where is a root of f(x) = 0 and εn is the error involved at the nth step, while finding the root by
Newton-Raphson formula (1). Then, Eq. (1) gives
f ( n )
+ εn+1 = + εn – ,
f ' ( n )
i.e.,
f ( n ) f ' ( n ) f ( n )
εn+1 = εn – = n
f ' ( n ) f ' ( n )
1
εn+1 = n f ' ( ) n f ' ' ( ) ....
f ' ( ) n f " ( ) .......
n2
– f ( ) n f ' ( ) f " ( ) .....
2
n2 1
εn+1 = f "( )
2 f ' ( ) n f "( )
36
1
n2 f " ( ) f " ( )
= 1 n
2 f ' ( ) f ' ( )
n2 f " ( ) f " ( )
= 1 n
2 f ' ( ) f ' ( )
or
n2 f " ( )
εn+1 = o( n3 )
2 f ' ( )
f " ( )
K= (4)
2 f ' ( )
It shows that Newton-Raphson method has second order convergence or converges quadratically.
Example: Set up Newton’s scheme of iteration for finding the square root of a positive number
N.
Solution: The square root of N can be carried out as a root of the equation x2 – N = 0. Let
f(x) = x2 – N. By Newton’s method, we have
f ( xn )
xn+1 = xn - .
f ' ( xn )
xn2 N 1 N
xn+1 = xn - xn (5)
2 xn 2 xn
37
Solution : Since 9 = 3, 16 = 4, we take x0 = (3 + 4)/2 = 3.5. Using equation (5), we have
1 N 1 12
x1 = x0 3.5 3.4643
2 x0 2 3.5
1 12
x2 = 3 .4643 3 .4641
2 3 .4643
1 12
x3 = 3 .4641 3 .4641
2 3 .4641
Lin-Bairstow’s method is often useful in finding quadratic factors of polynomial and finding the
complete roots of a polynomial equation with real coefficients. Let the polynomial equation is
given by
f(x) = A3x3 + A2x2 + A1x + A0 = 0 (1)
A1 A0
r and s (2)
A2 A2
where the constants B1, B2, C and D have to be determined. Equating the coefficients of the like
powers of x in equations (1) and (3), we get
38
B2 = A3
B1 = A2 - rB2
D = A0 – sB1
From (4), it is clear that the coefficients B1, B2, C and D are functions of r and s. Since x2 + Rx +
S is a factor of the given polynomial, So
C(R, S) = 0 and D(R, S) = 0 (5)
Taking
R = r + r and S = s + s (6)
C C
C(R, S) = C(r, s) + r . s. 0
r s
(7)
D D
D(R, S) = D(r, s) + r . s. 0
r s
where the derivatives are to be computed at r and s. We solve equation (7) for r and s. Using
these values in (6) will give the next approximation to R and S, respectively. This process can be
repeated until successive values of R and S show no significant change.
f(x) = x3 – 2x2 + x – 2
Solution:
1
So, r=– and s=1
2
39
Using Equations (4), we have
B2 = 1; B1 = – 2 – r
C = 1 – r (– 2 –r ) – s = 1 + 2r + r2 – s,
and D = – 2– s (– 2 – r ) = – 2 + 2s +rs.
1 3
Also [C(r, s)](- ½,1) = 1 – 1 + –1=– ;
4 4
1 1
[D(r,s)](- ½,1) = –2 + 2 – =– ;
2 2
C C
2 2r 1; 1;
r 1 ,1 s 1 ,1
2 2
D
s 1;
r 1 ,1
2
D 3
and 2r
s ,1
1 2
2
r – s = ¾ and r +3/2s = ½
13 1
Hence r = and s =
20 10
Thus, we have
1 13 3
R=– + = = 0.15
2 20 20
1 9
and S=1– = = 0.9
10 10
40
Therefore, the quadratic factor is x2 + 0.15x + 0.9, which is now taken as the approximate
quadratic factor to get the second approximation. So that, for the second approximation r = 0.15
and s = 0.9, then
C
= 2 + 2(0.15) = 2.30,
r
C D D
= – 1; = 0.9 and = 2 + r = 2.15.
S r s
2.3 r – s = – 0.4225
r = – 0.1665312
and s = 0.0394783.
Thus, the second approximation to the quadratic factor is x2– 0.0165312 x + 0.9394783. This
process is repeated until no significant difference in the values of R and S is there, in two
consecutive steps
41
2.9 CHECK YOUR PROGRESS
2. Using Regula Falsi method, compute the real root of the following equations.
4. Using Bairstow’s method, obtain the quadratic factor of the polynomial given by
f(x) = x3 – 2x2 + x – 2
2.10 SUMMARY
1. In this chapter we learn about how to find root of an equation. We learn to use different
method to solve equations or to find root of equations.
2. We learn graphical representation of deferent methods.
3. We learn to find rate of convergence of different method (Bisection method, Newton
raphson method, regulafalsi method)
2.11 KEYWORDS
( x i x i 1 ) f ( x i 1 )
3. Regula Falsi Method:- x = xi –1 –
f ( x i ) f ( x i 1 )
4. Bairstow’s Method: - Lin-Bairstow’s method is often useful in finding quadratic factors
of polynomial and finding the complete roots of a polynomial equation with real
coefficients.
5. Rate of Convergence: -It is defined how fast a method provide the accurate result of
function or equations.
(4) x2 + 1
43
2.13 REFERENCES/ SUGGESTEDREADINGS
44
SUBJECT: Computer Oriented Numerical Methods
STRUCTURE
3.0 Objective
3.1 Introduction
3.2 Gaussian Elimination Method
3.3 Partial and Full Pivoting (Ill – Conditions)
3.4 Gauss – Seidel Iteration Method
3.5 Solution of a Differential equation
3.6 Taylor’s Series Method
3.7 Euler’s Method
3.8 Runge – Kutta Method
3.8.1 First Order Runge – Kutta Method
3.8.2 Second Order Runge – Kutta Method
3.8.3 Fourth Order Runge – Kutta Method
3.9 Predictor – Corrector Methods
3.9.1 Milne’s Method
3.9.2 Adams – Bashforth Method
3.10 Check Your Progress
3.11 Summary
3.12 Keywords
3.13 Answer to Check Your Progress
45
3.14 Self Assessment Questions
3.15 References/ SuggestedReadings
46
3.0 OBJECTIVE
The objective of this lesson is to describe the numerical methods for finding the solution
simultaneous linear equations and ordinary differential equations.
3.1 INTRODUCTION
Using matrix notation, the above system can be written in compact form as
The solution of the system of equations (2) gives nunknown values x1, x2, …., xn, which satisfy
the system simultaneously. If m>n, we may not be able to find a solution, in principle, which
satisfy all the equations. If m<n, the system usually will have an infinite number of solutions.
However, in this lesson, we shall restrict to the case m = n. In this case, if A 0, then the
system will have a unique solution, while, if A= 0, then there exists no solution.
Various numerical methods are available for finding the solution of the system of equations (2),
and they are classified as direct and iterative methods. In direct methods, we get the solution of
the system after performing all the steps involved in the procedure. The direct method, we
consider is Gaussian elimination.Under iterative methods, the initial approximate solution is
47
assumed to be known and is improved towards the exact solution in an iterative way. We
consider Gauss-Seidel iterative method.
In the Gaussian elimination method, the solution to the system of equations (2) is obtained in two
steps. In the first step, the given system of equations is reduced to an equivalent upper triangular
form using elementary transformations. In the second step, the upper triangular system is solved
using back substitution procedure by which we obtain the solution in the order xn, xn-1, xn-2, …, x2,
x1.
This method is explained by considering a system of n equations in n unknowns in the form as
follows
a11 x1 a12 x 2 a1n x n b1
a 21 x1 a 22 x 2 a 2 n x n b 2
(3)
a n1 x1 a n 2 x 2 a nn x n b n
Step 1: We divide the first equation by a11 and then subtract this equation multiplied by a21,
a31,.....,an1 from 2nd, 3rd,....., nth equation. Then the system (3) reduces to the following form:
x1 a '12 x2 a '1n xn b'1
a '22 x2 a '2 n xn b'2
(4)
a 'n 2 x2 a 'nn xn b'n
Here, we observe that the last (n – 1) equations are independent of x1, that is, x1 is eliminated
from the last (n–1) equations.
This procedure is repeated with the second equation of (4), that is, we divide the second equation
by a'22 and then x2 is eliminated from 3rd, 4th, …, nth equations of (4). The same procedure is
repeated again and again till the given system assumes the following upper triangular form:
48
c 11 x1 c 12 x 2 c 1n x n d 1
c 22 x 2 c 2 n x n d 2
(5)
C nn x n d n
Step II: Now, the values of the unknowns are determined by back substitution procedure, in
which we obtain xn from the last equation of (5) and then substituting this value of xnin the
preceding equation, we get the value of xn-1. Continuing this way, we can find the values of all
other unknowns in the order xn, xn-1, ….., x2,x1.
Example: Solve the following system of equations using Gaussian elimination method
2x + 3y – z = 5
4x + 4y – 3z =3
-2x + 3y – z =1
Solution: The given system of equations is solved in two stages.
Step 1: We divide the first equation by 2 and then subtract the resulting equation (multiplied by
4 and –2) from the second and third equations, respectively. Thus, we eliminate x from the 2nd
and 3rd equations. The resulting new system is given by
3 z 5
x y-
2 2 2
- 2y - z - 7 (1)
6y - 2z 6
Now, we divide the second equation of (1) by –2 and eliminate y from the last equation and the
modified system is given by
3 z 5
x y-
2 2 2
z 7
y (2)
2 2
- 5z 15
Step II : From the last equation of (2), we get
z =3 (3)
using this value of z, the second equation of (2) gives
49
7 3
y 2 (4)
2 2
Using these values of y and z in the first equation of (2), we get
5 3
x 3 1
2 2
Hence, the solution is given by x = 1, y = 2, z = 3
The Gaussian elimination method fails if any one of the pivot elements becomes zero. In such a
situation, we rewrite the equations in a different order to avoid zero pivots. Changing the order
equations is called pivoting.
Now we introduce the concept of partial pivoting. In this technique, if the pivot aii happens to be
zero, then the ith column elements are searched for the numerically largest element. Let the jth
row (j >i) contains this element, then we interchange the ith equation with the jth equation and
proceed for elimination. This process is continued whenever pivots become zero during
elimination. For example, let us examine the solution of the following simple system:
10-6x1 + x2 = 1
x1 + x2 = 2
Using Gaussian elimination method with and without partial pivoting, assuming that the
solution is required accurate to only four decimal places. The solution by Gaussian
elimination method gives x1 = 0, x2 = 1. If we use partial pivoting, the system takes the
form
x1 + x2 = 2
10-6x1 + x2 = 1
Using Gaussian elimination method, the solution is found to be x1 = 1, x2 = 1, which is a
meaningful and accurate result.
In full pivoting which is also known as complete pivoting, we interchange rows as well as
columns, such that the largest element in the matrix of the system becomes the pivot element. In
50
this process, the position of the unknown variables also get changed. Full pivoting, in fact, is
more complicated than the partial pivoting. Partial pivoting is preferred for hand computation.
Example: Solve the system of equations
x+ y+z=7
3x + 3y+ 4z =24
2x + y + 3z =16
by Gaussion elimination method with partial pivoting.
Solution: In matrix notation, the given system can be written as
1 1 1 x 7
3 3 4 y 24 (1)
2 1 3 z 16
To start with, we observe that the pivot element a11= 1 ( 0). However, looking at the first
column, it shows that the numerically largest element is 3 which is in the second row. Hence, we
interchange the first row with the second row and then proceed for elimination. Thus, equation
(1) takes the form
3 3 4 x 24
1 1 1 y 7 (2)
2 1 3 z 16
Step I: Dividing the first row of the system (2) by 3 and then subtracting the resulting row,
multiplied by 1 and 2 from the second and third rows of the system (2), we get
4 x 8
1 1
3
1
- y -1 (3)
3
-1 1 z 0
3
The second row in equation (3) cannot be used as the pivot row, as a22 = 0. Interchanging the
second and third rows, we obtain
51
4 x 8
1 1 3
-1 1 y 0 (4)
3
1
- z 1
3
which is in the upper triangular form. From the last row of (4), we get
z=3 (5)
-y + 1 = 0 or y = 1 (6)
x + 1+ 4 = 8 or x =3 (7)
x = 3, y = 1, z=3
Example: Solve by Gaussian elimination method with partial pivoting, the following system
of equations:
0x1+ 4x2 +2x3 + 8x4 = 24
0 4 2 8 x1 24
4
10 5 4 x 2 32
(1)
4 5 6.5 2 x 3 26
9 4 4 0 x 4 21
To start with, we note that the pivot row, that is, the first row has a zero pivot element
(a11 = 0). This row should be interchanged with any row following it, which on becoming a pivot
52
row should not have a zero pivot element. While interchanging rows, it is better to interchange
with a row having largest pivotal element. Thus, we interchange the first and fourth rows, which
is called partial pivoting and we get
9 4 4 0 x1 21
4
10 5 4 x 2 32
(2)
4 5 6.5 2 x 3 26
0 4 2 8 x 4 24
We note that, in partial pivoting, the unknown vector remains unaltered, while the right-hand
side vector gets changed.
Step I: In this case, divide the first row of the system (2) by 9 and then subtracting this resulting
row multiplied by 4 from the second and third rows of equation (2), we get
4 4 x1 2.333
1 0
9 9
0 8.222 3.222 4 x2 22.667 (3)
0 3.222 4.722 2 x3 16.667
0 4 2 8 x4 24
Now we divide the second pivot row by 8.222 and subtract the resultant row multiplied by 3.222
and 4 from the third and fourth rows of equation (3), we obtain
4 4 x1 2.333
1 9 9
0
x 2.757
0 1 0.392 0.486
2
(4)
0 0 3.459 0.432 x 3 7.784
0 0 0.432 6.054 x 4 12.973
Finally, we divide the third pivot row by 3.459 and subtract the resultant row multiplied by 0.432
from fourth row of equation (4), thereby getting the triangular form
53
4 4 x1 2.333
1 9 9
0
x 2.757
0 1 0.392 0.486
2
(5)
0 0 1 0.125 x 3 2.250
0 0 0 5.999 x 4 11.999
Step II: From the last row of equation (5), we get x4= 2.00. Using this value of x4 into the third
row of equation (5), we obtain
Similarly, we get
x2 = 1.00, x1 = 1.00
.............................................................................
In Gauss-Seidel method, the corresponding elements of xi(r+1) replaces those of xi(r) as soon as
they become available. Hence, it is called the method of successive displacements. In this
method (r+1)th approximation or iteration is computed from
54
b1 a12 (r) a
x1(r 1) - x 2 - 1n x (r)
n
a11 a11 a11
(r 1) b 2 a21 (r 1) a2n (r)
x2 - x1 - xn
a22 a22 a22 (1)
.............................................................
(r 1) b n an1 (r 1) an, (n -1) (r 1)
xn - x1 - x n -1
ann ann ann
Thus, the general procedure can be written in the following compact form
b i i -1 a ij (r 1) n a ij
x i(r 1) - xj x (r)j
a ii j 1 a ii j i 1 a ii (2)
To describe system (1) in the first equation, we substitute the r-th approximation into the right-
( r 1)
hand side and denote the result by x1 . In the second equation, we substitute
( r 1) ( r 1)
( x1 , x 3( r ) ,...., x n( r ) ) and denote the result x2 . In the third equation, we substitute
( r 1)
( x1 , x 2( r 1) , x 4( r 1) ,...., x n( r ) ) and denote the result by x3(r 1) , and so on. This process is continued
55
x2 = 0.5 +0.25x1 +0.25x4 (1)
Taking x2 = x3 = x4 = 0 on the right- hand side of the first equation of system (1), we get x1(1) =
0.5 Taking x3 = x4 = 0 and the current value of x1, we get
form the second equation of system (1). Further, we take x4 = 0 and the current value of x1, we
obtain
from the third equation of system (1). Now, using the current values of x2 and x3, the fourth
equation of system (1) gives
The Gauss-Seidel iterations for the given set of equations can be written as
Now, by Gauss-Seidel procedure, the second and subsequent approximations can be obtained
and the sequence of the first four approximation are given as below:
Iteration Variables
Number (r) x1 x2 x3 x4
1 0.5 0.625 0.375 0.5
2 0.75 0.8125 0.5625 0.5938
3 0.8438 0.8594 0.60941 0.6172
4 0.8672 0.8711 0.6211 0.6231
56
3.5 SOLUTION OF A DIFFERENTIAL EQUATION
The solution of an ordinary differential equation means finding an explicit expression for y in
terms of a finite number of elementary functions of x.
Let us consider the first order differential equation
to study the various numerical methods of solving such equations. In most of these methods, we
replace the differential equation by a difference equation and then solve it. These methods yield
solutions either as a power series in x from which the values of y can be found by direct
substitution, or a set of values of x and y. The method of Taylor series belong to the former class
of solutions. In this method, y in (1) is approximated by a truncated series, each terms of which is
a function of x. The information about the curve at one point is utilized and the solution is not
iterated. As such, these are referred to as single-step methods. The methods of Euler, Runga-
Kutta, Milne, Adams-Bashforth etc. belong to the latter class of solutions. In these methods, the
next point on the curve is evaluated in short steps ahead, by performing iterations till sufficient
accuracy is achieved. As such, these methods are called step-by-step methods.
Euler and Runga-Kutta methods are used for computing y over a limited range of x-values
whereas Milne and Adams methods may be applied for finding y over a wider range of x-values.
Therefore Milne and Adams methods require starting values which are found by Taylor series or
Runga-Kutta methods.
57
To obtain its particular solution, n conditions must be given so that the constants c1,c2, ……., cn
can be determined. If these conditions are prescribed at one point only (say x0) then the
differential equation together with the conditions constitute an initial value problem of the nth
order. If the conditions are prescribed at two or more points, then the problem is termed as
boundary value problem.
In this lesson, we shall first describe methods for solving initial value problems and then explain
finite difference method for solving boundary value problems.
dy
f ( x, y ) (1)
dx
d 2 y f f dy
,
dx 2 x y dx
Differentiating this successively, we can get y, yiv etc. Puttingx = x0 and y = 0, the values of
(y)0, (y)0, (y)0 can be obtained. Hence the Taylor’s series
( x x0 ) 2 ( x x0 ) 3
y = y0+(x-x0)(y)0+ (y)0 + (y)0 + .... (3)
2! 3!
gives the values of y for every value of x for which (3) converges.
On finding the value y1 for x = x1 from (3), y, y etc. can be evaluated at x = x1 by means of (1),
(2) etc. Then y can be expanded about x =x1. In this way, the solution can be extended beyond
the range of convergence of series (3).
58
Remarks: This is a single step method and works well so long as the successive derivatives can
be calculated easily. It is useful for finding starting values for the application of powerful
methods like Runga-Kutta, Milne and Adams-Bashforth.
Example: Find by Taylor’s series method, the values of y at x = 0.1 and x = 0.2 to five places
of decimals from dy/dx = x2y – 1, y(0) = 1.
Solution:
Here (y0) = 1.
y = x2y – 1, (y)0 = –1
x2 x3 x4
y = 1+ x (-1) + (0) (2) (6) .......
2! 3! 4!
x3 x4
1 x .......
3 4
Example: Apply Taylor’s method to obtain approximate value of y at x = 0.2 for the
differential equation dy/dx = 2y + 3ex, y(0) = 0. Compare the numerical solution obtained with
the exact solution.
Solution:
59
Differentiating successively and substituting x =0, y = 0 we get
x2 x3 x 4 iv
y (x) = y(0) + xy (0) + y" (0) y'" (0) y (0) .......
2! 3! 4!
9 2 21 3 45 4
= 0 +3x x x x .......
2 6 24
9 2 7 3 15 4
= 3x x x x .......
2 2 8
= 0.8110 (1)
dy
Now 2 y 3e x is a Leibniz’s linear in x. Its I.F. being e-2x , the solution is
dx
or y = -3ex + ce2x
y = 3 (e2x – ex)
Comparing (1) and (2) it is clear that (1) approximates to the exact value upto 3 decimal places.
60
3.7 EULER’S METHOD
dy
f ( x, y ), y ( x0 ) y o . (1)
dx
The curve of solution through P(x0, y0) for this differential equation is shown in the following
figure. Further, we want to find the ordinate of any other point Q on this curve
Fig 7.1
Let us divide LM into n sub-intervals each of width h at L1, L2,...... so that h is quite small.
In the interval LL1, we approximate the curve by the tangent at P. If the ordinate through L1
meets this tangent in P1(x0+h,y1), then
dy
= y0 + h = y0 + h f(x0,y0)
dx P
Let P1Q1 be the curve of solution of (1) through P1 and let its tangent at P1 meet the ordinate
through L2 in P2(x0+2h,y2). Then
61
y2=y1+h(fx0+h,y1) (2)
1.0 3.18
62
Thus the required approximate value of y = 3.18
dy y x
Example: Given with initial condition y = 1 at x = 0; find y for x = 0.1 by Euler’s
dx y x
method.
Solution:
We divide the interval (0, 0.1) into five steps, i.e., we take n = 5 and h = 0.02. The various
calculations are arranged as follows:
0.10 1.0928
The Taylor’s series method of solving differential equations numerically involved in finding the
higher order derivatives. However there is a class of methods known as RungeKutta methods
which do not require the calculations of higher order derivatives and give greater accuracy. The
Runge-Kutta formulae possess the advantage of requiring only the function values at some
selected points.
63
y1=y0+hf(x0, y0)= y0 +hy0 [y = f(x,y)]
h2
y1=y(x0+h)= y0 +hy0+ y0 " +.......
2
It follows that the Euler’s method agrees with the Taylor’s series solution upto the term in h.
h
y1=y+ [f(x0, y0)+ f(x0+h,y1)] (1)
2
h
y1 = y0+ [f0+f(x0+h, y0+ hf0)], (2)
2
where f0 = f(x0,y0).
h2 h3
y1=y(x0+h)=y0 + hy0 + y0+ y0+..... (3)
2! 3!
Expanding f(x0+h, y0+hf0) by Taylor’s series for a function of two variables, (2) gives
h f f
y1= y0+ f 0 f ( x 0 , y 0 ) h hf 0 O(h 2 )
2 x 0 y 0
1 f f
= y0+ hf 0 hf 0 h 2 f 0 O(h 3 )
2 x 0 y 0
64
h2 df ( x, y ) f f
= y0 + hf0 + f 0 'O(h3 ) dx x f y
2
h2
y1 = y0 + hy0 + y0 "O(h 3 ) (4)
2!
Comparing (3) and (4), it follows that this method agrees with the Taylor’s series solution upto
the term in h2 .
The Runge-Kutta method of the second order is same as modified Euler’s method.
1
y1 = y0 + ( k1 k 2 ) , where
2
ki = hf (x0,y0)
1
y1 = y0 + ( k 1 4 k 2 k 3 ) , where
6
k1 = hf(x0, y0)
1 1
k2 = hf(x0 + h, y 0 k 1 )
2 2
This method is most commonly used and working rule for finding the increment k of y
corresponding to an increment h of x by Runge-Kutta method for
65
dy
f ( x, y ), y ( x0 ) y0
dx
is as follows:
Calculate successively
k1 = hf(x0, y0)
1 1
k2 = hf(x0 + h, y 0 k 1 ) ,
2 2
1 1
k3 = hf(x0 + h, y 0 k 2 ) ,
2 2
1
Finally compute k= (k1 + 2k2+ 2k3+k4)
6
and y1 = y0 + k .
dy
Example: Given 1 y 2 , where y = 0 when x = 0, find y(0.2), y(0.4) and y(0.6) using
dx
Runge-Kutta method.
Solution:
k1= 0.2,
1
and y(0.2) = 0 + (k1+2k2+2k3+k4)
6
66
= 0.2027, which is correct to four decimal places.
To compute y (0.4), we take x0 = 0.2 y0 = 0.2027 and h = 0.2. With these values, we get
Finally, taking x0 = 0.4, y0 = 0.4228 and h = 0.2, and proceeding as above, we obtain y(0.6) =
0.6841.
In the methods described so far, to solve a differential equation over a single interval, say from x
= xn to x = xn+1, we require information only at the beginning of the interval, i.e., at x = xn.
Predictor-corrector methods are methods which require function values atxn, xn-1, xn-2,...... for the
computation of the function value at xn+1. A predictor formula is used to predict the value of y at
xn+1 and then a corrector formula is used to improve the value of yn+1.
1. Milne’s method
2. Adams-Bashforth method
3.9.1Milne’s method:
Given dy/dx = f(x,y) and y = y0, x = x0; to find an approximate value of y for x = x0 + nh by
Milne’s method, we proceed as follows:
The value y0 = y(x0) being given, we compute
67
y1 = y(x0+h), y2 = (x0+2h), y3 = y (x0+3h),
Next we calculate
f0 = f(x0, y0), f1 = f(x0 + h, y1), f2 = f(x0 + 2h, y2), f3 = f(x0 + 3h, y3)
n( n 1) 2 n(n 1)(n 2) 3
f(x, y) = f0 + nf0 + f0+ f0+.......
2 6
in the relation
x0 4 h
y4 = y0 + x0
f ( x, y )dx.
Therefore
x0 4 h n(n 1) 2
y4 = y0 + x0
f 0 nf 0
2
f 0 ..........dx
4 n(n 1) 2
= y0 + h f
0
0 nf 0
2
f 0 ..........dn
20 8
y4 = y0 +h 4 f 0 8f 0 2 f 0 3 f 0 ..........
3 3
Neglecting fourth and higher order differences and expressing f0, 2f0 and 3f0 in terms of the
function values, we get
4h
y4= y0 + ( 2 f1 f 2 2 f 3 )
3
68
f4 = f(x0 + 4h, y4).
h
y4 = y2 + ( f 2 4 f3 f 4 )
3
Then an improved value of f4 is computed and again the corrector is applied to find a still better
value of y4. We repeat this step until y4 remains unchanged.
Once y4 and f4 are obtained to desired degree of accuracy, y5 = y(x0 + 5h) is found from the
predictor as
4h
y5 = y1 + (2 f 2 4 f 3 2 f 4 )
3
and f5 = f(x0 + 5h, y5) is calculated. Then a better approximation to the value of y5 is obtained
from the corrector as
h
y5 = y3 + ( f3 4 f4 f5 ) .
3
We repeat this step till y5 becomes stationary and we, then proceed to calculate y6 as before.
Example: Using Runge-Kutta method of order 4, find y for x = 0.1, 0.2, 0.3 given that dy/dx = xy
+ y2, y(0) = 1. Find the solution at x = 0.4 using Milne’s method.
Solution:
69
1 1
k2 = h f(x0 + h ,y0+ k1 ) = (0.1) f(0.05,1.05) = 0.1155
2 2
1 1
k3 = h f(x0 + h ,y0+ k2 ) = (0.1) f(0.05,1.0577) = 0.1172
2 2
1
k= (k1 + 2k2 +2k3 + k4)
6
1
= (0.1 + 0.231 + 0.2343 + 0.1360) = 0.1169
6
1 1
k2 = h f(x1+ h , y1+ k1 ) = (0.1) f(0.15,1.1848) = 0.1581
2 2
1 1
k3 = h f(x1+ h , y1+ k2 ) = (0.1) f(0.15,1.1959) = 0.1609
2 2
1
k= (k1 + 2k2 +2k3 + k4) = 0.1605
6
1 1
k2 = h f(x2+ h , y2+ k1 ) = (0.1) f(0.25,1.3716) = 0.2224
2 2
70
1 1
k3 = h f(x2+ h , y2+ k2 ) = (0.1) f(0.25,1.3885) = 0.2275
2 2
1
k= (k1 + 2k2 +2k3 + k4) =0.2267
6
4h
y4 = y0 + ( 2 f1 f 2 2 f 3 ) .
3
h
y4 = y2 + ( f2 4 f3 f4 )
3
0 .1
y4 = 1.2773 + [1.8869 4( 2.7132 ) 4.098]
3
= 1.8386, f4 = 4.1159
0 .1
y4 = 1.2773 + [1.8869 4( 2.7132) 4.1159])
3
71
= 1.8391, f4 = 4.1182 (1)
0 .1
y4 = 1.2773 + [1.8869 4( 2.7132 ) 4.1182 ]
3
dy
Given f ( x, y ) and y0 = y(x0), we compute
dx
f-1=f(x0 – h, y-1), f-2 = f(x0 – 2h, y-2), f-3 =f(x0 – 3h, y-3).
n ( n 1) 2 n ( n 1)( n 2 ) 3
f(x, y) =f0+ n f o f0 f 0 ......
2 6
x0 h
in y1 = y0 + x0
f ( x, y )dx. (1)
x1 n(n 1) 2
y1 = y0 + x0
f 0 nf 0
2
f 0 ........dx.
1 n(n 1) 2
= y0 +h 0
f 0 nf 0
2
f 0 ........dn
1 5 3
= y0 +h f 0 f 0 2 f 0 2 f 0 ........
2 12 8
72
Neglecting fourth and higher order differences and expressing f0 , 2 f 0 and 3 f 0 in terms of
function values, we get
h
y1= y0 + (55 f 0 59 f 1 37 f 2 9 f 3 ) (2)
24
This is called Adams-Bashforth predictor formula. Having found y1, we find f1 = f(x0+h1, y1).
Then to find a better value of y1, we derive a corrector formula by substituting Newton’s
backward formula at f1 ,i.e.,
n( n 1) 2 n( n 1)( n 2) 3
f(x,y) = f1+n f 1 f1 f 1 ...... in (1).
2 6
x1 n(n 1) 2
y1 = y0 + x0
f1 nf1
2
f1 ........dx.
0 n(n 1) 2
= y0 +h 1
f1 nf1
2
f1 ........dn
1 1 1
or y1 = y0 +h f1 f1 2 f1 2 f1 ........
2 12 24
Neglecting fourth and higher order differences andexpressing f1 , 2 f1 and 3 f1 in terms of
function values, we obtain
h
y1= y0 + (9 f1 19 f 0 5 f 1 f 2 ) (3)
24
Then an improved value of f1 is calculated and again the corrector (3) is applied to find a still
better value y1. This step is repeated till y1 remains unchanged and then we proceed to calculate
y2 as above.
73
dy
Example:Given x 2 (1 y ) and y(1) = 1, y(1.1) = 1.233, y(1.2) = 1.548, y(1.3) = 1.979,
dx
evaluate y(1.4) by Adams-Bashforth method.
Solution:
h
y1= y0 + (55 f 0 59 f 1 37 f 2 9 f 3 )
24
h
y1 = y0 + (9 f1 19 f 0 5 f 1 f 2 )
24
0 .1
y1 = 1.979 + (9 7.004 19 5.035 5 3.669 2.702 )
24
= 2.575
74
3.10 CHECK YOUR PROGRESS
4. Given
dy y x
, with y(0) = 1,
dx y x
5. Apply Runge – Kutta method to find an approximate value of y for x = 0.2 in steps of
0.1, if
dy
x y 2 , where y(0) = 1.
dx
75
3.11 SUMMARY
Linear Equations: -In mathematics, a linear equation is an equation that may be put in the
form where are the variables, and are the coefficients, which are often real numbers. The
coefficients may be considered as parameters of the equation, and may be arbitrary
expressions, provided they do not contain any of the variables.
f( x, y, y', . . ., y(m) ) = 0
where x is the independent variable and y is a function of x. y', y'' . . . y(m) are
respectively, first, second and mth derivatives of y with respect to x.
Some definitions:
the highest derivative in the ode is called the order of the ode.
the degree of the highest order derivative in the ode is called the degree of the ode.
the differential equation is linear if no product of the dependent variable y(x) with itself
or with any one of its derivatives occur in the equation otherwise is non-linear.
3.12 KEYWORDS
1. Gaussian Elimination Method:- The process of row reduction makes use of elementary row
operations, and can be divided into two parts. The first part (sometimes called forward
elimination) reduces a given system to row echelon form, from which one can tell whether
there are no solutions, a unique solution, or infinitely many solutions. The second part
(sometimes called back substitution) continues to use row operations until the solution is
found; in other words, it puts the matrix into reduced row echelon form.
76
2. Gauss – Seidel Iteration Method:- Gauss–Seidel method. In numerical linear algebra,
the Gauss–Seidel method, also known as the Liebmann method or the method of
successive displacement, is an iterative method used to solve a linear system of equations.
3. Euler’s Method:- yn+1 = yn+ hf(xn,yn), where xn = x0 + nh.
4. Runge – KuttaMethod:-RungeKutta methods which do not require the calculations of
higher order derivatives and give greater accuracy. The Runge-Kutta formulae possess the
advantage of requiring only the function values at some selected points.
5. Taylor’s Series Method:-
( x x0 ) 2 ( x x0 ) 3
y = y0+(x-x0)(y)0+ (y)0 + (y)0 + ....
2! 3!
3x - y + z = 1
3x + 6y + 2z = 0
3x + 3y + 7z = 4
3. Find y(0.5) for y’=-2x-y, y(0)=-1, with step length 0.1,Euler’s method.
5. Find y(0.3) for y’=(x.y2+y), y(0)=1, with step length 0.1, Using R-K fourth order method.
77
3.14 ANSWER TO CHECK YOUR PROGRESS
(3) 1.1053425
(4) 1.0928
(5) 1.2736
(6) 0.4555
78
SUBJECT: Computer Oriented Numerical Methods
INTERPOLION
STRUCTURE
4.0 Objective
4.1 Introduction
4.2 Errors in Polynomial Interpolation
4.3 Finite Differences
4.4 Detection of Error by use of Difference Tables
4.5 Differences of a Polynomial
4.6 Newton’s Forward Interpolation Formula
4.7 Newton’s Backward Interpolation Formula
4.8 Check your progress
4.9 Summary
4.10 Keywords
4.11 Self-Assessment Test
78
4.0 OBJECTIVE
In this lesson, the objective is to introduce the concepts of finite differences, thereby, to derive
the interpolation formulae using the forward and backward difference operators and tables, for
the given equi-spaced set of tabular values.
4.1 INTRODUCTION
The problem of approximating a given function f(x) by polynomials P9x) is generally used for
the construction of the function f(x), when it is not given in the form and only the values of f(x)
are given at a set of distinct points. The deviation of f(x) from P(x), i.e., f(x) – P(x), x є [a, b], is
called the error of approximation.
Let y = f(x), x0≤ x ≤ xn, be a function, then corresponding to every value of x in the range x0≤
x≤ xn, there exists one or more values of y. If the function f(x) is single-valued and continuous
and that it is known explicitly, then the values of f(x) corresponding to certain given values of x,
say x0, x1…. xn can easily be computed and tabulated. Conversely, given a set of tabulated values
(x0, y0), (x1, y1), (x2, y2),......, (xn, yn) satisfying the relation y = f(x) where the explicit nature of
f(x) is not known, then it is required to find a function, say (x), such that f(x) and (x) agree at
the set of tabulated points. Such a process is called interpolation. If (x) is a polynomial, then the
process is called polynomial interpolation and (x) is called the interpolating polynomial.
Similarly, different types of interpolation arise depending on whether (x) is a finite
trigonometric series, series of Bessel functions, etc. But, we shall be concerned with polynomial
interpolation only.
The study of interpolation is based on the calculus of finite differences, which deals with the
changes that take place in the value of the function (dependent variable) due to finite changes in
the independent variable.
79
In this lesson, we derive two important interpolation formulae by means of forward and
backward differences of a function.
Let the function y = f(x) be defined by the (n+1) points (x i, yi), i = 0, 1, 2,….., n, and is
continuous and differentiable (n+1) times. Let y = f(x) be approximated by a polynomial n(x) of
degree not exceeding n such that
Now, if we use n(x) to obtain approximate values of f(x) at some points other than those defined
by (1), what would be the accuracy of this approximation? Since the expression f(x) - n(x)
vanishes for x = x0, x1,….. xn, so we consider
and L is to be determined such that equation (2) holds for any intermediate value of x, say x = x,
x0<x<xn. Clearly, we have
f ( x' ) n ( x' )
L= . ---(4)
n 1 ( x' )
We construct a function F(x) such that
where L is given by (4) above. From the definition of F(x), it is clear that
that is, F(x) vanishes at (n+2) points in the interval x0 ≤ x ≤ xn. Consequently, by the repeated
application of Rolle’s theorem F(x) must vanish (n+1) times, F(x) must vanish n times, etc., in
80
the interval x0 ≤x≤ xn. In particular, F(n+1)(x) must vanish once in the interval. Let this point be
given by x=, x0<< xn. Differentiating (5), (n +1) times with respect to x and put x = , we get
f ( n 1) ( )
L= ---(7)
(n 1)!
f ( n 1) ( )
f(x) - n(x) = n+1 (x). ---(8)
(n 1)!
n1( x)
f(x) - n(x) = f(n+1)(), x0<<xn, ---(9)
(n 1)!
which is the required expression for the error. It is extremely useful in theoretical work in
different branches of numerical analysis. In particular, we will use it to determine errors in
Newton’s interpolation formulae.
Suppose that the function y = f(x) be tabulated for equally spaced set of values say xi = x0 + ih, i
= 0, 1,2,….n, and we have a table of values (xi, yi), i = 0, 1,2,3…..n. Finding the values of f(x)
for some intermediate values of x, or the derivative of f(x) for some x in the range x0≤ x ≤ xn, is
based on the concept of the differences of a function. The following three types of differences
are found useful.
81
Forward Differences:
If y0, y1, y2, …, yn denote a set of values of y, then y1 – y0, y2 – y1,… , yn – yn-1 are called the
differences of y. These differences of y denoted by y0, y1,…, yn-1 respectively are called the
first forward differences, and we have
where is called the forward difference operator. The differences of the first forward differences
are called second forward differences and are denoted by 2y0, 2y1,….. Similarly, one can
define third forward differences, fourth forward differences etc. Thus, we have
= y3 - 3y2 + 3y1 – y0
And, in general
It is, therefore, clear that any higher order difference can easily be expressed in terms of the
ordinates, since the coefficients occurring on the right side are the binomial coefficients.
These differences are systematically set out as follows in what is called a forward difference
table.
82
Forward Difference Table
2 3
x y 4 5 6
x0 y0
y0
x1 y1 2y0
y1 3y0
x2 y2 2y1 4y0
x4 y4 2y3 4y2
y4 3y3
x5 y5 2y4
y5
x6 y6
Backward Differences:
The differences y1– y0, y2 – y1, .....,yn – yn-1 when denoted by y1, y2, …., yn
respectively, are called the first backward differences. So that y1 = y1 – y0, y2 = y2 –
y1,…..,yn = yn – yn-1, where is called the backward difference operator. One can define
backward differences of higher orders as
These differences are exhibited in the form of a backward difference table as given below
83
Backward Difference Table
x y 2 3 4 5 6
x0 y0
x1 y1 y1
x2 y2 y2 2y2
Central Differences:
x y 2 3 4 5 6
x0 y0
y1/2
x1 y1 2y1
84
y3/2 3y3/2
x2 y2 2y2 4y2
x4 y4 2y4 4y4
y9/2 3y9/2
x5 y5 2y5
y11/2
x6 y6
We see from this table that the central differences on the same horizontal line have the
same suffix. Also, the differences of odd order are know only for half values of the suffix and
those of even order for only integral values of the suffix.
Observation: It is noted that in all the three tables, the same numbers occur in the same position
and it is only the notation which changes, e.g.,
The operators , and have already been defined. Besides these, there are operators E and ,
which are defined as follows :
85
If yx is the function f(x), then
1
yx = (y h+y h )
2 x 2 x 2
Remark: In the difference calculus E is regarded as the fundamental operator and , , , can
be expressed in terms of E.
Proof:
This shows that the operators and E are connected by the symbolic relation
= E – 1 or E = 1 +
= (1 – E-1) yx
= 1 – E-1
(iii) yx = y h – y h
x x
2 2
86
= E1/2 – E-1/2
1
(iv) yx = (y h+y h )
2 x 2 x 2
1 1/2 1
= (E yx + E-1/2yx) = (E1/2 + E-1/2)yx
2 2
1 1/2
= (E + E-1/2)
2
= yx+h – yx = yx
E =
E =
E1/2yx = y h = y h h –y h h
x x x
2 2 2 2 2
= yx+h – yx = yx
E1/2 =
Hence = E = E = E1/2
h2 2
= f(x) + hDf(x) + D f(x) + ……
2!
87
h 2 D 2 h3 D 3
= 1 hD .......... .... f ( x )
2! 3!
= ehDf(x)
E = ehD
2 x Ee x
ex = e . 2 x ,
E e
Solution:
2 x
Since e = 2. E-1 ex = 2 ex-h
E
2 x Ee x Ee x
e . 2 x = e-h2ex . 2 x = e-hEex
E e e
88
=E+1=1++1
= 2 + .
ii. ½2 + 1 2 / 4
=E – 1 = .
= (E3 – 3E2 + 3E – 1) y2
3y2 = 3y5.
2 3
x x x 2
= u1 u1 u1 .......
1 x 1 x 1 x
89
u1 x u 2 x 2 u 3 x 3
(ii) u0 + ..........
1! 2! 3!
x2 2 x3 3
= e u 0 xu 0
x
u0 u 0 ........
2! 3!
Solution:
= x(1+xE + x2E2+…..)u1
1
=x. u1 , [taking sum of infinite G.P.]
1 xE
1
= x u1 [E= 1 + ]
1 x(1 )
1
1 x x
= x u1 1 u1
1 x x ) 1 x 1 x
x x x 2 2
= 1 ........ u1
1 x 1 x (1 x ) 2
x x2 x3
= u1 u 1 2 u1 .......... ..
1 x (1 x ) 3
2
(1 x )
= R.H.S.
x x2 2 x3 3
(ii) L.H.S. = u0 + Eu0 + E u0 + E u0+……….
1! 2! 3!
xE x 2 E 2 x 3 E 3
= 1 ........ u 0
1! 2! 3!
= exE u0 = ex(1+) u0
= ex. exu0
90
x x 2 2 x 3 3
= ex 1 ........ u 0
1! 2! 3!
x x2 2 x3
= ex u 0 u 0 u 0 3 u 0 ......
1! 2! 3!
= R.H.S.
Difference tables can be used to check errors in tabular values. Suppose there is an error of +1
unit in a certain tabular value. As higher differences are formed, this error spreads out and is
considerably magnified. It affects the difference table as shown below in the table.
Error Difference Table shows the following characteristics:
i. The effect of the error increases with the order of the differences.
ii. The errors in any one column are the binomial coefficients with alternating signs.
Table
y 2 3 4 5
0 0
0 0
0 0 0
0 0 1
0 0 1
91
0 1 -5
0 1 -4
1 -3 10
1 -2 6
-1 3 -10
0 1 -4
0 -1 5
0 0 1
0 0 -1
0 0 0
0 0
0 0
(iii) The algebraic sum of the errors in any difference column is zero, and
(iv) The maximum error occurs opposite the function value containing the error.
These facts can be used to detect errors by difference tables.
Example:
x y 2 3 4
1 3010
414
2 3424 -36
378 -39
92
3 3802 -75 +178
303 +139
367 -132
299 +49
280 +3
7 5051 -16
264
8 5315
The term – 271 in the fourth difference column has fluctuations of 449 and 452 on either side of
it. Comparison with the error difference table suggest that there is an error of -45 in the entry for
x = 4. The correct value of y is therefore 4105 + 45 = 4150, which shows that the last two digits
have been transposed, a very common form of error. The reader is advised to form a new
difference table with this correction, and to check that the third differences are now practically
constant.
If an error is present in a given data, the differences of some order will become alternating in
sign. Hence, higher order differences should be formed till the error is revealed as in the above
example. If there are errors in several tabular values, then it is not easy to detect the errors by
differencing.
The nth differences of a polynomial of the nth degree are constant and all higher order
differences are zero.
93
Let the polynomial of the nth degree in x, be
= f(x+h) - f(x)
The second differences represent a polynomial of degree (n – 2). Continuing this process,
for the nth differences we get a polynomial of degree zero, i.e.,
which is a constant. Hence the (n+1)th and higher differences of a polynomial of nth degree will
be zero.
Remark: The converse of this theorem is also true, i.e., if the nth differences of a function
tabulated at equally spaced intervals are constant, the function is a polynomial of degree n. This
fact is important in numerical analysis as it enables us to approximate a function by a polynomial
of nth degree, if its nth order differences become nearly constant.
Example: Evaluate
94
10[(1-ax)(1-bx2)(1-cx3)(1-dx4)]
Solution:
10[(1-ax)(1-bx2)(1-cx3)(1-dx4)]
Let the function y = f(x) take the values y0, y1, y2,…. corresponding to the values x0, x0+h,
x0+2h,…. of x. Suppose it is required to find f(x) for x = x0+ph, where p is any real
number.
Epf(x) = f(x+ph)
p( p 1) 2 p( p 1)( p 2) 3 …….
= 1 + p + + + y0,
2! 3!
p( p 1) 2 p( p 1)( p 2) 3
i.e., yp = y0 + py0 + y0 + y0 +….. ---(1)
2! 3!
If y = f(x) is a polynomial of the nth degree, then n+1y0 and higher differences will be zero.
Hence (1) will become
95
p( p 1) 2 p( p 1)( p 2) 3
yp = y0 + py0 + y0 + y0 +…..
2! 3!
p( p 1).....( p n 1) n
……+ y0 ---(2)
n!
Remark: This formula is used for interpolating the values of y near the beginning of a set of
tabulated values and extrapolating values of y a little backward (i.e. to the left) of y0.
Let the function y = f(x) take the values y0, y1, y2,…. corresponding to the values x0, x0+h,
x0+2h,…. of x. Suppose it is required to evaluate f(x) for x = xn+ph, where p is any real number.
Then we have
p ( p 1) 2 p( p 1)( p 2) 3 …….
= 1 + p + + + yn,
2! 3!
p ( p 1) 2 p( p 1)( p 2) 3
i.e., yp = yn + pyn + yn + yn+ ….. ---(1)
2! 3!
Remark: This formula is used for interpolating the values of y near the end of a set of tabulated
values and also for extrapolating values of y a little ahead (to the right) of yn.
Example: The table gives the distance in nautical miles of the visible horizon for the given
heights in feet above the earth’s surface:
96
y = distance: 10.63 13.03 15.04 16.81 18.42 19.90 21.27
Solution
x y 2 3 4
100 10.63
2.40
2.01 0.15
1.77 0.08
1.61 0.03
1.48 0.02
1.37
400 21.27
3 = 0.03 etc.
x x 0 18
Since x = 218 and h = 50, p = = 0.36
h 50
97
p( p 1) 2 p( p 1)( p 2) 3
y218 = y0 + py0 + y0 + y0
2! 3!
p( p 1)( p 2)( p 3) 4
+ y 0 +…..
4!
0.36(0.64)
f(218) = 15.04 + 0.36(1.77) + (-0.16)
2
0.36(0.64)(1.64) 0.36(0.64)(1.64)(2.64)
+ (0.03) (0.01)
6 24
(ii) Since x = 410 is near the end of the table, we use Newton’s backward interpolation
formula.
x x n 10
Taking xn = 400, p = = = 0.2
h 50
p ( p 1) 2 p ( p 1)( p 2) 3
y410 = y400 + py400 + y400 + y400 +
2! 3!
p( p 1)( p 2)( p 3) 4
+ y 400
4!
0.2(1.2)
= 21.27 + 0.2 (1.37) + (-0.11)
2!
0.2(1.2)(2.2) 0.2(1.2)(2.2)(3.2)
+ (0.02) (0.01)
3! 4!
Example: From the following table, estimate the number of students who obtained marks
between 40 and 45:
No. of student:31 42 51 35 31
Solution:
40 31
42
50 73 9
51 -25
60 124 -16 37
35 12
70 159 -4
31
80 190
We shall find y45, i.e., number of student with marks less than 45. Taking x 0 = 40, x = 45, we
have
99
x x0 5
p= = = 0.5 [ h = 10]
h 10
p( p 1) 2 p( p 1)( p 2) 3
y45 = y40 + p y40 + y40 + y40 +
2! 3!
p( p 1)( p 2)( p 3) 4
y40.
3!
0.5(0.5) 0.5(0.5)(1.5)
= 31 + 0.5 x 42 + x9+ x (-25)
2 6
0.5(0.5)(1.5)(2.5)
+ x 37
24
= 31+21+1.125-1.5625-1.4453
= 47.87
The number of students with marks less than 45 is 47.87, i.e., 48. But the number of students
with marks less than 40 is 31.
Example: Find the cubic polynomial which takes the following values :
x: 0 1 2 3
f (x) : 1 2 1 10
0 1
100
1
1 2 -2
-1 12
2 1 10
3 10
x0
We take x0= 0 and p = =x [ h = 1]
h
x x( x 1) 2 x( x 1)( x 2) 3
f(x) = f(0) + f(0) + f(0)+ f(0)
1 1.2 1.2.3
x( x 1) x( x 1)( x 2)
= 1 + x(1) + (-2) + (12)
2 6
x xn
To compute f(4), we take xn = 3, x = 4 so that p = =1
h
p ( p 1) 2 p( p 1)( p 2) 3
f(4) = f(3) + pf(3) + f(3) + f(3)
1 .2 1.2.3
= 10 + 9 +10 +12 = 41
Which is the same value as that obtained by substituting x = 4 in the cubic polynomial above.
101
4.8 CHECK YOUR PROGRESS
1. Show that
1 f ( x )
f ( x) f ( x) f ( x 1)
2. Evaluate
1 1
(i) 2 2 (ii) n
x 5x 6 x
3 With usual notations, show that
1
(i) (1 )(1 ) 1 (ii) ( )
2
(iii) r f k r f k r
4. Evaluate
4 (1 x)(1 2 x)(1 3 x)(1 4 x) , h=1
5. Estimate the value of f(22) and f(42)from the following data:
x: 20 25 30 35 40 45
f(x): 354 332 291 260 231 204
6. Find the number of men getting wages between Rs. 10 and 15 from the following data
Wages (Rs.): 0-10 10-20 20-30 30-40
Frequency: 9 30 35 42
7. Construct Newton’s forward interpolation polynomial for the following data:
x: 4 6 8 10
y: 1 3 8 16
102
4.9 SUMMARY
1. We start to learn about the error in polynomial interpolation and detection of that error by
using difference table.
2. This chapter tells us how to find value near the top and near the end of table.
3. We learn Newton’s forward and backward interpolation formula for detecting the value at
any intermediate level.
4.10 KEYWORDS
Polynomial interpolation is a method of estimating values between known data points. When
graphical data contains a gap, but data is available on either side of the gap or at a few specific
points within the gap, an estimate of values within the gap can be made by interpolation.
Newton’s Forward Interpolation Formula:-
p( p 1) 2 p( p 1)( p 2) 3
yp = y0 + py0 + y0 + y0 +…..
2! 3!
Newton’s Backward Interpolation Formula:-
p ( p 1) 2 p( p 1)( p 2) 3
yp = yn + pyn + yn + yn+ …..
2! 3!
103
4.11 SELF ASSESSMENT TEST
x: 0 1 2 3
f(x): 1 0 1 10
X= -1
3. In the table below the value of y are consecutive terms of a series of which the number
21.6 is the 6th term. Find the 1st and the 10th term of the series.
X: 3 4 5 6 7 8 9
Y: 2.7 6.4 12.5 21.6 34.3 51.2 72.9
4. Construct difference table for following data
X: 1 2 4 5 6 7 8
Y: 23 33 45 56 65 77 89
104
4.13 REFERENCES/ SUGGESTEDREADINGS
105
SUBJECT: Computer Oriented Numerical Methods
INTERPOLION-II
STRUCTURE
5.0 Objective
5.1 Introduction
5.2 Central Difference Interpolation Formulae
5.2.1 Gauss’s Forward Interpolation Formula
5.2.1 Gauss’s Backward Interpolation Formula
5.2.3 Stirling’s Formula
5.2.4 Bessel’s Formula
5.3 Interpolation with Unequal Intervals
5.3.1 Lagrange’s Interpolation Formula
5.4 Inverse Interpolation
5.4.1 Lagrange’s Method
5.4.2 Iterative Method
5.5 Check Your Progress
5.6 Summary
5.7 Keywords
5.8 Self Assessment Questions
5.9 Answer to Check Your Progress
5.10 References/ Suggested Readings
106
5.0 OBJECTIVE
The objective of this lesson is to continue with the objective of the previous lesson by deriving
some more interpolation formulae such as, central difference interpolation formulae, which are
based on central difference table and operators; Interpolation formulae for unequi-spaced set of
values and also the inverse interpolation.
5.1 INTRODUCTION
The Newton’s forward and backward interpolation formulae are applicable for interpolation near
the beginning and end of the tabulated values. Now we shall develop central difference formulae
which are best suited for interpolation near the middle of the table, for equi-spaced set of values.
All the interpolation formulae discussed, have the disadvantage of requiring the values of the
independent variable to be equally spaced, i.e., equi-spaced set of values. It is therefore desirable
to have interpolation formulae with unequally spaced values of the argument and therefore, we
discuss one such formula, Lagrange’s interpolation formula. Also, the inverse interpolation is
discussed, in which we can find the value of the argument for a given value of the function, from
the set of tabulated values.
If x takes the values x0 – 2h, x0 – h, x0, x0 + h, x0 +2h and the corresponding values of y = f(x)
are y–2, y-1, y0, y1, y2, then we can write the difference table in the two notations as follows :
107
x y 1st diff. 2nd diff. 3rd diff. 4th diff.
x0 – 2h y– 2
y-2 (=y–3/2)
x0 –h y–1 2y-2(=2y-1)
y-1(=y-1/2) 3y-2(=3y – ½)
x0 y0 2y-1(=2y0) 4y-2(=4y0)
y0(=y1/2) 3y-1(=3y1/2)
x0+h y1 2y0(=2y1)
y1(=y3/2)
x0 + 2h y2
108
p( p 1)( p 2) 3
+ ( y-1+4y-1)
1.2.3
p( p 1)( p 2)( p 3) 4
+ ( y-1 +5y-1) + …..
1.2.3.4
Hence
p( p 1) 2 ( p 1) p( p 1) 3
yp= yo+ py0 + y-1+ y-1
2! 3!
( p 1) p( p 1)( p 2) 4
+ y-2 +….., ---(6)
4!
which is known as Gauss’s forward interpolation formula.
In the central difference notations, this formula will be
p( p 1) 2 ( p 1) p( p 1) 3
yp= y0 + py1/2+ y0 + y1/2
2! 3!
( p 1) p( p 1)( p 2) 4
+ y0 +….. ---(7)
4!
Remark :This formula is used to interpolate the values of y for p (0<p<1) measured forwardly
from the origin.
109
p( p 1) 2
yp= y0 + p( y-1 +2y-1) + ( y-1 +3y-1)
1.2
p( p 1)( p 2) 3
+ ( y-1+4y-1)
1.2.3
p( p 1)( p 2)( p 3) 4
+ ( y-1 +5y-1) +..…
1.2.3.4
( p 1) p 2 ( p 1) p( p 1) 3
= y0+ py-1 + y-1+ y-1
1.2 1.2.3
( p 1) p( p 1)( p 2) 4
+ y-1
1.2.3.4
( p 1) p( p 2)( p 3) 5
+ y-1 +.....
1.2.3.4
( p 1) p 2 ( p 1) p( p 1) 3
= y0+ py-1 + y-1+ ( y-2+4y-2)
1.2 1.2.3
( p 1) p( p 1)( p 2) 4
+ ( y-2+5y-2)+.....
1.2.3.4
[Using (5) and (6)]
Hence
( p 1) p 2 ( p 1) p( p 1) 3
yp= y0+ py-1 + y-2+ y-2
2! 3!
( p 2)( p 1) p( p 1) 4
+ y-2 +……., ---(7)
4!
which is called Gauss’s backward interpolation formula.
In the central difference notations, this formula will be
( p 1) p 2 ( p 1) p( p 1) 3
yp= y0 + py-1/2+ y0 + y-1/2
2! 3!
( p 2)( p 1) p( p 1) 4
+ y0 +……. ---(8)
4!
Remark: It is used to interpolate the values of y for a negative value of p lying between –1 and
0.
Gauss’s forward and backward formulae are themselves not of much practical use. However,
these serve as intermediate steps for obtaining the following two important formulae:
110
5.2.3Sterling’s Formula:
Gauss’s forward interpolation formula is
p( p 1) 2 ( p 1) p( p 1) 3
yp= y0 + py0+ y-1 + y-1
2! 3!
( p 1) p( p 1)( p 2) 4
+ y-2 +……. ---(1)
4!
Gauss’s backward interpolation formula is
( p 1) p 2 ( p 1) p( p 1) 3
yp= y0 + py-1+ y-1 + y-2
2! 3!
( p 2)( p 1) p( p 1) 4
+ y-2 +……. ---(2)
4!
Taking the mean of (1) and (2), we obtain
y0 y1 p 2 2 p ( p 2 1) 3 y 1 3 y 2
yp=y0 +p + y-1 +
2 2! 3! 2
p 2 ( p 2 1) 4
+ y -2 +…… ---(3)
4!
which is called Stirling’s formula
In the central difference notations, (3) takes the form
p2 2 2 2
yp= y0 + py0+ y0 + p ( p 1 ) 3y0
2! 3!
2 2 2
+ p ( p 1 ) 4y0 +…… , ---(4)
4!
1 1
since (y0 +y-1) = (y1/2 +y-1/2) = y0,
2 2
1 3 1
( y-1 +3y-2) = (3y1/2 +3y-1/2) = 3y0 etc.
2 2
Remark: This formula involves means of the odd differences just above and below the central
line and even differences on this line as shown below :
y 3 y 2 5 y 3 6
……y0….. 1 …..2y-1….. 3 .....4 y 2 ...... ... y 3 ...... central line
5 y
y 0 y 1 2
111
5.2.4 Bessel’s Formula:
Guass’s forward interpolation formula is
p( p 1) 2 ( p 1) p( p 1) 3
yp= y0 + py0+ y-1 + y-1
2! 3!
( p 1) p( p 1)( p 2) 4
+ y-2 +…… ---(1)
4!
We have 2y0 - 2y-1 = 3y– 1 ,
i.e. 2y–1 = 2y0 - 3y-1 ---(2)
Similarly, 4y–2 = 4y–1 - 5y– 2, etc. ---(3)
Now (1) can be written as
p( p 1) 1 2 1 2 p( p 2 1) 3
yp= y0 + py0+ y1 y1 + y-1
2! 2 2 3!
p ( p 2 1)( p 2) 1 4 1 4
+ y 2 y 2 +……
4! 2 2
1 p ( p 1) 2 1 p ( p 1) 2
= y0 + py0 + y-1 + ( y0 - 3y-1)
2 2! 2 2!
p ( p 2 1) 3 1 p( p 2 1)( p 2) 4
+ y-1 + y-2
3! 2 4!
1 p( p 2 1)( p 2)
+ (4y-1 - 5y-2) + …..
2 4!
[using (2), (3) etc.]
p( p 1) 2 y1 2 y0 p( p 1) p 1 1 3
= y0 + py0 + . + y-1
2! 2 2! 3 2
p ( p 2 1)( p 2) 4 y 2 4 y1
+ . + ……
4! 2
Hence
1
p( p 1) 2 y1 2 y0 ( p 2 ) p( p 1) 3
yp = y0 + py0 + . + y-1
2! 2 3!
( p 1) p( p 1)( p 2) 4 y 2 4 y1
+ . + ....., ---(4)
4! 2
which is known as the Bessel’s formula.
112
In the central difference notations, (4) becomes
1
p( p 1) 2 ( p ) p( p 1)
yp = y0 + py1/2+ y1/2+ 2 3y1/2
2! 3!
( p 1) p( p 1)( p 2) 4
+ y1/2+....., ---(5)
4!
1 2 1
since ( y1 2 y0 ) 2y1/2 , (4 y 2 4 y1 ) 4y1/2, etc.
2 2
Remark: This is a very useful formula for practical purposes. It involves odd differences below
the central line and means of even differences of and below his line.
Example: Employ Stirling’s formula to compute y12.2 from the following table (yx = 1+ log10 sin
x) :
x°: 10 11 12 13 14
105ux: 23,967 28,060 31,788 35,209 38,368
Solution:
Taking the origin at x = 12°, h = 1 and p = x – 12 , we have the following central table :
113
p yx yx 2yx 3yx 4yx
-2 0.23967
0.04093
-1 0.28060 -0.00365
0.03728 .00058
0 0.31788 -0.00307 -0.00013
0.03421 -0.00045
1 0.35209 -0.00062
0.03159
2 0.38368
1 1
At x = 12.2, p = 0.2. (As p lies between – and , the use of Stirling’s formula will be quite
4 4
suitable.)
Stirling’s formula is
p y 1 y 0 p 2 2 p ( p 2 1) 3 y 2 3 y1
yp= y0 + . + y-1 +
1 2 2! 3! 2
p 2 ( p 2 1) 4
+ y-2 + ......
4!
When p = 0.2, we have
2
0.03728 0.03421 (0.2)
y0.2 = 0.31788 + 0.2 (-0.00307)
2 2
2 2
(0.2)[(0.2) 2 1] 0.00058 0.00045 (0.2) [(0.2) 1]
+ (- 0.00013)
6 2 24
= 0.31788+0.00715-0.00006-0.000002+0.0000002
= 0.32497.
Example: Apply Bessel’s formula to obtain y25, given y20 = 2854, y24 = 3162, y28 = 3544, y32 =
3992.
Solution:
1
Taking the origin at x0 = 24, h = 4, we have p = (x-24).
4
The central difference table is
114
p y y 2 y 3 y
-1 2854
308
0 3162 74
382 -8
1 3544 66
448
2 3992
At x = 25, p =(25-24)/4 = ¼ . (As p lies between ¼ and ¾, the use of Bessel’s formula will yield
accurate result.)
Bessel’s formula is
1
( p ) p( p 1)
p( p 1) 2 y1 2 y0 2
yp = y0 + py0+ . + 3y-1 +......
2! 2 3!
---(1)
When p = 0.25, we have
0.25(0.75) 74 66
yp = 3162 + 0.25 x 382 +
2 2
(0.25)(0.25)(0.75)
+ (-8)
6
= 3162 + 95.5 – 6.5625 – 0.0625 = 3250.875 approx.
The various interpolation formulae derived so far being applicable only to equally spaced values
of the argument. It is, therefore, desirable to develop interpolation formulae for unequally spaced
values of x. Lagrange’s interpolation formula is one such formula and is as follows:
115
( x x1 )( x x2 ).....(x xn ) ( x x0 )( x x2 ).....(x xn )
f(x) = y0 + y1
( x0 x1 )( x0 x2 )....(x0 xn ) ( x1 x0 )( x1 x2 )....(x1 xn )
116
(9 5)(9 7)(9 13)(9 17) (9 5)(9 7)(9 11)(9 17)
+ 1452 + 2366
(11 5)(11 7)(11 13)(11 17) (13 5)(13 7)(13 11)(13 17)
(9 5)(9 7)(9 11)(9 13)
+ 5202
(17 5)(17 7)(17 11)(17 13)
50 3136 3872 2366 578
=- 810
3 15 3 3 5
So far, we have been finding the value of y corresponding to a certain value of x from a given set
of values of x and y. On the other hand, the process of finding the value of x for a value of y is
called the inverse interpolation. When the values of x are unequally spaced, Lagrange’s method
is used and when the values of x are equally spaced, the Iterative method should be used.
( y y0 )( y y1 ).......( y yn 1 )
+ .......... xn ,
( yn y0 )( yn y1 ).......( yn yn 1 )
which is used for inverse interpolation.
Example: The following table gives the values of x and y :
x: 1.2 2.1 2.8 4.1 4.9 6.2
y: 4.2 6.8 9.8 13.4 15.5 19.6
Find the value of x corresponding to y = 12, using Lagrange’s technique.
Solution:
117
Here x0 = 1.2, x1 = 2.1, x2 = 2.8, x3 = 4.1 x4 = 4.9, x5 = 6.2
and y0 = 4.2, y1 = 6.8, y2 = 9.8, y3 = 13.4, y4 = 15.5, y5 = 19.6
Taking y = 12, the above formula gives
(12 6.8)(12 9.8)(12 13.4)(12 15.5)(12 19.6)
x= 1.2
(4.2 6.8)(4.2 9.8)(4.2 13.4)(4.2 15.5)(4.2 19.6)
(12 4.2)(12 9.8)(12 13.4)(12 15.5)(12 19.6)
+ 2.1
(6.8 4.2)(6.8 9.8)(6.8 13.4)(6.8 15.5)(6.8 19.6)
(12 4.2)(12 6.8)(12 13.4)(12 15.5)(12 19.6)
+ 2.8
(9.8 4.2)(9.8 6.8)(9.8 13.4)(9.8 15.5)(9.8 19.6)
(12 4.2)(12 6.8)(12 9.8)(12 15.5)(12 19.6)
+ 4.1
(13.4 4.2)(13.4 6.8)(13.4 9.8)(13.4 15.5)(13.4 19.6)
(12 4.2)(12 6.8)(12 9.8)(12 13.4)(12 19.6)
+ 4.9
(15.5 4.2)(15.5 6.8)(15.5 9.8)(15.5 13.4)(15.5 19.6)
(12 4.2)(12 6.8)(12 9.8)(12 13.4)(12 15.5)
+ 6.2
(19.6 4.2)(19.6 6.8)(19.6 9.8)(19.6 13.4)(19.6 15.5)
= 0.022-0.234+1.252+3.419-0.964+0.055
= 3.55.
118
1 p ( p 1) 2
p2 = [yp – y0 - 1 1 y0] ---(3)
y0 2!
To find the third approximation, retaining the term with third differences in (1) and replacing
every p by p2, we have
1 p ( p 1) 2 p ( p 1)( p2 2) 3
p3 = [yp – y0 - 2 2 y0- 2 2 y0],
y0 2! 3!
and so on. This process is continued till two successive approximations of p agree with each
other, to the desired accuracy.
Remark: This technique can equally well be applied by starting with any other interpolation
formula.
Example: The following values of y = f(x) are given
x: 10 15 20
y: 1754 2648 3564
Solution:
x y y 2 y
10 1754
894
15 2648 22
916
20 3564
1
p1 = 3000 1754 1.39
894
119
1 1.39(1.39 1)
p2 = 3000 1754 22 1.387 ,
894 2
1 1.387(1.387 1)
p3 = 3000 1754 22 ,
894 2
= 1.3871
= 10 + 1.387 x 5 =16.935.
Example: Using inverse interpolation, find the real root of the equation x3+ x –3= 0, witch is
close to 1.2.
Solution:
The difference table is
x v y(=x3 + x-3) y 2 y 3 y 4 y
1 -0.2 -1
0.431
1.1 -0.1 -0.569 0.066
0.497 0.006
1.2 0.0 -0.072 0.072 -0.00013
0.569 -0.006
1.3 0.1 0.497 0.078
0.647
1.4 0.2 1.144
Clearly the root of the given equation lies between 1.2 and 1.3.
Assuming the origin at x =1.2 and using Stirling’s formula.
y = yo+ x
y o y 1 x 2 2
y 1
x( x 2 1) 3 y 1 3 y 2,
2 2 6 2
we get
120
0.569 0.467 x 2
0 = -0.072 + x 0.072
2 2
.
x x 2 1 0.006 0.006
[y = 0]
6 2
or 0 = -0.072 + 0.532x+0.036x2 + 0.001x3
This equation can be written as
0.072 0.036 2 0.001 3
x x x …..(i)
0.532 0.532 0.532
0.072
First approximation x(1) = 0.1353
0.532
Putting x = x(1) on R.H.S. of (i), we get second approximation x(2) as
x(2) = 0.1353-0.067(0.1353)2-1.8797(0.1353)3
= 0.134
Hence the desired root = 1.2 +0.1 x 0.134 = 1.2134
121
5. The equation x3 – 15x + 4 = 0 has a root close to 0.3, obtain this root upto 4 decimal
places using inverse interpolation.
5.6 SUMMARY
1. In this chapter we learn to find the value which lies near the center of table.
2. We learn about the center difference interpolation method. For this we use gauss’s forward
and gauss’s backward interpolation formulas.
3. We learn to solve problem having unequal interval. For this purpose we use Lagrange’s
Interpolation Formula.
5.7 KEYWORDS
y0 y1 p 2 2 p ( p 2 1) 3 y 1 3 y 2
yp=y0 +p + y-1 +
2 2! 3! 2
p 2 ( p 2 1) 4
+ y -2 +……
4!
122
Bessel’s formula:-
1
p( p 1) 2 y1 2 y0 ( p 2 ) p ( p 1) 3
yp = y0 + py0 + . + y-1
2! 2 3!
( p 1) p( p 1)( p 2) 4 y 2 4 y1
+ . + .....,
4! 2
Lagrange’s Interpolation Formula:-
( x x1 )( x x 2 ).....( x x n ) ( x x0 )( x x 2 ).....( x x n )
f(x) = y0 + y1
( x0 x1 )( x0 x 2 )....( x0 x n ) ( x1 x0 )( x1 x 2 )....( x1 x n )
( x x 0 )( x x1 ).....( x x n 1 ) _
+…...+ yn
( x n x 0 )( x n x1 )....( x n x n 1 )
This is known as Lagrange’s interpolation formula for unequal intervals.
X 21 25 29 33 37
Y 18.4708 17.8144 17.1070 16.3432 15.5154
4. Using gauss backward interpolation formula, find f(1966)
123
5. Using gauss backward interpolation formula, find f(1974)
X 20 24 28 32
Y 2854 3162 3544 3992
7. Using Bessel’s interpolation formula, find f(25)
X 20 24 28 32
Y 24 32 35 40
(1) 0.934
(2) 32.945
(3) 14.63
(4) 2.3
(5) 0.2679
124
SUBJECT: Computer Oriented Numerical Methods
STRUCTURE
6.0 Objective
6.1 Introduction
6.2 Numerical Differentiation
6.2.1 Derivatives using Forward Difference Formula
6.2.2 Derivatives using Backward Differences Formula
6.2.3 Derivatives using Central Differences Formulae
6.3 Maxima and Minima of a Tabulated Function
6.4 Numerical Integration
6.4.1 Trapezoidal Rule
6.4.2 Simpson’s one-third Rule
6.4.3 Simpson’s three-eighth Rule
6.5 Errors in Quadrature Formulae
6.6 Check Your Progress
6.7 Summary
6.8 Keywords
6.9 Self Assessment Questions
6.10 Answer to Check Your Progress
6.11 References/ SuggestedReading
125
6.0 OBJECTIVE
Objective of this lesson is to develop numerical techniques for finding the differentiation and
integration of the functions, which are given in the tabulated forms, using the interpolation
formulae. In the end, the errors in numerical integration formulae are also obtained.
6.1 INTRODUCTION
If a function y = f(x) be defined at a set of n+1 distinct points x0, x1,…..,xn-1,xn lying in some
interval [a, b] such that a = x0<x1<x2<…..<xn = b. From the given tabulated data (set of values of
x and y), we require to find differentiation of different orders at tabular or non tabular points.
b
Also, we require to find the values of the definite integral f ( x)dx , where f(x) is either given
a
It is the process of calculating the value of the derivative of a function at some assigned value of
x from the given set of values (xi, yi). To compute dy/dx, we first replace the exact relation y=
f(x) by the best interpolating polynomial y = (x) and then differentiate the latter as many times
as we desire. The choice of the interpolation formula to be used, will depend on the assigned
value of x at which dy/dx is desired.
If the values of x are equi-spaced and dy/dx is required near the beginning of the table, we
employ Newton’s forward formula. If it is required near the end of the table, we use Newton’s
backward formula. For values near the middle of the table, dy/dx is calculated by means of
Stirling’s or Bessel’s formula.
126
If the values of x are not equi-spaced, we use Newton’s divided difference formula to represent
the function.
Hence corresponding to each of the interpolation formulae, we can derive a formula for finding
the derivative.
Consider the function y = f(x) which is tabulated for the values xi (= x0 + ih), i= 0, 1,2, ....n.
p( p 1) 2 p( p 1)( p 2) 3
y y 0 py 0 y0 y 0 ...... ---(1)
2! 3!
dy 2p 1 2 3p2 6 p 2 3
y 0 y0 y 0 ......
dp 2! 3!
( x x0 ) dp 1
Since p = , therefore .
h dx h
Now
dy dy dp 1 2 p 1 2 3p2 6 p 2 3
. yo y0 y0
dx dp dx h 2! 3!
4 p 3 18 p 2 22 p 6 4
y0 ..... ---(2)
4!
dy 1 1 2 1 3 1 4
y o y 0 y 0 y 0 ......... ---(3)
dx x0 h 2 3 4
127
d 2 y d dy dp
dx 2 dp dp dx
1 2 2 6p 6 3 12 p 2 36 p 22 4 1
y0 y0 y 0 ....
h 2! 3! 4! h
Putting p = 0, we obtain
d2y 1 2 11 4
2 2 y 0 y 0 12 y 0 .....
3
---(4)
dx x0 h
P( p 1) 2 P( P 1)( p 2) 3
y = yn + py n yn y n ......
2! 3!
dy 2 p 1 2 3p2 6 p 2 3
y n yn y n .......
dx 2! 3!
x xn dp 1
Since p , therefore
h dx h
Now dy dy . dp
dx dp dx
2 p 1 2 3p3 6 p 2 2
= 1 y n yn y n ...... ---(5)
h 2! 3!
dy 1 1 2 1 3 1 4
y n y n y n y n .......... ---(6)
dx xn h 2 3 4
128
d 2 y d dy dp
dx 2 dp dx dx
1 2 6P 6 3 6 p 2 18 p 11 4
y n y n y n ....
h 3! 12
Putting p = 0, we obtain
d2y
2 = 2 2 y n 3 y n 4 y n ....
1 11
---(7)
dx xn h 12
Stirling’s formula is
p y 0 y 1 p 2 2
yP= y0+ y 1
1! 2 2!
3 y 1 3 y 2 p 2 ( p 2 12 ) 4
+ p( p 1 )
2 2
y 2 .... ---(8)
3! 2 4!
dy y 0 y 1 2 p 2 3 p 2 1 3 y 1 3 y 2 4 p3 2p 4
+ y 1 + y 2 .....
dx 2 2! 3! 2
4!
x x0 dp 1
Since p = , .
h dx h
Now
dy dy dp
.
dx dp dx
1 y 0 y 1 3 p 2 1 3 y 1 3 y 2 2p3 p 4
= +p 2
y + y .....
-1
2
h 2 6 2 12
129
dy = 1 y 0 y 1 1 y 1 y 2 1 y 2 y 3
3 3 5 5
........ --(9)
dx x0 h 2 6 2 30 2
d2y 1 2 1 4 1 6
similarly 2 2 y 1 12 y 2 90 y 3 ..... ---(10)
dx x0 h
Similarly, we can use any other interpolation formula for computing the derivatives.
dy d2y
Find and at (a ) x 1.1 (b) x = 1.6
dx dx 2
Solution:
x y 23 4 5 6
1.0 7.989
0.414
0.378 0.006
130
0.299 0.005
0.281
1.6 10.031
dy 1 1 2 1 3 1 4 1 5 1 6
y0 y0 y0 y0 y0 y0 ........ --(i)
dx x0 h 2 3 4 5 6
d2y 1 11 5 137 6
and 2 2 2 y0 3 y0 4 y0 5 y0 y0 ....... ---(ii)
dx x0 h 12 6 180
dy 1 1 1 1 1 1
0.378 (0.03) (0.004) (0) (0.001) (0.003)
dx 1.1 0.1 2 3 4 5 6
= 3.946
d2y 1 11 5 137
2 0.03 (0.004) 12 (0) 6 (0.001) 180 (0.003)
2
dx 1.1 (0.1)
= -3.545
b) For x = 1.6, we use the above difference table and the backward difference operator
instead of , and we take
dy 1 1 2 1 3 1 4 1 5 1 6
yn 2 yn 3 yn 4 yn 5 yn 6 yn ...... ---(iii)
dx xn h
and
131
d2y 1 11 5 137 6
2 2 2 yn 3 yn 4 yn 5 yn yn ...... ---(iv)
dx xn h 12 6 180
dy 1 1 1 1 1 1
0.281 ( 0.018) (0.005) ( 0.001) ( 0.001) (0.003)
dx 1.6 0.1 2 3 4 5 6
= 2.727
d2y 1 11 5 137
2 0.018 0.005 12 (0.001) 6 (0.001) 180 (0.003)
2
dx 1.6 (0.1)
= -1.703
dx d 2 x
Example: From the following table find & at t = 0.3
dt dt 2
Solution :
t x 2 3 4 5 6
0 30.13
1.49
1.25 -0.24
132
0.77 0.02 -0.27
-0.14 0.02
-0.57
0.6 33.24
As the derivatives are required near the middle of the table, we use Stirling’s formulae:
d 2x 1 2 1 4 1 6
2 2 x1 12 x 2 90 x 3 ..... ---(ii)
dt t 0 h
Here h = 0.1, t0 = 0.3, x0 = 0.31, x-1 = 0.77, 2x-1= -0.46 etc.
= 5.33
d 2x 1 1 1
2 0.46 12 (0.01) 90 (0.29) .... = -45.6
2
dt 0.3 (0.1)
133
6.3 MAXIMA AND MINIMA OF A TABULATED FUNCTIO N
p( p 1) 2 p( p 1)( p 2) 3
y y o py o yo y o ......
2! 3!
dy 2p 1 2 3p2 6 p 2 3
y o yo y o ...... ---(1)
dp 2 2
For maxima or minima, dy/dp = 0. Hence equating the right hand side of (1) to zero and retaining
only upto third differences, we obtain
2p 1 2 (3 p 2 6 p 2) 3
y o yo yo 0 ,
2! 6
Substituting the values of y0, 2y0, 3y0 from the difference table, we solve this quadratic for p.
Then the corresponding values of x are given by x = x0 + ph at which y is maximum or
minimum.
Example: From the table given below, find the value of x for which y is minimum. Also find
this value of y.
x: 3 4 5 6 7 8
Solution:
134
x y 2 3
3 0.205
0.035
4 0.240 -0.016
0.019 0.000
5 0.259 -0.016
0.003 0.001
6 0.262 -0.015
-0.012 0.001
7 0.250 -0.014
-0.026
8 0.224
Taking x0 = 3, we have y0 = 0.205, y0 = 0.035, 2y0 = -0.016 and 3y0 =0.
p ( p 1)
y = 0.205 + p(0.035) + (-0.016) ---(i)
2!
dy 2 p 1
= 0.035 + (-0.016)
dp 2!
135
0.035 – 0.008 (2p – 1) = 0
x = x0 + ph = 3 +2.6875 x 1 = 5.6875.
= 0.2628.
The process of evaluating 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 a single variable, is
known as quadrature.
b
Let I = f ( x)dx ,
a
where f(x) takes the values yo, y1, y2, …..,yn for x = x0, x1, x2,….,xn.
Fig – 5.1
136
Let us divide the interval (a,b) into n sub- intervals of width h so that x0 = a, x1= x0+h, x2 = x0 +
2h, ……,xn = x0+nh = b. Then
x0 nh
I = x0
f ( x)dx [Put x = x0 +rh, dx = hdr]
n
= h f ( x0 rh)dr
0
n r (r 1) 2 r (r 1)( r 2) 3
= h yo ry0 y0 y0 ...dr
0
2! 3!
n 4 3n3 11n 2 4 y0
3n ....... ---(1)
5 2 3 24
This is known as Newton-Cotes quadrature formula. From this general formula, we deduce the
following important quadrature rules by taking n = 1, 2, 3,…..
Putting n = 1 in (1) and taking the curve through (x0, y0) and (x1,y1) as a straight line, i.e., a
polynomial of first order so that differences of order higher than first become zero, we get
x0 h 1 h
x0
f ( x)dx = h y0 y0 ( y0 y1 )
2 2
Similarly
x0 2 h 1 h
x0 h
f ( x)dx = h y1 y1 ( y1 y 2 )
2 2
………………………………………
137
h
yn1 yn
x0 nh
x0 ( n 1) h
f ( x)dx =
2
h
y 0 y n 2( y1 y 2 .... y n1 )
x0 nh
x0
f ( x)dx =
2
---(2)
In this rule, the area of each strip (trapezium) is found separately. Then the area under the curve
and the ordinates at x0 and x0 +nhis approximately equal to the sum of the areas of the n
trapeziums.
Putting n = 2 in (1) above and taking the curve through (x0, y0), (x1, y1) and (x2, y2) as a parabola,
i.e., a polynomial of second order so that differences of order higher than second vanish, we get
x0 2 h 1 h
x0
f ( x)dx = 2h y0 y0 2 y0 ( y0 4 y1 y 2 )
6 3
Similarly
h
y 2 4 y3 y 4
x0 4 h
x0 2 h
f ( x)dx =
3
………………………………
h
yn2 4 yn1 yn , n being even.
x0 nh
x0 ( n 2 ) h
f ( x)dx =
3
h
y0 y n 4( y1 y3 .... y n1 ) 2( y 2 y 4 ..... y n2 )
x0 nh
x0
f ( x)dx =
3
---(3)
138
This is known as the Simpson’s one-third rule or simply Simpson’s rule and is most commonly
used.
Remark : While applying (3), the given interval must be divided into even number of equal sub-
intervals, since we find the area of two strips at a time.
Putting n = 3 in (1) above and taking the curve through (xi, yi): i = 0, 1, 2, 3, as a polynomial of
third order so that differences above the third order vanish, we get
x 0 3h 3 3 1
x0
f ( x)dx = 3h y0 y0 2 y0 2 y0
2 2 8
3h
= ( y0 3 y1 3 y2 y3 )
8
Similarly,
x0 5 h 3h
x0 3 h
f ( x)dx =
8
( y3 3 y 4 3 y5 y6 ) and so on.
3h
y 0 y n 3( y1 y 2 y 4 y 5 .. y n1 ) 2( y 3 y 6 .. y n3 ) ,
x0 nh
x0
f ( x)dx =
8
---(4)
6 dx
Example: Evaluate 0 1 x2
by using (i) Trapezoidal rule, (ii) Simplson’s 1/3 rule, (iii)
Simpson’s 3/8 rule, and compare the results with its actual value.
Solution:
139
1
Divide the interval (0,6) into six parts each of width h = 1. The values of f(x) = are given
1 x2
below
x 0 1 2 3 4 5 6
y y0 y1 y2 y3 y4 y5 y6
6 dx h
0 1 x 2
= [( y0 y6 ) +2(y1+y2+y3+y4+y5)]
2
1
= [(1 0.027) 2(0.5 0.2 0.1 0.0588 0.0385)]
2
= 1.4108
6 dx h
1 x
0 2
=
3
[( y0 y6 ) +4(y1+y3+y5)+2(y2+y4)]
1
= [(1 0.027) +4(0.5+0.1+0.0385)+2(0.2+0.0588)]
3
= 1.3662.
6 dx 3h
1 x
0 2
=
8
[( y0 y6 ) +3(y1+y2+y4+y5)+2y3)]
3
= [(1 0.027) +3(0.5+0.2+0.0588+0.0385)+2(0.1)]
8
140
= 1.3571
6 dx
1 x
6
Also 2
= tan 1 x tan 1 6 1.4056
0 0
This shows that the value of the integral found by Simpson’s 1/3 rule is the nearest to the actual
value.
Example: The velocity v(km/min) of a moped which starts from rest, is given at fixed intervals
of time t (min) as follows :
t: 2 4 6 8 10 12 14 16 18 20
v: 10 18 25 29 32 20 11 5 2 0
Solution:
ds
v
dt
20 h
s t 0 vdt [ X 4.O 2.E ].
20
(By Simpson’s rule)
0 3
X = v0 + v10 = 0 + 0 = 0
E = v2 + v4 + v6 + v8 = 18 + 29 + 20+ 5 = 72
2
= s t 0 (0 4 80 2 72) 309.33 km.
20
141
Example:A solid of revolution is formed by rotating about the x-axis, the area between the x-
axis, the lines x = 0 and x = 1 and a curve through the points with the following co-ordinates.
Solution:
1 h
y dx . [( y 0 y 4 ) 4( y1 y3 ) 2 y 2 ]
2 2 2 2 2 2
=
0 3
0.25
= [{1 (0.8415) 2 } 4{( 0.9896) 2 (0.9089) 2 } 2(0.9589) 2 ]
3
0.25 3.1416
= [1.7081 7.2216 1.839]
3
= 0.2618(10.7687) = 2.8192.
Example: Evaluate
1 1
I = dx , correct to three decimal places.
0 1 x
Solution:
We solve this example by both the trapezoidal and Simpson’s rules with h = 0.5, 0.25 and 0.125
respectively.
142
1
(i) h = 0.5. The values of x and y are tabulated below
1 x
x: 0 0.5 1.0
1
I= [1.0000 2(0.6667) 0.5]
4
= 0.7084
1
I= [1.0000 4(0.6667) 0.5]
6
= 0.6945
1
(ii) h = 0.25. The tabulated values of x and y are given below
1 x
1
I= [1.0 2(0.8000 0.6667 0.5714) 0.5]
8
= 0.6970
1
I= [1.0 4(0.8000 0.5714) 2(0.6667) 0.5]
12
= 0.6932
143
(iii) Finally, we take h = 0.125. The tabulated values of x and y are
1
I= [1.0 2(0.8889 0.8000 0.7273 0.6667
16
= 0.6941
1
I= [1.0 4(0.8889 0.7273 0.6154 0.5333)
24
= 0.6932
Hence the value of I may be taken to be equal to 0.693, correct to three decimal places. The exact
value of Iis loge2, which is equal to 0.693147…. This example demonstrates that, in general,
Simpson’s rule yields more accurate results than the trapezoidal rule.
where P(x) is the polynomial representing the function y = f(x), in the interval [a, b].
144
1) Error in the Trapezoidal rule
Expanding y = f(x) around x = x0 by Taylor’s series, we get
( x x0 ) 2
y y 0 ( x x 0 ) y 0 ' y 0 "..... ---(1)
2!
x0 h x0 h ( x x0 ) 2
x0
ydx
x0
[ y0 ( x x0 ) y0 '
2!
y0 "......]dx
h2 h3
= y0 h y0 ' y0 "..... ---(2)
2! 3!
1
h( y0 y1 ) ---(3)
2
h2
y1 y 0 hy 0 ' y 0 ".....
2!
1 h2
A1 h y0 y0 hy0 ' y0 ".....
2 2!
h2 h3
= hy 0 y 0 ' y 0 "..... ---(4)
2 2.2!
x1
= x0
ydx A1
1 1 3 h3
= h y0 "... y0 "..... ,
3! 2.2! 12
145
h3
i.e., Principal part of the error in [x0, x1] = - y0 "
12
h3
Similarly principal part of the error in [x1, x2]= - y1 " and so on.
12
h3
Hence the total error E = - [y0+ y1+……+yn-1]
12
Assuming that y (X) is the largest of the n quantities y0y1,..., yn-1, we obtain
nh 3 (b a)h 2
E y" ( X ) y" ( X ) , [ nh b a ] --- (5)
12 12
x2 x0 2 h ( x x0 ) 2
x0
ydx
x0
0
( y ( x x 0 ) y 0 '
2!
y0 "...... dx
4h 2 8h 3 16h 4 32h 5 iv
= 2hy0 y0 ' y0 " y0 "' y0 ...... --- (6)
2! 3! 4! 5!
Also A1 = area over the first double strip by Simpson’s 1/3 rule
1
= h( y0 4 y1 y2 ) --- (7)
3
h2 h3
y1= y0 + hy0 + y 0 ' ' y0 ' ' '...........
2! 3!
146
4h 2 8h 3
y 2 y 0 2hy 0 ' y 0 ' ' y 0 ' ".....
2! 3!
h h2
A1 = 0
y 4
y 0 hy 0 ' y 0 " '......
3 2!
4h 2 8h 3
+ y 0 2hy 0 ' y 0 " y 0 " '......
2! 3!
4h 3 2h 2 5h 5 iv
= 2hy0 + 2h y0 +
2
y0 " y0 " ' y0 ..... ---(8)
3 3 18
x2
Error in the interval [x0, x2] = x0
y dx A1
4 5
= h 5 y 0 ,
iv
[(6)-(8)],
15 18
4 5 h 5 iv
= h 5 y 0
iv
y0
15 18 90
h 5 iv
Similarly principal part of the error in [x2, x4] = y2 and so on.
90
h5
Hence the total error E = [ y 0 y 2 ..... y iv 2 ( n 1) ]
iv iv
90
Assuming the yiv (X) is the largest of y0iv, y2iv, …., yiv2n-2, we get
nh 5 iv (b a)h 4 iv
E < y0 ( X ) y (X ) , [ 2nh = b-a], ---(9)
90 180
1
i.e., the error in Simpson’s rule is of the order h4.
3
147
(3) Error in Simpson’s 3/8 rule. Proceeding as above, here the principal part of the error in the
interval [x0, x3]
3h 5 iv
= y --- (10)
80
1. Find the first and second derivatives of the function tabulated below at x = 1.1,
x: 1.00 1.2 1.4 1.6 1.8 2.0
f(x): 0 1 5 21 27
3. Calculate the value of 2 sin x dx by Simpson’s one-third rule using 10 sub-intervals.
0
4. A curve is drawn to pass through the points given in the following table:
x: 1 1.5 2 2.5 3 3.5 4
Find the area bounded by the curve, x-axis and the lines x = 1, x = 4.
148
6.7 SUMMAERY
There are two different strategies to develop numerical integration formulae. One is similar to
what we have adopted to numerical differentiation. That is, we approximate a polynomial for the
given function and integrate that polynomial within the limits of the integration. This restricts us
to integrate a function known at discrete tabular points. If these points are uniformly spaced then
the corresponding integration formulae are called as Newton - Cotes formulae for numerical
integration. On the other hand if we know the function explicitly but could not integrate in the
usual means because of the nature of the function then we can use the concept called quadrature
rule to find an approximate value to the integration.
In this method the function is evalualted at some predetermined abscissa (nodal) points and then
these values are added after multiplying them with some weights which are again
predeternmined, to find an approximate value to the given integral.
149
6.8 KEYWORDS
dy 1 1 2 1 3 1 4
y o y 0 y 0 y 0 .........
x0
dx h 2 3 4
d2y 1 2 11 4
2 2 y 0 y 0 12 y 0 .....
3
dx x0 h
dy 1 1 2 1 3 1 4
y n y n y n y n ..........
dx xn h 2 3 4
d2y 1 11
2 = 2 2 y n 3 y n 4 y n ....
dx xn h 12
dy = 1 y 0 y 1 1 y 1 y 2 1 y 2 y 3
3 3 5 5
........
dx x0 h 2 6 2 30 2
d2y 1 2 1 4 1 6
2 2 y 1 12 y 2 90 y 3 .....
dx x0 h
h
y 0 y n 2( y1 y 2 .... y n1 )
x0 nh
4. Trapezoidal Rule:- x0
f ( x)dx =
2
h
y0 y n 4( y1 y3 .... y n1 ) 2( y 2 y 4 ..... y n2 )
x0 nh
x0
f ( x)dx =
3
150
5. Simpson’s three-eighth Rule
3h
y 0 y n 3( y1 y 2 y 4 y 5 .. y n1 ) 2( y 3 y 6 .. y n3 )
x0 nh
x0
f ( x)dx =
8
1. From the following table of values of X and Y, obtain first and second Derivatives for
X=1.2
2. From the following table of values of X and Y, obtain first and second Derivatives for
X=1.4
3. From the following table of values of X and Y, obtain first and second Derivatives for
X=2.2
4. From the following table of values of X and Y, obtain first and second Derivatives for
X=1.4
151
5. From the following table of values of X and Y, obtain first and second Derivatives for
X=5
x 2 4 9 10
y 4 56 711 980
6. From the following table, find the area bounded by curve and x axis from X=7.47 to
X=7.52 using trapezoidal, simpson’s 1/3, simpson’s 3/8 rule.
(1) 4.75;9
(2) 0.63;6.6
(3) 2.8326
(4) 0.9985
(5) 7.78
152
6.11 REFERENCES/ SUGGESTEDREADINGS
153