Numerical Analysis Book
Numerical Analysis Book
Written by:
January, 2020
Wolkite University, Ethioplia
ii
Contents
Preface vii
1.1 Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
iv
3.2.4 Finite Difference Method for Non Linear Boundary Prob-
lems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
v
vi
Preface
viii
Rational
We have been teaching Numerical Analysis for the seven years in Wolkite
University for science and engineering students. Besides, we have noticed
that the following problems were affecting the students’ performance and
motivation while taking the course:
♣ Programming experience.
Given the fact that we use MATLAB, and that experience programming is
an important issue for student performance, we have developed a series
of tutorials in MATLAB and we would like to test their usefulness as well
as how to improve them. Also, critical thinking about the course will help
to determine what kind of experience of programming we require, how can
we make the students gain that skill (if they don’t have it), and determine
what do we expect from them at the end of the course from the program-
ming point of view. To improve students’ performance, we devoted to write
this book so as students can use it as supplementary book. We orga-
nize this small Laboratory manual for science and engineering students
who have a course of numerical methods/numerical analysis. It will help
them as a self study for their computing practices on solving problems.
We briefly discus the MATLAB techniques for matrix analysis as matrix
inverse, determinant, transpose of a matrix, matrix arithmetic. More de-
tails are also given to solutions of nonlinear equations, especially on the
methods of bisection, Newton method, and on solutions of linear systems
like Gaussian elimination methods. We developed short methods to find
solutions to Science and engineering problems using symbolic computer
coding.
x
Module Description
Objectives
• Define interpolation.
Introduction
2
2x − 1 can be written as x2 − 2x − 1 = −2 + (x − 1) + (x − 1)(x − 2). In particular,
if a census of the population of Ethiopia is taken every 10 years. the
following table lists the population, in thousands of people, from 1950 to
2000 and the data are also represented in the following figure 1.1.
In reviewing these data, we might ask whether they could be used to pro-
vide a reasonable estimate of the population,say in 1965, 1978, 1990, e.t.c..
Prediction of this type or simply approximate the polynomial that express
such data is called Interpolation or if the data is given in (x0 , y0 ), (x1 , y1 ), (x2 , y2 )
· · · (xn , yn ), then computing the value of y at the value of x in [x0 , xn ] is called
Interpolation But computing the value of y at the value of x outside [x0 , xn ]
is called Extrapolation. for example the process of computing the popula-
tion of the above data in 1945 or 2020 is called extrapolation. Interpolation
is required in many Engineering and Science applications that use tabular
3
data as input. Polynomials are the most common choices of interpolation
because they are easy to evaluate, differentiate and integrate.
1.1 Interpolation
Objectives
? Define interpolation.
2. Interpolate the function f (x) = ex sin(x) using f (1) = 2.2874, f (2) = 6.7188
and f (3) = 2.8345.
4
1.1.1 Interpolation With Equal Interval
Given the set of n + 1 values, with (x0 , y0 ), (x1 , y1 ), (x2 , y2 ), ..., (xn , yn ) of x and
y , it is required to find yn (x) , a polynomial of degree nth such that y and
yn (x) agree at the tabulated points. Let the values of x be equidistant, that
is:
xi − xi−1 = h, f or i = 1, 2, 3, ..., n
Therefore,
x1 = x0 + h
x2 = x0 + 2h
..
.
xi = x0 + ih
4y0 42 y0 43 y 0
yn (x) = y0 + (x − x0 ) + (x − x 0 )(x − x 1 ) + (x − x0 )(x − x1 )(x − x2 )
h 2!h2 3!h3
4n y0
+ ... + (x − x0 )(x − x1 )...(x − xn−1 )
n!hn
(1.3)
Given the set of n + 1 values, with (x0 , y0 ), (x1 , y1 ), (x2 , y2 ), ..., (xn , yn ) of x and
y , it is required to find yn (x) , a polynomial of degree nth such that y and
yn (x) agree at the tabulated points. Let the values of x be equidistant, that
is:
xi − xi−1 = h, f or i = 1, 2, 3, ..., n
Therefore,
x1 = x0 + h
x2 = x0 + 2h
..
.
xi = x0 + ih
Like (1.2) let yn (x) be a polynomial of nth degree, and written as:
6
Here, the coefficients, a0 , a1 , ..., an+1 , are computed as follow:
Putting x = xn in (1.5) gives,
yn (xn ) = a0 ⇒ yn = a0 (Since the other terms in (1.5) vanish)
Again putting x = xn−1 in (1.5) gives,
yn (xn−1 ) = yn−1 = a0 + a1 (x( n − 1) − xn ) ⇒ yn (xn−1 ) = yn−1 = yn − a1 h
Now, solving for a1 gives:
yn − yn−1 Oyn
a1 = ⇒
h h
Similarly, putting x = xn−2 , x = xn−3 , ..., x = x0 in (1.5), we obtain
O 2 yn O3 yn O n y0
a2 = , a 3 = , ..., a n =
2!h2 3!h3 n!hn
Now, Substitute these values of a0i s, in (1.5) we obtain
Oyn O 2 yn
yn (x) = yn + (x − xn ) + (x − xn )(x − xn−1 )
h 2!h2
O3 yn On yn
+ (x − x n )(x − x n−1 )(x − xn − 2) + ... + (x − xn )(x − xn−1 )...(x − x0 )
3!h3 n!hn
(1.6)
x 0 1 2 3
f(x) 1 2 1 10
Solution 1.1. The forward difference table for the data is given above.
Since n = 3 ,the cubic Newton’s forward difference interpolation polynomial
7
becomes:
Example 1.2. .
Find the interpolating polynomial corresponding to the data (1, 5), (2, 9), (3, 14),and
(4, 21), Using Newton’s backward difference interpolation polynomial.
Solution 1.2. We have the following backward difference table for the data.
The backward differences can be written in a tabular form as in Table.
A. Lagrange Interpolation
x x0 x1 x2 ··· xn
f (x) f (x0 ) f (x1 ) f (x2 ) ··· f (xn )
Pn (x) = L0 (x)f (x0 ) + L1 (x)f (x1 ) + L2 (x)f (x2 ) + ... + Ln (x)f (xn )
n
X
Pn (x) = Li (x)fi (1.8)
i=0
x − x1 x−x1
• For Linear Lagrange polynomial: L0 (x) = and L1 (x) = x0 −x1
x0 − x1
(x − x1 )(x − x2 )
• For Quadratic Lagrange polynomial: L0 (x) = , L1 (x) =
(x0 − x1 )(x0 − x2 )
(x − x0 )(x − x2 ) (x − x0 )(x − x1 )
and L2 (x) = e.t.c.
(x1 − x0 )(x1 − x2 ) (x2 − x0 )(x2 − x1 )
9
Solution 1.3. In this case we have
x − x1 x−5 (x − 5)
L0 (x) = = = and
x0 − x1 2−5 −3
x − x0 x−2 (x − 2)
L1 (x) = = =
x1 − x0 5−2 3
(x − 5) (x − 2)
Pn (x) = L0 (x)f (x0 ) + L1 (x)f (x1 ) = (4) + (1) = 6 − x
−3 3
Exercise 1.1. Given that f (0) = 1, f (1) = 3, andf (3) = 55 find the unique
polynomial of degree 2 or less, which fits the given data.
Divided Difference
Let the data values, (xi , f (xi )), i = 0, 1, 2, ..., n be given. We define the di-
vided differences as follows.
First divided difference: Consider any two consecutive data values (xi , f (xi ))
and (xi+1 , f (xi+1 )). Then, we define the first divided difference as;
f (xi+1 ) − f (xi )
f [xi , xi+1 ] = , i = 0, 1, 2, ..., n − 1
xi+1 − xi
f (x1 ) − f (x0 ) f (x2 ) − f (x1 )
T heref ore, f [x0 , x1 ] = , f [x1 , x2 ] = , e.t.c.
x1 − x0 x2 − x1
Note that:
f (xi ) f (xi+1 )
f [xi , xi+1 ] = f [xi+1 , xi ] = + , i = 0, 1, 2, ..., n − 1
xi − xi+1 xi − xi+1
We say that the divided differences are symmetrical about their argu-
ments.
Second divided difference: Consider any three consecutive data values
(xi , f (xi )), (xi+1 , f (xi+1 )) and (xi+2 , f (xi+2 )) Then, we define the second
10
divided difference as;
The nth divided difference using all the data values in the table, is de-
fined as;
Example 1.4. .
Obtain the divided difference table for the data:
x −1 0 2 3
f (x) −8 3 1 12
Solution 1.4. . We have the following divided difference table for the data.
The divided differences can be written in a tabular form in Table below:
11
We mentioned earlier that the interpolating polynomial representing a
given data values is unique, but the polynomial can be represented in
various forms. If we write the interpolating polynomial as;
f 1 − a0 f1 − f0
pn (x1 ) = f (x1 ) = f1 = a0 + a1 (x − x0 ) ⇒ a1 = = = f [x0 , x1 ]
x − x0 x − x0
Similarly;
So, we can write the interpolating polynomial using Divided Difference as;
Example 1.5. .
Find f (x) as a polynomial in x for the following data by Newton’s divided
12
difference formula.
x −4 −1 0 2 5
f (x) 1245 33 5 9 1335
13
Solution 1.5. .
First we form the divided difference table for the data as follow:
14
Self check exercise 1.1. .
1. Find f (x) as a polynomial in x for the following data by Newton’s forward
interpolation formula.
x −2 −1 0 1 2 3
f (x) 9 16 17 18 44 81
y = e2x
x −2 −1 0 1 2 3
f (x) 9 16 17 18 44 81
x −2 −1 0 1 3 4
f (x) 9 16 17 18 44 81
15
1.2 Numerical Integration
Objectives
Introduction
Some functions may not be analytically integrable. In this case the help of
numerical analysis is very important to compute the given definite integral.
In this chapter we will see some of the numerical methods those we apply
to integrate a function numerically over a given interval.
16
plicit anti-derivative). Numerical integration is a process of finding the nu-
merical value of a definite integral
Z b
I= f (x)dx (1.12)
a
Let Z b
I= f (x)dx
a
Z x0 +nh
I= f (x)dx
x0
17
n
r(r − 1) 2 r(r − 1)(r − 2) 3 r(r − 1)(r − 2)...(r − (n − 1)) n
Z
= h [ y0 +r4y0 + 4 y0 + 4 y0 +...+ 4 y0 ] dr
0 2! 3! n!
By Newton’s forward interpolation formula, so integrating this term by
term, gives us;
x0 +nh
n(2n − 3) 2 n(n − 2)2 3
Z
n
I= f (x)dx = nh[ y0 + 4y0 + 4 y0 + 4 y0
x0 2 12 24
n4 3n3 11n2 44 y0 n5 35n3 50n2 45 y 0
+( − + − 3n) + ( − 2n4 + − + 12n)
5 2 3 4! 6 4 3 5!
n6 15n5 255n3
274n 2
4 6
y 0
+( − + 17n4 + − − 60n) + ...] (*)
7 6 4 3 6!
Putting n = 1 in equ (∗) above and taking the curve through x0 , y0 and
x1 , y1 as a straight line i.e. a polynomial of first degree so that differences
of order higher than first becomes zero, we get;
Z x0 +h
1 h
f (x) dx = h y0 + 4y0 = (y0 + y1 )
x0 2 2
Similarly
Z x0 +2h
1 h
f (x) dx = h y1 + 4y1 = (y1 + y2 )
x0 +h 2 2
..
.
Z x0 +nh
1 h
f (x) dx = h yn−1 + 4yn−1 = (yn−1 + yn )
x0 +(n−1)h 2 2
18
Adding these n integrals, we obtain;
Z x0 +nh
h
f (x) dx = [(y0 + yn ) + 2(y1 + y2 + y3 + ... + yn−1 )] (1.13)
x0 2
Putting n = 2 in equ (∗) above and taking the curve through (x0 , y0 ) , (x1 , y1 )
and (x3 , y3 ) as a parabola i.e. a polynomial of second degree so that differ-
ences of order higher than second vanish , we get
Z x0 +2h
1 2 h
f (x) dx = 2h y0 + 4y0 + 4 y0 = (y0 + 4y1 + y2 )
x0 6 3
Similarly,
Z x0 +4h
h
f (x) dx = (y2 + 4y3 + y4 )
x0 +2h 3
..
.
Z x0 +nh
h
f (x) dx = (yn−2 + 4yn−1 + yn )
x0 +(n−2)h 3
This is known as the Simpson’s one-third rule or simply Simpson’s rule and
it is most commonly used.
Obs. While applying (1.14), the given interval must be divided in to even
number of equal sub-intervals, since we find the area of two strips at a
19
time.(i.e.n must be even.)
Putting n = 3 in equ (∗) above and taking the curve through (xi , yi ) i =
0, 1, 2, 3 as a parabola i.e. a polynomial of degree three so that differences
of order higher than second vanish , we get
Z x0 +3h
3 3 2 1 3 3h
f (x) dx = 3h y0 + 4y0 + 4 y0 + 4 y0 = (y0 + 3y1 + 3y2 + y3 )
x0 2 2 8 8
Similarly
Z x0 +6h
3h
f (x) dx = (y3 + 3y4 + 3y5 + y6 )
x0 +3h 8
..
.
20
1.2.4 Waddle’s rule
Putting n = 6 in equ (∗) above and neglecting all differences above the sixth
order, we obtain;
Z x0 +6h
9 2 3 123 4 11 5 1 41 6
f (x) dx = 6h y0 + 34y0 + 4 y0 + 44 y0 + 4 y0 + 4 y0 + ( 4 )y0
x0 2 60 20 6 140
3h
= (y0 + 5y1 + y2 + 6y3 + y4 + 5y5 + y6 )
10
Similarly,
Z x0 +12h
3h
f (x) dx = (y6 + 5y7 + y8 + 6y9 + y10 + 5y11 + y12 )
x0 +6h 10
..
.
21
1.2.5 Errors in quadrature formulas
(x − x0 )2 00 (x − x0 )3 000
y = y0 + (x − x0 )y00 + y0 + y0 + ... (1.18)
2! 3!
Therefore,
x1 x0 +h
(x − x0 )2 00 (x − x0 )3 000
Z Z
y dx = y0 + (x − x0 )y00 + y0 + y0 + ... dx
x0 x0 2! 3!
x0 +h
h2 0 h3 00 h4 000
Z
y dx = hy0 + y + y + y0 + ... (1.19)
x0 2! 0 3! 0 4!
1
A1 = h (y0 + y1 ) (1.20)
2
h2 00 h3 000
y1 = y0 + hy00 + y + y0 + ... (1.21)
2! 0 3!
h2 00 h3 000
1 0
A1 = h y0 + y0 + hy0 + y0 + y0 + ...
2 2! 3!
22
h2 0 h3 00 h4 000
A1 = hy0 + y0 + y0 + y + ... (1.22)
2 2.2! 2.3! 0
3
That is, principal part of the error in [x0 , x1 ] = − h12 y000
3
Similarly, principal part of the error in [x1 , x2 ] = − h12 y100 and so on.
3
Hence the total error E = − h12 y000 + y100 + y200 + ...yn−1
00
Assuming that y 00 (X) is the largest of the n quantities , we obtain y000 + y100 +
y200 + ...yn−1
00
nh3 00 (b − a)h2 00
E< − y (X) = − y (X) (1.23)
12 12
Since nh = b − a
Hence the error in the trapezoidal rule is of order h2 .
ii.Error in Simpson’s 1/3 rule
Expanding y = f (x) around x = x0 by Taylor’s series, we get;
(x − x0 )2 00 (x − x0 )3 000
y = y0 + (x − x0 )y00 + y0 + y0 + ... (1.24)
2! 3!
x2 x0 +2h
(x − x0 )2 00 (x − x0 )3 000
Z Z
y dx = y0 + (x − x0 )y00 + y0 + y0 + ... dx
x0 x0 2! 3!
x0 +2h
4h2 0 8h3 00 16h4 000
Z
y dx = 2hy0 + y + y + y + ... (1.25)
x0 2! 0 3! 0 4! 0
Also A1 = area over the first doubt strip by Simpson’s 1/3 rule [x0 , x2 ].
1
A1 = h (y0 + 4y1 + y2 ) (1.26)
3
23
Putting, x = x0 + h and y = y1 in (1.24), we get;
h2 00 h3 000
y1 = y0 + hy 0 + y + y + ... (1.27)
2! 3!
5
Similarly principal part of the error in [x2 , x4 ]= − h90 y2iv
Hence the total error
h5 iv
y0 + y1iv + y2iv + ...yn−1
iv
E=−
90
Assuming that y iv (X) is the largest of the n quantities , we obtain y0iv + y1iv +
y2iv + ...yn−1
iv
nh5 iv (b − a)h4 iv
E< − y (X) = − y (X) (1.30)
90 180
Since 2nh = b − a
Hence the error in the trapezoidal rule is of order h4 .
24
iii. Error in Simpson’s 3/8 rule
Proceeding as above, here the principal part of the error in the interval
[x0 , x3 ]
3h5 iv
E= − y (X) (1.31)
80
Proceeding as above, here the principal part of the error in the interval
[x0 , x6 ]
h7 iv
E= − y (X) (1.32)
140
Example 1.6. .
Evaluate
Z 6
1
dx
0 1 + x2
By using:
a. Trapezoidal rule.
d. Weddell’s rule.
Solution 1.6. Divide the interval (0, 6) into six equal parts each of width
1
h = 1. The values of f (x) = are given below:
1 + x2
25
x 0 1 2 3 4 5 6
f (x) 1 0.5 0.2 0.1 0.0588 0.0385 0.027
y y0 y1 y2 y3 y4 y5 y6
Z 6
dx h
2
= ((y0 + y6 ) + (y1 + y2 + y3 + y4 + y5 ))
0 1+x 2
1
= [(1 + 0.027) + 2(0.5 + 0.2 + 0.1 + 0.0588 + 0.0385)]
2
= 1.4108.
Z 6
dx h
2
= ((y0 + y6 ) + 4(y1 + y3 + y3 + y5 ) + 2(y2 + y4 ))
0 1+x 3
1
= [(1 + 0.027) + 4(0.5 + 0.1 + 0.0385) + 2(0.2 + 0.0588)]
3
= 1.3662.
Z 6
dx 3h
2
= [(y0 + y6 ) + 3(y1 + y2 + y4 + y5 ) + 2(y3 )]
0 1+x 8
3
= [(1 + 0.027) + 3(0.5 + 0.2 + 0.0588 + 0.0385) + 2(0.1)]
8
= 1.3571.
26
iv. Solution by Waddle’s rule:
Z 6
dx 3h
= [y0 + 5y1 + y2 + 6y3 + y4 + 5y5 + y6 ]
0 1 + x2 10
= 0.3[1 + 5(0.5) + 0.2 + 6(0.1) + 0.0588 + 5(0.0385) + 0.027
= 1.3735
Also;
Z 6
dx
= tan−1 (6) − tan−1 (0) = 1.4056
0 1 + x2
This shows that the value of the integral found by Waddle’s rule is the
nearest to the actual value followed by its value given by Simpson’s 1/3
rule.
Exercise 1.2. .
Compute the following using Trapezoidal rule; Simpson’s rules and Waddles
rule with h = 0.01.
Z π/2 Z 1 Z 0.3
p 1
a. xsin(x) dx b. sin(x) + cos(x) dx c. (1 − 8x3 ) 2 dx
0 0 0
Z b n
X
f (x) dx ≈ ci f (xi ) (1.33)
a i=1
27
First transform any finite intervals [a, b] to [−1, 1].
Z b Z 1
⇒ f (x) dx = g(x) dx (1.34)
a −1
b = m(1) + c
⇒ ⇒ m = b−a 2
and c = b+a2
a = m(−1) + c
⇒ x = b−a2
t + b+a
2
and dx = b−a 2
dt
Rb R1
⇒ a f (x) dx = −1 f ( b−a t + b+a ) b−a
2 2 2
dt
b Z 1
b−a b−a
Z
b+a
f (x) dx = f t + dt (1.35)
a 2 −1 2 2
b 2
b − a2
Z
(a0 + a1 x) dx = a0 (b − a) + a1 (1.36)
a 2
c1 f (x1 ) = c1 (a0 + a1 x1 ) = c1 a0 + a1 (c1 x1 ) (1.37)
b 2 − a2
c1 = b − a and c1 x1 =
2
b 2 − a2
a+b
N ow, c1 x1 = (b − a)x1 ⇒ (b − a)x1 = ⇒ x1 =
2 2
Therefore;
Z b
a+b
f (x) dx ≈ c1 f (x1 ) = (b − a)f (1.38)
a 2
28
Here, if a = −1 and b = 1, then (1.38) becomes;
1
−1 + 1
Z
f (x) dx ≈ c1 f (x1 ) = (1 − (−1))f = 2f (0) (1.39)
−1 2
Solution 1.7. Here, f (x) = 5xe−2x , a = 0.1 and b = 1.3. So (3.8), we have;
Z 1.3
−2x 0.1 + 1.3
= 1.2f (0.7) = 1.2 5(0.7)e−2(0.7) = 1.0357
5xe dx = (1.3 − 0.1)f
0.1 2
(1.41)
Note that the exact solution is 0.8939, so the error is |0.8939 − 1.0357| = 0.1418
(1.42)
And also,
29
Now, relating the coefficients if a0 , a1 , a2 , a3 , from (1.42) and the above equa-
tion, we have the following four systems of equations;
c1 + c2 = 2
c x +c x =0
1 1 2 2
c1 x21 + c2 x22 = 2/3
c x2 + x2 = 0
3 3 3
Solution 1.8. First transform the interval [0.1, 1.3] to [−1, 1] by letting x =
mt + c
1.3 = m(1) + c
⇒ ⇒ m = 0.6 and c = 0.7 ⇒ x = 0.6t + 0.7
0.1 = m(−1) + c
Then,
f (x) = 5xe−2x
x = 0.6t + 0.7
and dx = 0.6 dt
30
Therefore,
Z 1.3 Z 1 Z 1
−2x −1.2t−1.4
5xe dx = (3t + 3.5)e (0.6)dt = (1.8t + 2.1)e−1.2t−1.4 dt
0.1 −1 −1
1 1
= f −√ +f √
3 3
1 −1.2(− √1 )−1.4 1 −1.2( √1 )−1.4
= (1.8(− √ ) + 2.1)e 3 + 1.8( √ ) + 2.1)e 3
3 3
= 0.52299 + 0.38719 = 0.91018
Note that the exact solution is, 0.8939, so the error is |0.8939 − 0.91018| =
0.01628, which is more accurate than one point Gaussian Quadrature rule.
Then using, similar procedure that of one point and two point Gaussian
quadrature formula, we take the three point Gaussian quadrature formula
as;
Z 1
r ! r !
5 3 8 5 3
f (x) dx ≈ c1 f (x1 ) + c2 f (x2 ) + c3 f (x3 ) = f + f (0) + f −
−1 9 5 9 9 5
(1.45)
31
R1
Example Approximate −1
ex cosxdx Using Gass-Legendre quadrature with
n = 3.
Solution 1.10
Since n = 3, we use three point Gassian Quadrature formula given in (1.45)
and taking the entries from the above table and we obtain;
Z 1
ex cosxdx = 1.93340
−1
And the exact solution is 1.9334214 so, the error is 0.0000214 which is very
small.
Double integral
Double Integral is definite integral over two dimensional region < and de-
noted as:
Z Z Z b Z d Z d Z b
I= f (x, y)d< = f (x, y) dy dx = f (x, y) dx dy
< a c c a
(1.46)
(1.47)
Example 1.10. .
Evaluate the integral;
Z 2.6 Z 4.6
1
I= dx dy
2 4 xy
32
1
Solution 1.10. First we calculate the value of f (x, y) = xy
and the result is
in the following table.
i. For y = 2;
3
I0 = (0.2)[ (0.125 + 0.1087) + 3(0.1191 + 0.1136) ] = 0.0698
8
3
I1 = (0.2)[ (0.1087 + 0.0945) + 3(0.1035 + 0.0988) ] = 0.0608
8
3
I2 = (0.2)[ (0.0962 + 0.0836) + 3(0.0916 + 0.0874) ] = 0.0538
8
Then, use Simpson’s 1/3 rule in y direction for the data given in the
following table.
y 2 2.3 2.6
f (y) 0.0698 0.0608 0.0538
0.3
I= [(0.0698 + 0.0538) + 4(0.0608)] = 0.0367
3
i. For y = 2;
0.2
I0 = [ (0.125 + 0.1087) + 2(0.1191 + 0.1136) ] = 0.0698
2
33
ii. For y = 2.3;
0.2
I1 = [ (0.1087 + 0.0945) + 2(0.1035 + 0.0988) ] = 0.0608
2
0.
I2 = [ (0.0962 + 0.0836) + 2(0.0916 + 0.0874) ] = 0.0538
2
Again, use Trapezoidal rule in y direction for the data given in the
following table.
y 2 2.3 2.6
f (y) 0.0698 0.0608 0.0538
0.3
I= [(0.0698 + 0.0538) + 4(0.0608)] = 0.0368
2
34
Self check exercise 1.2. .
1. Evaluate the integral
Z 1.2
1
dx,
0 1 + x2
35
Unit Summary
• Interpolation can be done for two types of given data. These are equal
spacing and unequal spacing data.
• We can use Trapezoidal rule, Simpson’s 1/3 rule, Simpson’s 3/8 rule,
waddle’s rule, Gaussian quadrature rule, e.t.c. to integrate numeri-
cally.
36
Review Exercise 1
1. Find sin(500 ) from the following data using forward and backward
difference
4. Find acubic polynomial which takes the values y(0) = 1, y(1) = 0, y(2) =
1, and y(3) = 10 using Newton’s backward difference formula and find
y(2.5)
5. A second degree polynomial passes through (0, 1), (1, 3), (2, 7), (3, 13).
Then find the polynomial.
37
taking 6 sub intervals and correct to five s.f by Simpson’s 1/3 rule
9. Calculate
Z π/2
esinx dx,
0
taking 3 sub intervals and correct to four d.p by Simpson’s 3/8 rule
References
38
2
Approximation Theory (12 hrs)
Objectives
Introduction
40
2.1 Discrete Least-Square Approximation
Objectives
41
In many Natural Sciences, social Sciences or behavioral Sciences, an
experiment or survey often produces a mass of discrete data. To interpret
these data, the investigator report using graphical methods. For instance,
an experiment in physics might produce a numerical table of the form:
x x0 x1 x2 ··· xn
f (x) f (x0 ) f (x1 ) f (x2 ) ··· f (xn )
straight line is the simplest and one of the most important curve fitting to
approximate a function that best fits of such data. least-square method
is the method that is used to find the best fit for a straight line.
such that the error E(a0 , a1 , a3 , ..., an ) in least square senses minimized; that
is
n
X
E(a0 , a1 , a2 , ..., an ) = (yk − (a0 + a1 xk + a2 x2k + ... + an xnk ))2 is minimum.
k=0
y = ax + b (2.1)
Now, best fitting the data means finding a best values of a and b in (2.1)
using suitable technique that mostly fit to the given data. For example, if
the nine points are represented in the following figure (2.1).
42
Figure 2.1: Scattered data diagram
As, we observe from the figure, the data points will not fall on the line
y = ax + b. if by chance the k th datum falls on the line, then:
(axk + b) − yk = 0
|(axk + b) − yk | =
6 0
The total absolute error, E for all n + 1 data points is given by:
n
X
E(a, b) = |(axk + b) − yk |
k=0
Now, sine this error is small(< 1), we can minimize the error by squaring
as:
n
X
E(a, b) = (|(axk + b) − yk |)2 (2.2)
k=0
By the help of derivative, let us minimize the total absolute error as:
∂ ∂
E(a, b) = 0 and E(a, b) = 0
∂a ∂b
Pn 2(|(ax + b) − y |)x = 0
k=0 k k k
P n
k=0 2(|(axk + b)| − yk ) = 0
43
This is a pair of simultaneous linear equation with unknowns a and b.
They are called normal equation and rearranged as:
(Pn x2 )a + (Pn x )b = Pn x y
k=0 k k=0 k k=0 k k
(2.3)
( n x )a + ( n 1)b =
P P P n
k=0 k k=0 k=0 yk
Example 2.1. Find the best fit value of a and b using the linear least square
method for the following tabular data.
x 4 7 11 13 17
y = f (x) 2 0 2 6 7
Solution 2.1. Plot the original data gives scatter diagram and let the straight
line y = a + bx best fits the given data. To find the values of a and b from the
normal equation, we compute the summations using table as follow:
644a + 52b = 227
52a + 5b = 17
Now, solving this system, we obtain the values of a and b is 0.4864 and
−1.6589 respectively. Therefore, the linear line y = 0.4864 + 1, 6589x best fits
the given data points.
Again, the total absolute square error is:
4
X
E(a, b) = (|yk − (0.4864 + 1.6589xk )|)2
k=0
44
Example 2.2. Find the best fit value of a and b using the linear least square
method for the following tabular data.
x 0 1 2 3 4
y = f (x) 1 1.8 3.3 4.5 6.3
m
X
E(a0 , a1 , a2 , ..., an ) = (yi − pn (xi ))2
i=0
Xm m
X m
X
2
= (yi ) − 2 (yi pn (xi )) + (pn (xi ))2
i=1 i=1 i=1
m
X m X
X n m X
X n
= (yi )2 − 2 ( (aj (xi )j ))yi + ( (aj (xi )j ))2
i=1 i=1 j=0 i=1 j=0
Xm Xn X m n
XX n m
X
= (yi )2 − 2 aj ( y i xi ) j + aj ak ( (xi )j )2
i=1 j=0 i=1 j=0 k=0 i=1
∂E
= 0, f or j = 0, 1, 2, ...n
∂aj
45
Thus, for each j we have:
m n m
∂E X X X
0= = −2( (yi xi )j ) + 2 ak ( (xi )j+k
∂aj i=1 k=0 i=1
n
X m
X m
X
ak ( (xi )j+k = yi xji j = 0, 1, 2, ..., n (2.4)
k=0 i=1 i=1
Here, equation (2.5) also called the normal equation and has unique solu-
tion provided that x0i s are unique.
Example 2.3. Fit the data below with the discrete least square polynomial
of degree at most 2.
Solution 2.3. For this problem n = 2 and m = 5. Also the three normal
equations are constructed from the following table.
46
5
X
E= (yi − p(xi ))2 = 0, 00720286
i
y = aebx (2.6)
Now, let Y = logy, A = loga, B = bloge, then (2.7) can be rewrite as;
Y = A + Bx (2.8)
Now, we use linear least square method to fit Equation (2.8) and so, the
normal equation is:
Pn
Yi = nA + B ni=1 xi
P
i=1
Pn Pn Pn 2 (2.9)
i=1 xi Yi = A i=1 xi + B i=1 xi
Solving the above equation for A and B, then solving for a and b, we get
B
a = antilogA and b = loge
Example 2.4. Fit the curve y = abx for the following data.
x 2 3 4 5 6
y = f (x) 144 172.8 207.4 248.8 298.5
47
Solution 2.4. We have given that y = abx ⇒ logy = loga + xlogb and reduced
to Y = A + Bx, where, A = loga, and B = logb
The normal equation are:
48
Self check exercise 2.1. .
1. Find the least square line y = ax + b for the data points, (-1, 10), (0, 9),
(1, 7), (2, 5), (3, 4), (4, 3), (5, 0) and (6, -1).
x −2 −1 0 1 2
y = f (x) 1 2 3 3 4
x 0 1 2 3 4
y = f (x) 0 1.8 1.3 2.5 6.3
4. Using a method of least square fit a curve y = abx to the following data:
x 2 3 4 5 6
y = f (x) 8.3 15.4 33.1 65.2 127.4
49
2.2 Continuous Least-Square Approximation
Objectives
Given f (x) continuous on [a, b], find a polynomial Pn (x) of degree at most n
50
Such that, the integral of the square of the error minimize. That is
Z b
E= [f (x) − pn (x)]2 dx is minimized. (2.12)
a
n
X
2 n−1 n
Let Pn (x) = a0 + a1 x + a2 x + .... + an−1 x + an x = ai xi and
i=0
Z b
E = E(a0 , a1 , a2 , ..., an ) = [f (x) − pn (x)]2 dx
a
n n
!2
Z b X Z b Z b X
E= [f (x)2 dx − 2 ai xi f (x) dx + ai x i dx
a i=0 a a i=0
Z b n Z b
∂E j
X
= −2 x f (x) dx + 2 ai xi+j dx
∂aj a i=0 a
n
X Z b Z b
i+j
ai x dx = xj f (x) dx , j = 0, 1, 2, ..., n (2.13)
i=0 a a
b
bi+j+1 − ai+j+1
Z
xi+j dx =
a i+j+1
51
the normal equations are:
52
53
Express ak as Weight function w(x)
54
2.2.3 Least Square Approximation of Function Using Leg-
ender’s polynomials
Example 2.6. Find the linear and quadratic least square approximation of
f (x) = ex using Legender’s Polynomials
55
Self check exercise 2.2. .
56
Unit Summary
57
Review Exercise 2
able.
x 0 1 2 3 4
y = f (x) 0 1.8 1.3 2.5 6.3
x −2 0 2 4 6
y = f (x) 1 3 6 8 13
x −4 −2 0 2 4
y = f (x) 1.2 2.8 6.2 7.8 13.2
x −3 −1 1 3
y = f (x) 15 5 1 5
5. Find the least square parabola for the points (-3, 3), (0, 1), (2, 1), (4,
3).
x 1 2 3 4
y = f (x) 05 1 1 2
7. Find the least square geometric curve y = axb for the following data:
x 1 2 3 4 5
y = f (x) 0.2 2 4.5 8 12.5
58
8. Using the method of least square fit a relation of the form y = abx :
x 2 3 4 5 6
y = f (x) 144 172.8 207.4 248.8 298.5
9. Using the method of least square fit a relation of the form y = abx :
x 1 2 3 4
y = f (x) 4 11 35 100
10. Find a least square curve of the form y = abx for the following data for
constants a and b:
x 61 26 7 2.6
y = f (x) 350 400 500 600
11. The pressure and volume of a gas are related by the equation P V λ = k
for λ and k are constants. Fit this equation for the given data bellow;
References
59
60
3
Numerical Methods For Ordinary
Differential Equations (16 Hrs)
Objective
• Solve linear and non-linear initial value problems using Euler’s method,
Runge-Kutta 4th order method.
Introduction
62
3.1 Initial Value Problems
Objectives
dy x+y
= , y(0) = 1.
dx x−y
5. Solve
d2 y
= 2y 0 − xy, y(0) = 1, y(2) = 4, f or1 ≤ x ≤ 2
dx2
63
6. Solve
dy
= f (x, y), y(x0 ) = y0 (3.1)
dx
d2 y dy
= f (x, y, ), a ≤ x ≤ b, y(a) = α, y 0 (a) = β (3.2)
dx2 dx
Example 3.1.
dy
a. = f (x, y), a ≤ x ≤ b, y(a) = α,
dx
b. y 0 = 1 + xsin(xy), 1 ≤ x ≤ 2, y(0) = 1
Note In example above a and b are of the first order, c is linear-second order
and d is non-linear second order initial value problems.
64
dy
Example 3.2. a. dx
= x − 3,
∂u
c. ∂x
= y,
Example 3.3.
and
dy
= f (x, y), y(x0 ) = y0 (3.3)
dx
d2 y ∂f ∂f dy
⇒ 2
= + = fx + fy y 0 (3.4)
dx ∂x ∂x dx
65
Then, differentiating successively we obtained y 000 , y (4) , y (5) , ...
The Taylor’s Series expansion about of y(x) about x = x0 gives;
(x − x0 )2 00 (x − x0 )3 000
y(x) = y(x0 ) + (x − x0 )y 0 (x0 ) + y (x0 ) + y (x0 ) + ...
2! 3!
(x − x0 )2 00 (x − x0 )3 000
y(x) = y0 + (x − x0 )y00 + y0 + y0 + ... (3.5)
2! 3!
Substituting the values of y0 , y00 , y000 , y0000 , ..., we obtain y(x) for all values of x
for which (3.5) converge.
Putting x1 = x0 + h, and y(x0 + h) = y(x1 )
h2 00 h3 000
y(x1 ) = y1 = y0 + hy00 + y + y0 + ... (3.6)
2! 0 3!
h2 00 h3 000
y(x2 ) = y2 = y1 + hy10 + y1 + y1 + O(h4 ) (3.7)
2! 3!
Where O(h4 ) represent all the terms involving fourth and higher order
terms.
Example 3.4. Given the IVP, y 0 = x − y 2 and y(0) = 1. Then find the approxi-
mate solution by Taylor’s method of order 3 at x0 = 0.1 and x1 = 0.2.
(x − x0 )2 00 (x − x0 )3 000
y(x) = y0 + (x − x0 )y00 + y0 + y0 + ...
2! 3!
But, y 0 (x) = x − y 2 , then,
Now, substituting the values of y0 , y00 , y000 and y0000 in formula for y(x) above we
66
get;
(x − x0 )2 (x − x0 )3
y(x) = 1 + (x − x0 )(−1) + (3) + (−8)
2! 3!
x2 8x3
1 + (−1)x + 3 −
2 6
3x0 2 8x0 3
T hen, y(x0 ) = 1 + (−1)x0 + −
2 6
3(0.1)2 8(0.1)3
⇒ y(0.1) = 1 + (−1)(0.1) + −
2 6
= 1 − 0.1 + 0.015 + 0.0013333
= 0.9156667
y(0.2) is Exercise!!!
dy
y0 = = f (x, y), with y(x0 ) = y0 (3.8)
dx
y1 = y0 + (x1 − x0 )f (x0 , y0 )
67
⇒ y1 = y0 + hf (x0 , y0 ) (3.11)
y2 = y1 + (x2 − x1 )f (x1 , y1 )
⇒ y2 = y1 + hf (x1 , y1 ) (3.12)
• Euler’s Formula
yn+1 = yn + hf (xn , yn )
F or n = 0, y1 = y0 + hf (x0 , y0 )
F or n = 1, y2 = y1 + hf (x1 , y1 )
F or n = 2, y3 = y2 + hf (x2 , y2 )
F or n = 3, y4 = y3 + hf (x3 , y3 )
F or n = 4, y5 = y4 + hf (x4 , y4 )
..
.
Solution 3.2. . The values of x with the given step size h are,
68
x0 = 0, x1 = 0.02, x2 = 0.04, x3 = 0.06, x4 = 0.08 and x5 = 0.1. then,
= 1 + 0.02(−1)
= 1 − 0.02
= 0.98
= −0.92006
= 0.9608 + 0.02(−0.92006)
= 0.942398.
= −0.880287
= 0.942398 + 0.02(−0.880287)
= 0.92479.
= −0.84076
= 0.92479 + 0.02(−0.84076)
= 0.907975.
69
y6 = y5 + hf (x5 , y5 ), but f (x5 , y5 ) = f (0.1, 0.907975) = (0.1 − 0.907975)/(0.1 + 0.907975)
= −0.80158
= 0.907975 + 0.02(−0.80158)
= 0.89194.
dy
a. = x + y 2 , y(0) = y0 = 1, h = 0.1
dx
dy
b. + y = 1, y(1) = y0 = 2, h = 0.1
dx
dy
c. = 1 + xy 3 , y(0) = 1, h = 0.1
dx
h
f (x0 , y0 ) + f (x1 , y10 )
f (x, y) =
2
h
f (x0 , y0 ) + f (x1 , y10 )
⇒ y1 =
2
h
y12 = f (x1 , y1 ) + f (x2 , y21 )
2
h n
yn+1 = yn + f (xn , yn ) + f (xn+1 , yn+1 ) , n = 1, 2, 3, ...n (3.13)
2
70
And y1th is the nth approximation of y1 . The formula can be starting from y10
by Euler’s formula. y1 = y0 + hf (x0 , y0 ).
Example 3.6. .
Using Modified Euler’s method solve for x = 0.06 of dy/dx = (x − y)/(x + y)
given that x0 = 0, y0 = 1 and h = 0.02.
Solution 3.3.
= 1 + 0.02(−1)
= 0.98
Then,
y1 = y0 + h/2(f (x0 , y0 ) + f (x1 , y10 )), but f (x0 , y0 ) = −1 and f (x1 , y10 ) = f (0.02, 0.98) = −0.96
= 1 + 0.02/2(−1 − 0.96)
= 0.9804
y20 = y1 + hf (x1 , y1 ) butf (x1 , y1 ) = f (0.02, 0.9804) = (0.02 − 0.9804)/(0.02 + 0.9804) = −0.9600
= 0.9804 + 0.02(−0.9600).
= 0.9612.
Then,
y2 = y1 + h/2(f (x1 , y1 ) + f (x2 , y20 )), but f (x1 , y1 ) = −0.9600 and f (x2 , y20 ) = f (0.04, 0.9612)
= −0.9201
= 0.961599.
71
y30 = y2 + hf (x2 , y2 ) butf (x2 , y2 ) = f (0.04, 0.961599) = (0.04 − 0.961599)/(0.04 + 0.961599)
= −0.9201
= 0.961599 + 0.02(−0.9201)
= 0.943197
Then,
y3 = y2 + h/2(f (x2 , y2 ) + f (x3 , y30 )), but f (x2 , y2 ) = −0.9201 and f (x3 , y30 ) = f (0.06, 0.943197)
= −0.88038
= 0.9435942
Exercise 3.2. Using the Modified Euler’s method solve y 0 = x + y with y(0) =
1 and h = 0.02.
dy
= f (x, y), y(x0 ) = y0
dx
a. First order runge-kutta method: The Euler’s method is the first order
Runge – kutta method. i.e.
72
called the second order Runge – kutta method. i.e.
h
f (x0 , y0 ) + f (x1 , y10 )
y1 = y0 + (3.15)
2
h
y1 = y0 + (k1 + k2 ) , (3.16)
2
Where
k1 = f (x0 , y0 ),
k2 = f (x1 , y10 )
1
y1 = y0 + (k1 + 4k2 + k3 ) , (3.17)
6
Where,
k1 = hf (x0 , y0 )
k1
k2 = hf (x0 + h2 , y0 + 2
)
k3 = f (x0 + h, y0 + k 0 ), k 0 = hf (x0 + h, y0 + k1 )
1
y1 = y0 + (k1 + 2k2 + 2k3 + k4 ) , (3.18)
6
Where,
k1 = hf (x0 , y0 )
h k1
k2 = hf (x0 + , y0 + )
2 2
h k2
k3 = hf (x0 + , y0 + )
2 2
k4 = hf (x0 + h, y0 + k3 )
73
The fourth order Runge-Kutta method is most commonly applied method
rather than other order methods, and it is given by the following general
formula:
1
yn+1 = yn + (k1 + 2k2 + 2k3 + k4 )
6
k1 = hf (xn , yn )
h k1
k2 = hf (xn + , yn + )
2 2
h k2
k3 = hf (xn + , yn + )
2 2
k4 = hf (xn + h, yn + k3 )
h = xn − xn−1 , xn = x0 + nh
Example. Using Runge – kutta 4th order method find the value of y for
dy (x − y)
x = 0.04 in step size of 0.02 for the equation = with y(0) = 0.1.
dx (x + y)
Solution .
1
The Runge – kutta 4th order method is yn+1 = yn + (k1 + 2k2 + 2k3 + k4 )
6
1
⇒ y1 = y0 + (k1 + 2k2 + 2k3 + k4 ),
6
Where;
h k2
k3 = hf (x0 + , y0 + ) = 0.02f (0 + 0.02/2, 1 − 0.0196/2) = −0.0196
2 2
k4 = hf (x0 + h, y0 + k3 ) = 0.02f (0 + 0.02, 1 − 0.0196) = −0.0192
74
1
⇒ y1 = 1 + (−0.02 + 2(−0.0196) + 2(−0.0196) + −0.0192)
6
= 1 + 1/6(−0.02 − 0.0392 − 0.0392 − 0.0192)
= 0.9804
1
y2 = y1 + (k1 + 2k2 + 2k3 + k4 ) ,
6
W here;
h k1
k2 = hf (x1 + , y1 + ) = 0.02f (0.02 + 0.02/2, 0.9804 − 0.0192/2) = −0.0188
2 2
h k2
k3 = hf (x1 + , y1 + ) = 0.02f (0.02 + 0.02/2, 0.9804 − 0.0188/2) = −0.0188
2 2
1
⇒ y2 = 0.9804 + (−0.0192 + 2(−0.0188) + 2(−0.0188) + −0.0184)
6
1
= 0.9804 + (−0.0192 − 0.0376 − 0.0376 − 0.0184)
6
= 0.9616
1
y3 = y2 + (k1 + 2k2 + 2k3 + k4 ) ,
6
W here;
h k1
k2 = hf (x2 + , y2 + ) = 0.02f (0.04 + 0.02/2, 0.9616 − 0.0184/2) = −0.018
2 2
75
h k2
k3 = hf (x2 + , y2 + ) = 0.02f (0.04 + 0.02/2, 0.9616 − 0.018/2) = −0.0178
2 2
1
⇒ y3 = 0.9616 + (−0.0184 + 2(−0.018) + 2(−0.0178) + −0.0176)
6
= 0.9616 + 1/6(−0.0184 − 0.036 − 0.0356 − 0.0176)
= 0.9437
Exercise 3.3. Compute y3 , y6 and y8 the following using Runge Kutta 4th or-
der method.
dy
a. = x + y 2 , y(0) = y0 = 1, h = 0.1
dx
dy
b. + y = 1, y(1) = y0 = 2, h = 0.1
dx
dy
c. = 1 + xy 3 , y(0) = 1, h = 0.1
dx
The methods those we discussed before are called one-step methods. Be-
cause the approximation for the mesh point xi+1 involves information from
any one of the previous mesh points xi . Although, these methods use for
function evaluation information at points between xi and xi+1 , they do not
retain information for discrete use in future approximation. All the infor-
mation used by these methods is obtained with in the sub-interval over
which the solution is being approximation. Methods using the approxi-
mation at more than one previous mesh points to determine the approxi-
76
mations at the next point are called Multi-step methods.
Definition 3.5. .
A Multi-step methods for solving the initial value problem:
y 0 = f (x, y) (3.19)
y(a) = α, , a ≤ x ≤ b (3.20)
has different equation for finding the approximation yi+1 at the mesh point
xi+1 represented by the following equation, where m > 1 is an integer.
yi+1 =am−1 yi + am−2 yi−1 + ... + a0 yi+1−m + h[bm f (xi+1 , yi+1 ) + bm−1 f (xi , yi )+, ...,
+ b0 f (xi+1−m , yi+1−m )]
(3.21)
(b − a)
for i = m−1, m, ..., N −1, where h = , the a0 , a1 , ..., am−1 and b0 , b1 , ..., bm−1
N
are constants and the starting values
y0 = α0 , y1 = α1 , ..., ym−1 = αm−1 are specified.
Note:
h
yi+1 = yi + [55f (xi , yi ) − 59f (xi−1 , yi−1 ) + 37f (xi−2 , yi−2 ) − 9f (xi−3 , yi−3 )]
24
(3.22)
77
Define an explicit four-step method known as the fourth order Adams-
Bashforth method
Whereas
h
yi+1 = yi + [9f (xi+1 , yi+1 ) + 19f (xi , yi ) − f (xi−1 , yi−1 ) + f (xi−2 , yi−2 )] (3.24)
24
y0 = α, y1 = α1 , and y2 = α2 , i = 2, 3, 4, 5, ..., N − 1 (3.25)
h
yi+1 = yi + [3f (xi , yi ) − f (xi−1 , yi−1 )] (3.26)
2
y0 = α, y1 = α1 , i = 1, 2, 3, ..., N − 1 (3.27)
5 000
• Local truncation error, τi+1 (h) = 12
y (µi )h2 , for some µi ∈ (xi−1 , ti+1 )
h
yi+1 = yi + [23f (xi , yi ) − 16f (xi−1 , yi−1 ) + 5f (xi−2 , yi−2 )] (3.28)
12
y0 = α, y1 = α1 , y2 = α2 i = 2, 3, ..., N − 1 (3.29)
• Local truncation error, τi+1 (h) = 38 y (4) (µi )h3 , for some µi ∈ (xi−1 , ti+1 )
78
iii. Adams-Bashforth Four-Step Explicit Method
h
yi+1 = yi + [55f (xi , yi ) − 59f (xi−1 , yi−1 ) + 37f (xi−2 , yi−2 ) + 9f (xi−3 , yi−3 )]
24
(3.30)
y0 = α, y1 = α1 , y2 = α2 , y3 = α3 i = 3, 4, ..., N − 1 (3.31)
251 (5)
• Local truncation error, τi+1 (h) = 720
y (µi )h4 , for some µi ∈ (xi−1 , ti+1 )
h
yi+1 = yi + [1901f (xi , yi ) − 2774f (xi−1 , yi−1 ) + 2616f (xi−2 , yi−2 ) − 1274f (xi−3 , yi−3 )
720
+ 251f (xi−4 , yi−4 )]
(3.32)
y0 = α, y1 = α1 , y2 = α2 , y3 = α3 , y4 = α4 i = 4, 5, 6..., N − 1 (3.33)
95 (6)
• Local truncation error, τi+1 (h) = 288
y (µi )h5 , for some µi ∈ (xi−1 , ti+1 )
h
yi+1 = yi + [5f (xi+1 , yi+1 ) + 8f (xi , yi ) − f (xi−1 , yi−1 )] (3.34)
12
y0 = α, y1 = α1 , i = 1, 2, 3, ..., N − 1 (3.35)
−1 (4)
• Local truncation error, τi+1 (h) = 24
y (µi )h3 , for some µi ∈ (xi−1 , ti+1 )
79
ii. Adams-Moulton Three-Step Implicit Method
h
yi+1 = yi + [9f (xi+1 , yi+1 ) + 19f (xi , yi ) − 5f (xi−1 , yi−1 ) + f (xi−2 , yi−2 )]
24
(3.36)
y0 = α, y1 = α1 , y2 = α2 i = 2, 3, ..., N − 1 (3.37)
−19 (5)
• Local truncation error, τi+1 (h) = 720
y (µi )h4 , for some µi ∈ (xi−1 , ti+1 )
−3 (6)
• Local truncation error, τi+1 (h) = 160
y (µi )h5 , for some µi ∈ (xi−1 , ti+1 )
Note: Generally, the implicit method is more accurate than the explicit
method, but to apply the implicit method, we must solve the implicit equa-
tion for yi+1 . This is not always possible, and even when it can be done the
solution for yi+1 may not be unique.
Example 3.7. .
Solve the IVP
y 0 = y − x2 , 0 ≤ x ≤ 1, y(0) = 0.5
Solution 3.4. .
i. For the explicit four step Adams-Bashfourth method:
we have given y0 = 0.5 and to take the next three approximations, we use
Runge-Kutta fourth order method and we get; y1 = y(0.2) ≈ 0.8292933, y2 =
y(0.4) ≈ 1.2140762, y3 = y(0.6) ≈ 1.6489220 and we use these as starting values
Adams-Bashforth four step explicit method to compute the next approxima-
tions y4 = y(0.8) and y5 = y(1.0)
80
So,
h
y(0.8) = y4 = y3 + [55f (x3 , y3 ) − 59f (x2 , y2 ) + 37f (x1 , y1 ) + 9f (x0 , y0 )]
24
y0 = 0.5, y1 = 0.8292933, y2 = 1.2140762, y3 = 1.6489220
W here;
f (x, y) = y − x2 + 1
0.2
= 1.6489220 + [55f (0.6, 1.6489220) − 59f (0.4, 1.2140762) + 37f (0.2, 0.8292933)+
24
9f (0, 0.5)]
= 2.1272892
and
h
y(1.0) = y5 = y4 + [55f (x4 , y4 ) − 59f (x3 , y3 ) + 37f (x2 , y2 ) + 9f (x1 , y1 )]
24
y1 = 0.8292933, y2 = 1.2140762, y3 = 1.6489220, y4 = 2.1272892
0.2
= 2.1272892 + [55f (0.8, 2.1272892) − 59f (0.6, 1.6489220) + 37f (0.4, 1.2140762)+
24
9f (0.2, 0.8292933)]
= 2.6410533
The error for this approximation at x = 0.8 and x = 1.0 respectively are;
81
and to take the next two approximations, we use Runge-Kutta fourth order
method and we get; y1 = y(0.2) ≈ 0.8292933, y2 = y(0.4) ≈ 1.2140762, and we
use these as starting values Adams-Moulton three step implicit method to
compute the next approximations y3 = y(0.6) , y4 = y(0.8) and y5 = y(1.0)
So,
h
yi+1 = yi + [9f (xi+1 , yi+1 ) + 19f (xi , yi ) − 5f (xi−1 , yi−1 ) + f (xi−2 , yi−2 )]
24
y0 = α, y1 = α1 , y2 = α2 i = 2, 3, ..., N − 1
1
1.8yi+1 27.8yi − yi−1 + 0.2yi−2 − 0.192i2 − 0.192i + 4.736
yi+1 =
24
1
+27.8yi − yi−1 + 0.2yi−2 − 0.192i2 − 0.192i + 4.736 , i = 2, 3, ...
yi+1 =
22.2
1
27.8y2 − y1 + 0.2y0 − 0.192(2)2 − 0.192(2) + 4.736
⇒ y3 =
22.2
1
27.8(1.2140762) − 0.8292933 + 0.2(0.5) − 0.192(2)2 − 0.192(2) + 4.736
y(0.6) ≈ y3 =
22.2
1.6489341
Similarly we‘compute
82
3.1.6 Higher Order Equations and Systems
Definition 3.6. Differential equations more than order one are said to be
higher order differential equations.
Definition 3.7. .
An mth system of first order initial value problem has of the form:
du1
= f1 (x, y1 , y2 , ...ym ) (3.38)
dx
du2
= f2 (x, y1 , y2 , ...ym ) (3.39)
dx
du3
= f3 (x, y1 , y2 , ...ym ) (3.40)
dx
..
. (3.41)
dum
= fm (x, y1 , y2 , ...ym ) (3.42)
dx
the objective is to find m functions y1 (x),y2 (x),..., ym (x) that satisfy each of
the differential equations together with the initial conditions.
Definition 3.8. .
83
A general mth order IVP is:
Solution 3.5. .
Since the given IVP is of second order let use two function representations
u(x) and v(x) to reduce systems of first order IVPs.
So, Let
u(x) = y(x) du
dx
= y 0 (x) = v(x)
⇒
v(x) = y 0 (x) dv
= y 00 (x) = e2x sinx + 2v(x) − 2u(x)
dx
x0 = 0, x1 = 0.1, x2 = 0.2
84
Even if, many methods are appropriate to solve the above method, for sim-
plicity let use Euler’s method separately, we have;
u1 = u0 + hv0 u1 = −0.4 + 0.1(−0.6) = −0.46
v = h(e2x0 sinx + 2v − 2u v = 0.1(e2(0) sin(0) + 2(−0.6) − 2(−0.4) = −0.64
1 0 0 0 1
u2 = u1 + hv1 u2 = −0.46 + 0.1(−0.64) = −0.524
v = h(e2x1 sinx + 2v − 2u v = 0.1(e2(0.1) sin(0.1) + 2(−0.64) − 2(−0.46) = −0.6401
2 1 1 1 2
85
Self check exercise 3.1. .
1. solve
dy
= x + y, y(1) = 0
dx
2. solve
dy
= 1 − y, y(0) = 0
dx
i. Euler’s method
ii. Runge-Kutta fourth order method.
86
3.2 Boundary Value Problems
Objectives
Solve
dy 2 dy
2
= f (x, y, ), a ≤ x ≤ b, y(a) = α, y(b) = β (3.48)
dx dx
In equation given above (3.50), y(a) = α and y(b) = β are called boundary
conditions.
87
Existance and Uniquness of Solution
dy 2 dy
= f (x, y, ), a ≤ x ≤ b, y(a) = α, y(b) = β
dx2 dx
, then show that whether the given BVP has unique solution or not.
Proof 3.1. .
Rewrite the given differential equation as:
88
Thus, clearly fy and fy0 are continuous on;
So, by theorem (3.1) we conclude that the given BVP in (3.4) has a unique
solution.
Under what condition(s) the given linear BVP has unique solution?
Solution 3.6.
Now, fy and fy0 are continuous on D if p(x), q(x) and r(x) are continuous on
a ≤ x ≤ b. Again,
ii.|fy0 (x, y, )| ≤ M
(since fy0 is continuous on [a, b], then fy0 is bounded) So, if p(x), q(x) and r(x)
are continuous for a ≤ x ≤ b and q(x) > 0 for a ≤ x ≤ b, then by theorem (3.1)
the given linear BVP in (3.5) has unique solution.
In this lecture note we will see shooting method and finite difference
method to solve BVPs.
89
Shooting Method
The shooting method uses the methods used in solving initial value prob-
lems. This is done by assuming initial values that would have been given if
the ordinary differential equation were a initial value problem. The bound-
ary value obtained is compared with the actual boundary value. Using
trial and error or some scientific approach, one tries to get as close to the
boundary value as possible. As the name suggest shooting means shoot
to reach the target point as close as possible.
The linear shooting method for linear equations is based on the replace-
ment of the linear BVP by IVP . To formulate this consider the following
linear BVP of the form:
Where, p(x), q(x) and r(x) are continuous for a ≤ x ≤ b and q(x) > 0 for
a≤x≤b
Now, to solve this BVP, we convert (3.53) to IVP and apply initial conditions
for y and y 0 gives;
Now, ourtarget is "Does the the IVP in (3.54) satisfy y(b) = β ? "
y 00 + p(x)y 0 + q(x)y = r(x), a ≤ x ≤ b
So, BVP:
y(a) = α, y(b) = β
0
When we write this BVP as system by letting y = z, we get:
y 0 = z, y(a) = α
IVP: Here, this system of IVP
z 0 = r − pz − qy z(a) = y 0 (a) =? say δ
can be solved using one of the favorite IVP technique like, Euler’s Method,
90
Runge-Kutta method, Multi-step Method, Taylor’s Series Method, ...
To satisfy our target let us compare y(b; δ) − β.
If |y(b; δ) − β| < , then our target satisfied and we solved the BVP. But to
choose an appropriate value of δ that satisfy our target let us consider a
function
After solving IVP1 and IVP2 to get y(b, δ0 ) and y(b, δ1 and then compare
|y(b, δ0 ) − β| < and |y(b, δ1 ) − β| < , where φ(δ0 ) = y(b, δ0 ) − β and
φ(δ1 ) = y(b, δ1 ) − β
In particular, let us use secant method for two initial guess δ0 and δ1 for
the function φ(δ).
(δn − δn − 1)
δn+1 = δn − φ(δn ) (3.54)
φ(δn ) − φ(δn−1 )
So,
(δ1 − δ0)
δ2 = δ1 − φ(δ1 ) (3.55)
φ(δ1 ) − φ(δ0 )
Again, formulate
y 00 + py 0 + qy = r, y(a) = α
IVP3:
y(a) = α, z(a) = y 0 (a) = δ
2
For y(b, δ2 ), we check if |y(b, δ2 ) − β| < . If yes, then the BVP is solved. If
no, then refine δ by computing δ3 , δ4 , δ5 , e.t.e. for Secant Method.
91
Example 3.11. Given the BVP:
1
y 00 = 6y 2 − x, y(0) = 1, y(1) = 5, h = (3.56)
3
Solution 3.7. .
We formulate two IVPs by choosing two initial guesses δ0 = 1.2 and δ1 = 1.5
1
IV P 1 : y 00 = 6y 2 − x, y(0) = 1, y 0 (0) = 1.2, h =
3
1
IV P 2 : y 00 = 6y 2 − x, y(0) = 1, y 0 (0) = 1.5, h =
3
NB: To solve these two IVPs, we can use Euler’s Method for simplicity of
calculation!!!
y 0 = z, y(0) = 1
so for IVP1: y 00 = 6y 2 − x ⇒
z 0 = 6y 2 − x z(0) = y 0 (0) = 1.2
Here, x0 = 1, x1 = 1/3, x2 = 2/3, x3 = 1
Now, by Euler’s Method the formula is:
yn+1 = yn + hzn
zn+1 = zn + h(6yn2 − xn )
1
y1 = y0 + hz0 ⇒ 1 + (1.2) = 1.4
3
z1 = z0 + h(6y02 − x0 ) ⇒ 1.2 + 13 (6(1) − 0) = 3.2
1
y2 = y1 + hz1 ⇒ 1.4 + (3.2) = 2.466
3
1 1
z2 = z1 + h(6y1 − x1 ) ⇒ 3.2 + (6(1.4)2 − ) = 7.01
2
3 3
1
y3 = y2 + hz2 ⇒ 2.466 + (7.01) = 4.7966 = y(1, 1.2) = y(b, δ0 )
3
y 0 = z, y(0) = 1
z 0 = 6y 2 − x z(0) = y 0 (0) = 1.5
92
Similar computations with IVP1 gives the following :
y1 = 1.5, z1 = 3.5
y2 = 2.666, z2 = 7.89
So, φ(δ0 ) = |y(b; δ0 | = 4.7966 and |y(1; 1.2) − 5| = |4.7966 − 5| = 0.2034 <
(δn − δn − 1)
δn+1 = δn − φ(δn ), n = 1, 2, 3, 4, ..., N
φ(δn ) − φ(δn−1 )
(δ1 − δ0 )
δ2 = δ1 − φ(δ1 )
φ(δ1 ) − φ(δ0 )
(δ1 − δ0 )
δ2 = δ1 − (y(1; 1.5) − 5)
y(1; 1.5) − 5 − (y(1; 1.2) − 5)
(1.5 − 1.2)
δ2 = 1.5 − (0.29) = 1.32
5.29 − 4.7966
Now, using
δ2 , we formulate IVP3 and solve;
y 0 = z, y(0) = 1
IVP3:
z 0 = 6y 2 − x z(0) = y 0 (0) = 1.32 = δ
2
y1 = 1.44, z1 = 3.32
y2 = 2.57, z2 = 7.3672
So, φ(δ2 ) = |y(b; δ2 | = 4.965 and |y(1, 1.32) − 5| = |4.965 − 5| = 0.035 <
93
Again, compute δ3 using,
(δ2 − δ1)
δ3 = δ2 − φ(δ2 )
φ(δ2 ) − φ(δ1 )
(1.32 − 1.5)
δ3 = 1.32 − (0.035) = 1.300
4.965 − 5.29
y1 = 1.426, z1 = 3.28
y2 = 2.519, z2 = 7.2369
So, φ(δ3 ) = |y(b; δ3 − 5| = 4.933 and |y(1; 1.28) − 5| = |4.933 − 5| = 0.06 <
Now, one can compute δ4 , δ5 , δ6 , e.t.c. to take better approximation of the BVP.
Definition 3.10. A given BVP which is not linear in the dependent variable
of the given DE is called is called non-linear BVP.
94
3.2.3 Finite Difference Method for Linear Problems
1 2 00
y(x + h) = y(x) + hy 0 (x) + h y (x)+, ..., + (3.57)
2!
y(x + h) − y(x) 1 00
⇒ y 0 (x) ≈ − y (ξ) (3.58)
h 2
Now,
yi+1 − yi
yi0 = + O(h), i = 1, 2, 3, ...n (3.59)
h
1 2 00
y(x − h) = y(x) − hy 0 (x) + h y (x)−, ..., + (3.60)
2!
y(x) − y(x − h) 1 00
⇒ y 0 (x) ≈ + y (ξ) (3.61)
h 2
Now,
95
Then, (3.63), becomes
yi+1 − yi
yi0 = + O(h), i = 1, 2, 3, ...n (3.62)
h
Thus, (3.64) is called Euler’s Back ward Approximation for first derivative.
Again,
1 2 00
y(x + h) = y(x) + hy 0 (x) + h y (x)+, ..., + (3.63)
2!
1
y(x − h) = y(x) − hy 0 (x) + h2 y 00 (x)−, ..., + (3.64)
2!
y(x + h) − y(x − h)
y 0 (x) ≈ + O(h) (3.65)
2h
yi+1 − yi−1
yi0 = + O(h), i = 1, 2, 3, ...n (3.66)
2h
96
now, to solve (3.71) using FDM, we implement three steps:
If we take :
AY=b (3.70)
Where, A=
97
1 h2 q(x) − hp(x) − 2 1 + hp(x) 0 0 0
0 1 h2 q(x) − hp(x) − 2 1 + hp(x) 0 0
..
h2 q(x) − hp(x) − 2
0 0 1 . 0
.. .. ..
. . . 1 h2 q(x) − hp(x) − 2 1 + hp(x)
y r(x )
0 1
y1 r(x2 )
Y= y2 b=h2 r(x3 )
.. ..
. .
yn r(xn )
y 00 − y = 0 (3.71)
Solution 3.9. We can be discretize as Given the interval [a, b] = [0, 3], and
xi = x0 + ih ⇒ x0 = 0, x1 = 1, x2 = 2, x3 = 3 such that y0 = y(x0 ) = y(0) =
0, y1 = y(x1 ) =?, y2 = y(x2 ) =?, y3 = y(x3 ) = y(3) = 3. To find the unknown
values y1 and y2 , using finite difference method, we approximate the given
DE, y 00 − y = 0, and we get;
98
Now, for two values of i in (3.77), we get the following system;
i = 1, y2 − 2y1 + y0 = h2 y1
i = 2, y3 − 2y2 + y1 = h2 y2
y2 − 3y1 = 0
−3y + y = −3
2 1
Now, solving this system using any one of appropriate direct method, we
get y1 = 0.375, and y2 = 0.75
Note: If we take the step size h, very small in the finite difference approx-
imation, then the approximation goes to the exact solution rapidly!!!
x
y 00 − (3 + )y = x
2
y(1) = −2, y(3) = 1
99
Thus, when we rewrite equation (3.78) as discretize form as:
Now, to solve (3.79), we can use any appropriate approach like fixed point
iteration method, Newton’s-Raphson Method, e.t.c.
Solution 3.10. .
Given that h = 1, a ≤ x ≤ b ⇒ x0 = −1, x1 = 0, x2 = 1, x3 = 2, x4 = 3
Here, y(x0 ) = y(−1) = y0 = 2 and y(x4 ) = y(3) = y4 = −1 are given as
boundary value. So we need to find y1 , y2 , y3 and
The discretize form of (3.81) is:
i = 1, ⇒ y2 − 2y1 + y0 = x1 y12 + x1
y2 − 2y1 + 2 = 0
i = 2, ⇒ y3 − 2y2 + y1 = x2 y22 + x2
y3 − 2y2 + y1 = 1.y22 + 1
y3 − 2y2 − y22 + y1 − 1 = 0
i = 3, ⇒ y4 − 2y3 + y2 = x3 y32 + x3
y4 − 2y3 + y2 = 2y32 + 2
−2y3 + y2 − 2y32 − 3 = 0
y2 − 2y1 + 2 = 0
Non-Linear System: y3 − 2y2 − y22 + y1 − 1 = 0
−2y3 + y2 − 2y32 − 3 = 0
Even if, we can use other techniques to solve this non-linear system, let us
100
use Newton’s-Raphson’s method to solve this system.
Now, consider:
F (Y) = F (y1 , y2 , y3 ) = [f1 (y1 , y2 , y3 ), f2 (y1 , y2 , y3 ), f3 (y1 , y2 , y3 )] Where,
f1 (y1 , y2 , y3 ) = y2 − 2y1 + 2
Now, we form a matrix called Jacobian matrix J(Y) from the system, F (y1 , y2 , y3 )
as:
−2 1 0
= 1 −2 − 2y2
1
0 1 −2 − 4y3
Now, let us take Y 0 = [0, 0, 0]t , then F (Y 0 )= F (y1 , y2 , y3 ) = [2, −1, −3]t
and
−2 1 0
J(Y 0 ) = 1 −2 1
0 1 −2
Now, we use,
101
And obtain a vector X0 as follow;
0.2500
X 0 = −1.5000
−2.2500
Again, use
k+1
Y =Y k+X k
(3.82)
Again,
= [ 0, −2.25, −10.125 ]t
and
−2 1 0 −2 1 0 −2 1 0
1 (1)
J(Y ) = 1 −2 − 2y2 = 1 −2 − 2(−1.5) =
1 1 1 1 1
(1)
0 1 −2 − 4y3 0 1 −2 − 4(−2.25) 0 1 7
102
Again;
−0.2961
X 1 = −0.5921
−1.3618
Again, use
Y 2 =Y 1+X 1 (3.84)
to solve Y 2 gives;
0.2500 −0.2961 −0.0461
Y 2 = Y 1 + X 1 = −1.5000 + −0.5921 ⇒ Y 2
−2.0921
−2.2500 −1.3618 −3.6118
103
Self check exercise 3.2. 1. Solve
x
y 00 − (3 + )y 2 = x
2
y(1) = −2, y(3) = 1
104
Unit Summary
dy
= f (x, y), y(x0 ) = y0
dx
105
Review Exercise 3
dy 1
= 2 , y(4) = 4,
dx x +1
dy −y
=
dx 1+x
3. Given
dy
= x2 + y, y(0) = 1
dx
, then evaluate y(0.02) and y(0.04) using Euler’s method with h = 0.01.
dy
= x − y 2 , y(0) = 1
dx
dy
= x + y, y(0) = 1
dx
6. Solve
and compute y2 .
106
7. Using non-linear shooting method solve
i. h = 0.5
ii. h = 0.25
References
107
108
4
Eigenvalue Problems (8 Hrs)
Objective
Introduction
Objectives
110
? Find the dominant eigenvector using power method.
AX = λX (4.1)
111
Such a vector X is called an eigen-vector of a matrix A corresponding to
λ.
2 3 2
Example 4.1. Show that is an eigen vector of A= correspond-
1 3 −2
ing to λ = 4.
AX − λX = 0 (4.2)
⇒ (A − Iλ)X = 0 (4.3)
112
polynomial of A and once the eigenvalues of a matrix A have been found,
we can find the eigenvectors.
Example Find the eigenvalues
and eigenvectors
of the matrix:
2 1
A =
1 2
Exercise 4.2. Find the eigen value and corresponding eigenvectors of ma-
trix
1 −3 3
A = 3 −5 3
6 −6 4
113
Theorem 4.1. If A is an n × n matrix, then the following are equivalent.
a. λ is an eigenvalue of A.
Note:
114
1 2 4 5
4 3 10
Given matrix A =
, then find
1 4 5 7
6 2 −1 −2
115
The eigenvector corresponding to λ1 is called dominant eigenvector.
Procedure
General Algorithm
Stopping Criteria
116
−0.3856
13
1
−0.3856
Now, λ1 =13 and X 1 = Again,
1
−2 −3 −0.3856 −2.2308
AX 1 = Y 2 ⇒ =
6 7 1 4.6923
Here, scaling the second element gives:
◦ Second iteration:
−0.4734
4.6923
1
−0.4734 −2 −3 −0.4734
Now, λ2 =4.6923 and X 2 = AX 2 = Y 3 ⇒
1 6 7 1
−2.0492
=
4.1475
Here, scaling the second element gives:
◦ Third iteration:
−0.4942
4.1475
1
−0.4942 −2 −3 −0.4942
Now, λ3 =4.1475 and X 3 = AX 3 = Y 4 ⇒
1 6 7 1
−2.0119
=
4.0356
Here, scaling the second element gives:
◦ Fourth iteration:
−0.4985
4.0356
1
117
−0.4985 −2 −3 −0.4985
Now, λ4 =4.0356 and X 4 = AX 4 = Y 5 ⇒
1 6 7 1
−2.0029
=
4.0088
Here, scaling the second element gives:
◦ Fith iteration:
−0.4996
4.0088
1
−0.4996
Now, λ5 = 4.0088 and X 5 =
1
−1
◦ |λ5 − λ4 | = 0.0268 < = 10
Hence, we obtain the approximate dominant eigenvalue of the given matrix
at the fifth iteration
and the eigenvalue is 4.0088 and the corresponding
−0.4996
eigenvector is λ =
1
118
Procedures
Generate a sequence of matrices
A1 , A2 , A3 , ...Am , Q1 , Q2 , Q3 , ...Qm , R1 , R2 , R3 , ...Rm such that:
1. Set A = A1 , Q = Q1 R = R1 so that A1 = Q1 R1 .
Stopping Criteria:
|λk − λ(k−1) |∞
|λk |∞
Note: To find the matrices Q and R in the QR factorization method we
must form a symmetric and orthogonal matrix P = I − 2V V T where
||V || = 1 by using a method called Householder method.
Procedures of Householder method
119
• This process continues
until wehave
a a ...a1n
11 12
a21 a22 ...a2n
Pn−1 Pn−2 ...P1 A =
.. .. .. such that ;
. . ....
an1 an2 ...ann
Pn−1 Pn−2 ...P1 A = R = QT A
⇒ Q = (Pn−1 Pn−2 ...P1 )T
pP
n
3. Set D = −Sign(dk ) i=k di
q
1 dk
4. Set V1 = 0, V2 = 0, ...Vk−1 = 0 and evaluate Vk = 2
1− D
and P =
dj
−DVk again compute Vj =
2P
120
0
0
..
.Vk
5. Write V as V =
Vk+1
..
.
Vm
6. Evaluate Pk = I − 2V V T
2 0.8944 d1
√ 1 = =
22 +12
1 −0.4472 d2
p p
2
D = −sign(d
s 1) d1 + d22 =s (0.8944)2 + (−0.4472)2 = −1
1 d1 1 0.8944
V1 = 1− = 1− = 0.9732
2 D 2 −1
P = −DV1 = 0.9732
d2 −0.4472
V2 = = = −0.2298
2P 2(0.9732)
V1 0.9732
Now, V = =
V2 −0.2298
T
1 0 0.9732 h i
Now, P1 = I − 2V V = -2 0.9732 −0.2298
0 1 −0.2298
121
−0.8944 0.4472 −2.2360 1.7888
= P1 A = = R1 and
0.4472 0.8944 0 1.3416
−0.8944 0.4472
P1 = QT1 ⇒ Q1 = P1T =
0.4472 0.8944
So, the QR factorization
of A is :
−0.8944 0.4472 −2.2360 1.7888
A=QR= (Verify!!!)
0.4472 0.8944 0 1.3416
Now, after factorizing A=QR by householder transformation, we use QR
method to find all eigenvalues.
Taking A = A1 , Q = Q1 , R = R1
We have A1 = Q1 R1
2.7999 0.6000
A2 = R1 Q1 =
0.6000 1.2000
st
1 iteration:
2.7999
⇒ λ1 = factorizing A2 = R1 Q1 by householder transformation. To
1.2000
2.7999
do this generate P1 of A2 . Consider first column of A2 . i.e = and
0.6000
1 2.7999 0.9777 d
normalizing it gives: p = = 1
(2.7999)2 + (0.6000)2 0.6000 0.2095 d2
p p
2 2 2 2
D = −sign(d
s 1 ) d1 + d 2 = s(0.9777) + (0.2095) = −1.0220
1 d1 1 0.9777
V1 = 1− = 1− = 0.9944
2 D 2 −1.022
P = −DV1 = 0.9943
d2 0.2095
V2 = = = 0.1054
2P 2(0.9943)
V1 0.9944
Now, V = =
V2 0.1054
T
1 0 0.9944 h i
Now, P1 = I − 2V V = -2 0.9944 0.1054
0 1 0.1054
−0.9777 −0.2095 −2.863 −0.8380
= P1 A2 = = R2 and
−0.2095 0.9778 0 1.0476
−0.9777 −0.2095
P1 = QT2 ⇒ Q2 = P1T =
−0.2095 0.9778
122
So, the QR factorization
of A2 is :
2.9748 −0.2196
A2 = Q2 R2 ⇒ A3 = R2 Q2 = (Verify!!!)
−0.2196 1.0243
Now, after factorizing A2 = Q2 R2 by householder transformation, we use
QR method to find all eigenvalues.
2.9748 −0.2196
A3 = R2 Q2 =
−0.2195 1.0243
nd
2 iteration:
2.9748
⇒ λ2 = factorizing A2 3 = R2 Q2 by householder transformation. To
1.0243
2.9748
do this generate P1 of A3 . Consider first column of A3 . i.e = and
−0.2195
1 2.9748 0.1112
normalizing it gives: p = =
(2.9748) + (−0.2195)2 −0.2195
2
−0.1131
D = −1
V1 = 0.9993
P = −DV1 = −0.9993
−0.0368
V2 =
V1 0.9944
Now, V = =
V2 0.1054
−0.9913 0.0736 −2.9829 0.2944
Now, P1 = I − 2V V T = = P1 A3 = = R3
0.0736 0.9973 0 1.0044
and
−0.9973 −0.0736
P1 = QT3 ⇒ Q3 = P1T =
0.0736 0.9973
So, the QR factorization
of A3 is :
2.9965 0.0741
A3 = Q3 R3 ⇒ A4 = R3 Q3 = (Verify!!!)
−0.0741 1.0027
Now, after factorizing A3 = Q3 R3 by householder transformation, we use
QR method to find
all eigenvalues.
2.9965 0.0741
A4 = R3 Q3 =
−0.0741 1.0027
3rd iteration:
123
2.9965
⇒ λ3 = Now,
1.0027
λ3 − λ2
| | = 0.0051 < = 10−2
λ3
124
Unit Summary
125
126
Review Exercises 4
1 −3 3
1. Find eigenvalues and eigenvectors of the matrix A = 3 −5 3 us-
6 −6 4
ing characteristics polynomial.
130
Answer for Review Exercises
2. f (0.005) = 1.0097
3. y(0.35) = 2.0218
8. Yes.
1. i. 0.8747
ii. 0.8761
iii. 1.0415
Answer for Review Exercise 1
1. sin500 = 0, 76604
2. f (3) = 20.267296
3. sin850 = 0, 966
5. 22.0948
6. f (5)=75
7. 1.751.
8. 0.82212.
9. 0.0911
10. 1.8279
1. y = −1.6071x + 8.6429
2. y = 0.7x + 2.6
2. p(x) = 0.9984x
132
Answer for Review Exercise 2
1. y = 0.72 + 1.33x
2. y = 6.24 + 1.45x
3. y = 3.3 + 1.45x
6. − 21 + 35 x
7. y = 0.5012x1.9977
8. y = 9986x1.2
9. y = (1.3268).(2.9485x )
10. y = (701.94).x−0.1708
1. 4.0098
133
2. 1.2632
4. 0.851, 0.780
5. 1.1103, 1.2428
6. -0.524
1. λ1 = 4, λ2 = −2,
λ3 = −2 and eigenvector corresponding to
λ1 = 4 is
−0.4082 −0.8103
X = −0.4082 and corresponding to λ2 = λ3 = −2 is X = −0.3185
−0.8165 0.4918
2. The
dominant
eigenvalue λ = 2.9999 and corresponding eigenvector
0.5
X = 0.5
1.00
3. The
dominant eigenvalue λ = 2.9999 and corresponding eigenvector
0.833
X=
1.00
−2.673 −0.7715 0.5774
4. A = QR , where Q = 0.5344 −0.6173 −0.5774 and
0.8018 0.1543 0.5773
3.7417 1.8706 −2.6726
R = −0.0003 −3.2405 −1.2342
−0.0002 0 2.3095
5. λ1 = 2, λ2 = −1,.
134
6. λ1 = 5, λ2 = 1, λ3 = −1.
135