Numerical Metods Chapter 1 & 2
Numerical Metods Chapter 1 & 2
Numerical Metods Chapter 1 & 2
Editors
Dr. P. M. Avhad
Dr. S. A. Katre
Preface
We are glad to present this book to S.Y.B.Sc. Mathematics students of Pune University. This book is strictly written according to the revised syllabus of second
semester of S.Y.B.Sc. Mathematics, implemented by University of Pune, since June
2014. The book deals with errors, solution of algebraic and transcendental equations, Interpolation, Least Square Curve tting procedure, Numerical dierentiation
and integration and numerical solution of rst order ODE.
This book is based on our teaching experience of last 16 17 years. Simple and
lucid language is used to explain the fundamental concept in each chapter. Book
contains large number of examples with all types. We request the students to solve
these problems on their own.
We are thankful to Prof. P.M.Avhad (chairman) and all other BOS members in
Mathematics, University of Pune for their continuous co-operation, encouragement,
and motivation to write this book. We are also thankful to University authorities
and press for publishing this book.
Suggestions and comments for further development of this book are welcome and
will be acknowledge.
In case of queries/suggestions, send an email to: pgjmaths@gmail.com
-Authors
Acknowledgment
We sincerely thank the following University authorities (Savitribai Phule Pune University, Pune) for their constant motivation and valuable guidance in the preparation
of this book.
ii
Contents
1
ERRORS
1.1 Introduction: . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Errors and Their Computations: . . . . . . . . . . . . . . . . .
1.3 Rounding o errors to n signicant digits,to n decimal places:
1.3.1 Truncation Error: . . . . . . . . . . . . . . . . . . . . .
1.4 Absolute, relative and percentage errors: . . . . . . . . . . . .
1.5 A General Error formula: . . . . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1
1
1
2
3
3
9
iii
Chapter 1
ERRORS
1.1
Introduction:
1.2
There are two types of numbers viz, exact and approximate numbers. Any real
31
315
number is exact number. e.g. 1, 2, 5, 12, 1000
, 1327
, 7, 10 7, , e.... are exact
numbers. Approximate numbers are those that represent the rational or irrational
numbers to a certain required accuracy.Approximate value of is 3.1416 or its better
approximation is 3.14159265. But we can not write its exact value. Same is true for
any irrational number.
Denition 1.1. Signicant Digits : The digits which are used to express a number are called signicant digits or signicant gures.
The numbers 62.345, 0.32122, 0.10026, 0.99999 contain ve signicant digits each.
23.4, 0.234, 0.0234, 0.000234 have three signicant gures.
The number of signicant digits is uncertain in number which is represented
by whole number like 32, 354; 1, 02, 34, 500 etc. The number 66400 has uncertain
1
CHAPTER 1.
ERRORS
number of signicant digits, whereas the numbers 6.64104 , 6.640104 and 6.6400
104 have three, four and ve signicant gures, respectively.
1.3
CHAPTER 1.
1.3.1
ERRORS
Truncation Error:
There is another type of error which is known as truncation error which is computed
by using approximate formula obtained by truncation of innite series given real
function. This error is associated with the problem of convergence.
Suppose Taylors series of real function f (x) is
f (x + h) = f (x) + hf (x) +
h2
h3
f (x) + f (x) +
2!
3!
(1.1)
If we neglect second and higher order derivatives in the above expansion (1.3.1)
then the error which arises in computation due to the truncation in formula is a
truncation error.
Remark 1.1. The round-o error can be reduced by computing for more signicant
gures. A useful rule is for each step retain at least one more gure than that given in
the data, round-o after performing last operation. The computer allow a precision
of 7 signicant gures in the range about 1038 to 1039 . Arithmetic carried out with
this precision is called single precision. For more accuracy arithmetic carried out
with 15 signicant gures with range about 10308 to 10308 (by MATLAB) is called
double precision.
1.4
(1.2)
ea = |xt xa |
(1.3)
ea
x
=
xt
xt
(1.4)
CHAPTER 1.
ERRORS
x
xt
(1.5)
(1.6)
then U is an upper limit of the absolute error and is said to measure absolute accuracy. Similarly the quantity
U
U
|xt |
|xa |
(1.7)
1
2 10n
(1.8)
Theorem 1.1. Let x1 and x2 be true values of two quantities,x1a and x2a be their
approximate values respectively.If e1 ,e2 and esum are errors in x1 ,x2 and x1 + x2
respectively then
esum = e1 + e2 .
(1.9)
(1.10)
CHAPTER 1.
ERRORS
(1.11)
Proof:
eprod = (x1 + e1 )(x2 + e2 ) x1 x2
= x1 x2 + x1 e2 + x2 e1 + e1 e2 x1 x2
= x1 e2 + x2 e1 + e1 e2
= x1 e2 + x2 e1 (approximately)
Theorem 1.4. Let x1 and x2 be true values of two quantities,x1a and x2a be their
approximate values respectively. If e1 ,e2 and eq are errors in x1 ,x2 and xx12 respectively
then
(
)
e2
x1 e1
(approximately).
eq =
(1.12)
x2 x1 x2
Proof:
(x1 + e1 ) x1
eq =
(x2 + e2 ) x2
x2 (x1 + e1 ) x1 (x2 + e2 )
=
x2 (x2 + e2 )
x2 e1 x1 e2
)
= (
x22 1 + xe22
x2 e1 x1 e2
e2
(approximately by neglecting
)
2
x2
x2
(
)
x1 e1
e2
=
x2 x1 x2
=
CHAPTER 1.
ERRORS
(1.13)
22
7
e = x x1 = 0.0030694
0.0030694
er =
= 0.000977
3.141592654
Example 1.4. Three approximate values of the number
0.12. Which of these three is the best approximation ?
1
9
CHAPTER 1.
ERRORS
Solution: We have
1
0.10 = 1
9
90
1
0.11 = 1
9
900
1
0.12 = 8
9
900
Solution: We have,
3
3 = 1.732, 11 = 2.234, 5 = 2.236
correct to 4 signicant digits.Hence,
3
S = 3 + 11 + 5 = 1.732 + 2.234 + 2.236 = 6.602
Now error in each number is 0.0005 hence error in S is,
e = 3 0.0005 = 0.0015.
This total error shows that the sum is correct to 3 signicant digits only. Hence we
take S = 6.60 and then relative error in Sis,
er =
e
0.0015
=
= 2.27 104 = 0.0002.
|x|
|6.60|
CHAPTER 1.
ERRORS
CHAPTER 1.
1.5
ERRORS
In this we derive a general formula for the error committed in using a certain functional relation.Let
u = f (x1 , x2 , ..., xn )
(1.14)
(1.15)
f
xi + term involving(xi )2
u + u = f (x1 , x2 , ..., xn ) +
xi
i=1
(1.16)
Assuming that the errors in xi are small and that (xi )xi 1, so that the squares
and higher powers of xi can be neglected, the above relation yields
n
f
f
f
f
xi =
x1 +
x2 + ..... +
xn
u
x
x
x
x
i
1
2
n
i=1
(1.17)
We observe that this formula has the same form as that for the total dierential of
u. The formula for the relative error follows immediately:
er =
u u x1 u x2
u xn
=
+
+ ..... +
u
x1 u
x2 u
xn u
(1.18)
2yz
2z
2y
x
+
y
+
z
x3
x2
x2
CHAPTER 1.
ERRORS
10
0.006
(u)max
=
= 0.003
u
2
Exercise:
CHAPTER 1.
ERRORS
11
10. Three approximate values of the number 1/3 are given as 0.30, 0.33 and 0.34
Which of this three is the best approximation. (0.33)
11. Three approximate values of the number 2/3 are given as 0.65, 0.66 and 0.67
Which of this three is the best approximation. (0.67)
12. Three approximate values of the number 1/6 are given as 0.165, 0.166 and 0.167
Which of this three is the best approximation. (0.167)
Chapter 2
SOLUTION OF ALGEBRAIC AND
TRANSCENDENTAL EQUATIONS
2.1
Introduction:
In scientic and engineering studies we come across roots of equations of the form
f (x) = 0.
(2.1)
2.2
Mathematical Preliminaries:
In this section we state certain denitions and mathematical results which would be
useful in the sequel.
Denition 2.1. Algebraic function: An expression of form
f (x) = a0 + a1 x + a2 x2 + ... + an xn
is called as algebraic function or polynomial function of degree n.
12
(2.2)
13
f (b) f (a)
.
ba
(2.3)
Theorem 2.3. Taylors series:If f (x) possesses all ordered continuous derivatives
in an interval containing a then in that interval f (x) is expressed as series containing
powers of (x a) as follows:
(x a)2
(x a)n (n)
f (a) + +
f (a) +
2!
n!
(This series is called as Taylors series of f (x) about a.)
f (x) = f (a) + (x a)f (a) +
2.3
(2.4)
(a + b)
,
2
r = 0, 1, 2, .
(2.5)
14
4. If f (xr ) = 0 then
(a) If f (a)f (xr ) < 0 then root lies in the interval (a, xr ).Then take b = xr and
go to step 2 above.
(b) If f (xr )f (b) < 0 then root lies in the interval (xr , b).Then take a = xr and
go to step 2 above.
5. Repeat steps 2 , 3 and 4 till we get root correct to required accuracy or till
getting required number of iterations.
Note: In bisection method in each iteration width of interval is reduced by a
factor one half and hence at the end of nth step width of interval containing root
will be |ba|
2n . Now,
|b a|
loge (|b a| )
2n
loge 2
(2.6)
4 + 4.5
= 4.25
2
we nd f (x1 ) = 0.2656 which is negative. We therefore conclude that the root lies
between 4.25 and 4.5.
Proceeding this way, the following table is obtained
n.
1
2
3
4
5
6
7
8
9
10
11
12
a
4
4
4.25
4.25
4.25
4.2813
4.2969
4.2969
4.3008
4.3027
4.3042
4.3044
b
5
4.5
4.5
4.375
4.3125
4.3125
4.3125
4.3047
4.3047
4.3047
4.3047
4.3047
x
4.5
4.25
4.375
4.3125
4.2812
4.2969
4.3047
4.3008
4.3027
4.3037
4.3044
4.3046
15
f(x)
0.75
-0.1875
0.2656
0.0352
-0.0771
-0.0212
0.0069
-0.0072
-0.0001
0.0033
0.0060
0.0065
At n = 12, it is seen that the dierence between two successive iterates is 0.0005
which is less than 0.001. Thus x = 4.3046 is the approximate root of the given
equation.
Example 2.2. Find the root of the equation ex = sinx using bisection method.
Solution:
We have f (x) = ex sinx = 0. Since f (0) is positive and f (1) is negative, a root
lies between 1 and 0 and therefore we take x0 = 0.5. Then f (x0 ) = 0.1271 which is
positive.
Hence the root lies between 1 and 0.1271 and we obtain
Proceeding this way, the following table is obtained
n
1
2
3
4
5
6
7
8
9
10
11
a
1
1
0.75
0.625
0.625
0.5938
0.5938
0.5938
0.5898
0.5898
0.5889
b
0
0.5
0.5
0.5
0.5625
0.5625
0.5781
0.5859
0.5859
0.5879
0.5879
x
0.5
0.75
0.625
0.5625
0.5937
0.5781
0.5859
0.5898
0.5879
0.5889
0.5884
16
f(x)
0.1271
-0.2093
-0.0498
0.0365
-0.0072
0.0145
0.0036
-0.0018
0.0009
-0.0004
0.0002
At n = 11, it is seen that the absolute dierence between two successive iterates
is 0.0006 which is less than 0.001. Thus x = 0.5884 is the approximate root of the
given equation.
Exercise:
Using Bisection method nd root (correct up to three decimal places) of the following
equations.
1. x3 + x2 + x + 7 = 0
(2.105)
2. x3 x 4 = 0
(1.79604)
3. x3 x2 1 = 0
(1.466)
4. x3 3x 5 = 0
(2.279)
5. x3 5x + 3 = 0
(0.657)
2.4
This is the oldest method for nding the real root of a nonlinear equation y = f (x) =
0. In this method rstly we choose two points a and b such that f (a) and f (b) have
17
opposite signs. Hence,a root must lies between these points. Now, the equation of
the chord joining the two points A(a, f (a) and B(b, f (b)) is given by
y f (a) f (b) f (a)
=
xa
ba
(2.7)
f (a)
af (b) bf (a)
=
f (b) f (a)
f (b) f (a)
(2.8)
f (a)
af (b) bf (a)
=
,
f (b) f (a)
f (b) f (a)
r = 0, 1, 2, .
(2.9)
18
Solution:
Since f (1) is negative and f (2) is positive, a root lies between 1 and 2 and therefore
we take x0 = 1 and x1 = 2. Now by the formula
f (x0 )
(x1 x0 )
f (x1 ) f (x0 )
f (1)
x2 = 1
(2 1)
3 (1)
x2 = 1.25
x2 = x0
Now f (x2 ) = 0.6094 which is negative so root lies between1.25 and 2 Therefore
now we take x0 = 1.25 and x1 = 2 and using the formula again we get
f (x0 )
(x1 x0 )
f (x1 ) f (x0 )
f (1.25)
x3 = 1.25
(2 1.25)
3 (0.6094)
x3 = 1.3766
x3 = x0
Now f (x3 ) = 0.2863 which is negative so root lies between1.3766 and 2 Therefore
now we take x0 = 1.25 and x1 = 2 and continuing this process we get following
table.
n
1
2
3
4
5
6
7
8
9
x0
x1
1
2
1.25
2
1.3766 2
1.4309 2
1.4524 2
1.4606 2
1.4637 2
1.4649 2
1.4653 2
xn
f (xn )
1.25
-0.6094
1.3766 -0.2863
1.4309 -0.1177
1.4524 -0.0457
1.4606 -0.0173
1.4637 -0.0065
1.4649 -0.00245
1.4653 -0.0009
1.4655 -0.0003
19
Exercise:
1. Using False position method nd root, correct to three decimal places of the
following equations.
(a) x3 x 4 = 0 (1.796)
(b) x3 x 1 = 0 (1.325)
(c) x3 + x 1 = 0 (0.682)
(d) x3 + x2 + x + 7 = 0
(e) x3 x 4 = 0
(f) x3 x2 1 = 0
2. Evaluate
(a) 2 18
(b) 3 13
(c) 2 10
(d) 4 72
2.5
In previous root nding methods, we use end points of a interval containing a root
to nd an approximate root of the given equation.In iteration method we take value
in a interval containing a root as initial approximate root of the given equation and
improve it to required accuracy.
Let f (x) = 0 be given equation. In iteration method to nd a root of equation
f (x) = 0,we use following steps:
1. Using location of root result nd an interval I containing a root of the equation.
2. Rewrite equation f (x) = 0 as x = (x) where (x) < 1 for each x I.
20
(2.10)
(2.11)
(2.12)
x1 = (x0 )
(2.13)
From (2.4.2),
(2.14)
Now without loss of generality assume x0 < then by hypothesis (x) satisfy both
conditions of Lagranges mean value theorem on the interval [x0 , ] I. Therefore
there exist 0 (x0 , ) such that
() (x0 )
x0
( x0 ) (0 ) = () (x0 )
(0 ) =
(2.15)
(2.16)
21
(2.17)
Similarly we obtain
x2 = ( x1 ) (1 ), x1 < 1 <
(2.18)
x3 = ( x2 ) (2 ), x2 < 2 <
..
.
(2.19)
(2.20)
(2.21)
(2.22)
(2.23)
(2.24)
3x = cosx + 1
1
(x) = x = (cosx + 1)
3
|sinx| 1
| (x)| =
<
3
3
22
n
0
1
2
3
4
5
xn
0
0.3333
0.6483
0.5990
0.6086
0.6068
xn+1
0.3333
0.6483
0.5990
0.6086
0.6068
0.6072
f (xn+1 )
-0.9451
0.1479
-0.0288
0.0054
-0.0010
0.0002
Example 2.5. Find the root of the equation x = (5 x) 3 using iteration method.
Solution:
1
(x) = x = (5 x) 3
2
1
| (x)| = (5 x) 3 < 1
3
Hence the iteration method can be applicable.
We start with x0 = 1. Therefore x1 = (x0 ) = 1.5874 and f (x1 ) = 0.0819 and
x2 = (x1 ) = 1.5055. Proceeding this way, the following table is obtained
n
0
1
2
3
4
xn
1
1.5874
1.5055
1.5175
1.5158
xn+1 f (xn+1 )
1.5874 0.0819
1.5055 -0.0119
1.5175 0.0017
1.5158 -0.0003
1.5160 0.0001
23
Exercise:
Using Iteration method nd a root, correct to 4 signicant gures of the following
equations.
1. x =
1
(x+1)2
(0.4655)
2. xsinx = 1 (1.068)
3. 5x3 20x + 3 = 0 (0.1514)
4. sin2 x = x2 1 (1.404)
5. ex = cotx (0.5314)
6. ex = 10x (0.0913)
7. x3 = x2 + 1 (1.466)
8. sinx = 10(x 1) (1.088)
2.5.1
Let xi1 , xi , xi+1 be three successive approximations to the desired root of the
equation x = (x) which is equivalent to f (x) = 0 satisfying conditions of iterative
method.Then from iterative method we have,
xi = k( xi1 ), xi+1 = k( xi )
(2.25)
xi1
xi
=
xi+1
xi
(2.26)
(xi+1 xi )2
= xi+1
xi+1 2xi + xi1
(2.27)
Dividing, we obtain
24
(xi )2
2 xi1
(2.28)
This explains the term 2 -process. For computation of 2 process we use following
table
x1
x1 = x2 x1
x2
2 x1 = x2 x1
x2 = x3 x1
x3
Example 2.6. Find the root of the equation 3x = cosx + 1 using iteration method
and Aitkens 2 process.
Solution:
As per the table () given above x1 = 0.3333, x2 = 0.6483 and x3 = 0.599 hence
by formula xi = xi+1 xi we get x1 = 0.315, x2 = 0.0493 and 2 x1 =
x2 x1 = 0.3643
By Aitkens 2 process,
(x2 )2
x4 = x3
2 x1
= 0.6057
Which corresponds to 4 normal iteration in iteration method.
2.6
25
Newton-Raphson Method:
Let f (x) = 0 be equation such that f (x) possesses all ordered derivatives in an
interval containing its one root say . Let x0 be an approximate root of f (x) = 0
and x1 = x0 + h be the correct root so that f (x1 ) = 0. Expanding f (x0 + h) by
Taylors series we get,
f (x0 + h) = f (x0 ) + hf (x0 ) +
h2
f (x0 ) + = 0
2!
x1 = x0
f (x0 )
f (x0 )
f (xn )
, n = 0, 1, 2, 3,
f (xn )
(2.29)
f (x) = x4 x 5
f (x) = 4x3 1
f (1) = 5 and f (2) = 9
xi+1 = xi
26
f (x1 )
f (x1 )
f (1.7422)
= 1.7422
f (1.7422)
2.4706
= 1.7422
20.1521
= 1.6196
f (x2 )
x3 = x2
f (x2 )
f (1.6196)
= 1.6196
f (1.6196)
4.2611
= 1.6196
15.9035
= 1.3532
f (x3 )
x4 = x3
f (x3 )
f (1.3532)
= 1.3532
f (1.3532)
0.9999
= 1.3532
8.9117
= 1.241
x2 = x1
11.
3
x = 11
f (x) = x3 11 = 0
f (x) = 3x2
27
Thus
f (x0 )
f (x0 )
1.739
= 2.1
13.23
= 2.2314
f (x1 )
x2 = x1
f (x1 )
0.1105
= 2.2314
14.9374
= 2.224
x1 = x0
3
11 2.224
Exercise:
1. Evaluate
(a) 2 18
(b) 3 13
(c) 2 10
(d) 4 72
(3.130)
28
29
4. Find the root of the equation ex sinx = 0 which lies between 0 and
1 (0.58867).
5. Find the root of the equation 3x = cosx + 1.
(0.6072)
N)
1(
xi+1 = xi +
2
xi
(1.414214)
7. Find the leasr positive root of the equation tanx = x to an accuracy of 0.0001
by Newton-Raphson method.
(4.4934)