Module On Numerical Analysis II
Module On Numerical Analysis II
December, 2013EC
Table of Contents
Introduction......................................................................................................................................3
Chapter1...........................................................................................................................................4
Introduction......................................................................................................................................4
1.1 Finite Difference........................................................................................................................5
1.2 Forward Differences..................................................................................................................5
1.4 Backward Differences...............................................................................................................7
1.6 Interpolation with Equally Spaced points................................................................................10
1.6.1 Newton’s Forward Interpolation Formula........................................................................10
1.7 Interpolation with Unequally spaced point..........................................................................16
1.7.1 Lagrange’s Interpolation Formula....................................................................................16
Newton’s General Interpolation Formula with Divided Difference..........................................20
Chapter 2: Revision on Numerical Integration..............................................................................27
2.1 Numerical Integration..........................................................................................................27
2.1.1. Newton-Cotes Quadrature Formula.................................................................................28
2.1.2. The Trapezoidal Rule.......................................................................................................28
2.1.2. The Simpson’s 1/3-Rules.................................................................................................30
Numerical solutions of ODE...........................................................................................................5
Taylor series method........................................................................................................................6
Euler method....................................................................................................................................8
Modified Euler method..................................................................................................................10
Introduction
Unlike other terms denoting mathematical disciplines, such as calculus or linear algebra the exact
extent of the discipline called numerical analysis is not yet clearly defined. By numerical
analysis, we mean the theory of constructive methods in mathematical analysis. By constructive
method we mean a procedure that permits us to obtain the solution of a mathematical problem
with an arbitrary precision in a finite number of steps that can be prepared rationally (the number
of steps depend on the desired accuracy).
Numerical analysis is both a science and an art. As a science, it is concerned with the process by
which a mathematical problem can be solved by the operations of arithmetic. As an art,
numerical analysis is concerned with choosing the procedure which is best suited to the solution
of a particular problem. In general numerical analysis is the study of appropriate algorithms for
solving problems of mathematical analysis by means of arithmetic calculations.
The analytic methods have certain limitations in practical applications. So in most cases exact
solution is not possible from applied mathematics. In such cases the numerical methods are very
important tools to provide practical method for calculating the solutions of problems to a desired
degree of accuracy. The use of high-speed digital computers for solving problems in the field of
engineering design and scientific research increased the demand for numerical methods.
The problems that are impossible to solve by classical methods or that are too formidable for a
solution by manual computation can be resolved in a minimum of time using digital computers.
So it is essential for the modern man to be familiar with the numerical methods used in
programming problems using the computers.
The computer however is only as useful as the numerical methods employed. If the method is
inherently inefficient, the computer solution is worthless, no matter how efficiently the method is
organized and programmed. On the other hand, an accurate, efficient numerical method will
produce poor results if inefficiently organized or poorly programmed. The proper utilization of
the computer to solve scientific problems requires the development of a program on numerical
method suitable to the problem.
Chapter1
Introduction
Given the set of tabular values ( x 0 , y 0 ) , ( x 1 , y 1 ) , ( x 2 , y 2 ) , … , ( xn , y n ) satisfying the relation y=f (x )
Where the explicit nature of f (x) is not known, it is required to find a simpler 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 trigonometric function, exponential functions, etc.
Numerical interpolation approximates functions and we approximate functions for one or several
of the following reasons:
A large number of important mathematical functions may only be known through tables
of their values.
Some function may be known to exist but are computationally too complex to manipulate
numerically.
Some function may be known but the solution of the problem in which they appear may
not have an obvious mathematical expression to work with.
Some of the methods of interpolation that will be considered in this unit include Newton’s
Forward and Backward difference interpolation formulae, Newton’s divided difference
interpolation formula and the Lagrangian interpolation.
∆ y 0 = y 1− y 0 , ∆ y 1= y 2− y 1 , …, ∆ y n−1= y n− y n−1
Where ∆ is called the forward difference operator and ∆ y 0 , ∆ y 1 , ∆ y 2 , … are called first ordered
forward differences. The differences of first ordered forward differences are called second
2 2 2
ordered forward differences and are denoted by ∆ y 0 , ∆ y 1 , ∆ y 2 , … . Similarly, one can defined
3rd , 4th , …, nth order forward differences.
∆ 2 y 0 =∆ y 1−∆ y 0= y 2−2 y 1+ y 0
3 2 2
∆ y 0 =∆ y 1−∆ y 0 = y 3−3 y 2+ 3 y1 − y 0
⋮ = ⋮ = ⋮
x y=f (x ) ∆ ∆
2
∆
3
∆
4
∆
5
∆ y0
∆ y1
2
∆ y2 ∆ y0
3
∆ y3 ∆ y0
4
∆ y4 ∆ y1
2 ∆ y0
5
∆ 3 y1 ∆ y0
4
∆ y2
2 ∆ y1
3
∆ y3
2 ∆ y2
Example
x y=f (x ) ∆ ∆2 ∆3 ∆4 ∆5
0 3
9
1 12 60
69 -10
2 81 50 −259
119 -269 755
3 200 −219 496
-100 227
4 100 8
-92
5 8
Where ∇ is called the backward difference operator. In a similar way, one can define backward
differences of higher orders. Thus we obtain:
∇ 2 y 2 =∇ y 2−∇ y 1= y 2−2 y 1 + y 0
3 2 2
∇ y3 =∇ y 3−∇ y 2= y 3−3 y 2 +3 y 1− y 0
∇ 4 y 4 =∇ 3 y 4 −∇ 3 y3 = y 4 −4 y 3 +6 y 2−4 y 1 + y 0
⋮ = ⋮ = ⋮
x y=f (x ) ∇ ∇
2
∇
3
∇
4
∇
5
x0 y0
∇ y1
2
x1 y1 ∇ y2
3
∇ y2 ∇ y3
x2 y2 2
∇ y3
4
∇ y4
∇ y3 3
∇ y4 ∇ y5
5
x3 y3 2
∇ y4
4
∇ y5
∇ y4 3
∇ y5
x4 y4 2
∇ y5
∇ y5
x5 y5
Example
x 10 20 30 40 50
The operator E is called shift operator or displacement or translation operator. It shows the
operation of increasing the argument value x by its interval of differencing h so that:
Similarly, E2 f ( x +h )=f (x +2 h)
En f ( x )=f ( x+nh ) , En y x = y x+ nh
y ( x 0 )= y 0 , y ( x 1 ) = y 1 , … , y ( xn ) = y n
y ( x ) =a0 + a1 ( x−x 0 ) + a2 ( x−x 0 )( x −x1 ) + a3 ( x−x 0 )( x −x1 ) ( x−x 2 ) +…+ an ( x−x 0 )( x−x1 ) … ( x−x n−1 )
………………………..(*)
y ( x 1) =a 0+ a1 ( x1−x 0 )
⟹ y 1= y 0 +a1 ( h )
y 1− y 0
⟹ a1=
h
∆ y0
⟹ a1=
h
2 3 n
∆ y0 ∆ y0 ∆ y0
In a similar manner we get a 2= 2
, a3 = 3
,…,a n= n
2h 3 !h n! h
2 3 n
∆ y0 ∆ y0 ∆ y0 ∆ y0
y ( x) = y0 +
h
( x−x 0 ) + 2 (
x−x 0 ) ( x−x 1 ) + 3 (
x−x 0 ) ( x−x 1 ) ( x−x 2 ) +…+a n= n (
x−x 0 ) ( x−x 1 ) … ( x−x n−
2h 3! h n!h
x−x 0
Hence let P=
h
2 3
P ( P−1 ) P ( P−1 ) ( P−2 ) P ( P−1 )( P−2 ) ...(P−n+1) n
y ( x) = y0 + P ∆ y0 + ∆ y 0+ ∆ y 0+ …+ ∆ y0
2! 3! n!
Example
1
a. Construct the difference table for f ( x )= , x ∈ [ 2,2.5 ] ∧h=0.1
x
b. Using NFIF Find i. f ( 2.25 ) ii. f ( 2.35 )
Solution
a.
x y=f (x ) ∆ ∆
2
∆
3
∆
4
∆
5
2 0.5
-0.024
-0.021 -0.002
-0.018 -0.001
-0.017
2. 0.400
x−x 0 2.25−2.2
b i . P= for h=0.1 , x=2.25∧x 0=2.2 ⟹ P= =0.5
h 0.1
y ( 2.25 ) ≅ 0.4446875
1
The exact value is y ( 2.25 )= =0.44444 … .
2.25
Example
Find the 4th degree polynomial which takes the following values
x 0 2 4 6 8 10
y 1 2 1 10 9 ?
Solution
x−0 x
P= =
2 2
4
65 2 5 3 x
y ( x ) =1+ 7 x− x+ x−
12 4 12
Example
From the table estimate the number of students who obtained marks b/n 40 and 45.
Solution
x yx ∆ yx ∆ yx
2 3
∆ yx
4
∆ yx
40 31
42
50 73 9
51 -25
60 124 -16 37
35 12
70 159 -4
31
80 190
We shall find y 45 that is number of students with mark less than 45.
x−x 0 5
Taking x 0=40 , x=45 we have p= = =0.5
h 10
y 45=47.87
To interpolate a value of f ( x) near to the end of the tabular values we use the following
polynomial
y ( x ) =a0 + a1 ( x−x n ) + a2 ( x−x n) ( x− xn−1 ) + a3 ( x −xn ) ( x−x n−1 ) ( x−x n−2 ) +…+ an ( x−x n )( x− xn−1 ) … ( x−x 1 )
……………….(**)
y ( x n−1) =a 0+ a1 ( xn −1−x n )
⟹ y n−1= y n +a1 ( h )
y n−1− y n y n− y n−1
⟹ a1= =
x n−1−x n x n−x n−1
∇ yn
⟹ a1=
h
∇2 y n ∇3 y n ∇n yn
In a similar manner we get a 2= , a3 = ,…,a n=
2h 2 3 !h3 n ! hn
x−x n
Let P=
h
Example
Population, y 46 66 81 93 101
(in thousands)
Solution
x y=f (x ) ∇ ∇2 ∇3 ∇4
1891 46
∇ y 1 =20
1901 66 2
∇ y 2 =-5
3
∇ y 2 =15 ∇ y3 =2
1911 81 2 4
∇ y 4 =-3
∇ y 3 =-3
∇ y 3 =12 3
∇ y 4 =-1
1921 93 2
∇ y 4 =-4
∇ y 4 =8
1931 101
x−x n 1925−1931
P= = =−0.6
h 10
Exercise
1. The table below gives the value of tan x for 0.10 ≤ x ≤ 0.30
Find
a. tan0.12 b. tan0.26 c. tan0.5
2. Find the number of men getting wages b/n Rs.10 and Rs.15 from the following data:
Frequency 9 30 35 42
Pn ( x ) =A 0 ( x−x 1 )( x −x2 ) … ( x−x n ) + A1 ( x−x 0 ) ( x−x 2 ) … ( x−x n ) +…+ An ( x−x 0 ) ( x−x 1 ) … ( x−x n−1)
………………..( 1 )
Where A0 , A 1 , … , A nare constants to be determined.
y0
That is A0 =
( x 0 −x1 ) ( x 0−x 2 ) … ( x 0−x n )
y1
That is A1=
( x 1−x 0 ) ( x 1−x 2 ) … ( x 1−x n )
Similarly
yn
That is An =
( x n− x0 ) ( x n−x 2 ) … ( x n−x n−1 )
( x−x 1 ) ( x−x 2) … ( x− xn )
Pn ( x ) = y 0 +¿
( x 0 −x1 ) ( x 0−x 2 ) … ( x 0−x n )
This is called Lagrange’s interpolation formula and which can be written as a general form:
n
Pn ( x ) =∑ Li ( x ) f i
i=0
Where
( ) ( x−x 0 ) … ( x−x i−1 ) ( x−x i+1 ) … ( x−x n )
n
x−x j
Li ( x )= ∏ x i−x j
=¿ ¿ ,( i=0 , 1 , 2, … , n) are
j=0 , j ≠i ( xi −x 0 )( x i−x 1 ) … ( x i−x i−1 )( x i−x i +1) … ( x i−x n )
individually polynomials of degree n in x and are called the Lagrange’s interpolation
coefficients.
Note: Li ( x j )= {
1if i= j
0 if i ≠ j
Note: The Lagrange’s interpolation formula can also be used to split the given function into
partial fractions.
Dividing both sides of equation (2) by ( x−x 0 ) ( x−x 1 ) ( x−x 2 ) . … . ( x−x n ) we get
f (x ) y0 1
= . +
( x−x 0 ) ( x−x 1) ( x−x 2 ) . … . ( x −x n) ( x 0−x 1 ) ( x 0−x 2 ) . …. ( x 0−x n ) x−x 0
y1 1
.+…+ ¿
( x 1−x 0 )( x 1−x 2 ) . … . ( x 1−x n ) x−x 1
yn 1
.
( x n−x 0 )( xn −x 1) ( x n−x 2 ) . … . ( x n −xn −1 ) x−x n
Example
Use Lagrange’s method of interpolation to find the unique polynomial P( x ) of degree 2 such
that : P ( 1 )=1 , P ( 3 )=27 , P ( 4 )=64 .
Solution
1. The percentage of criminals for different age group is given below. Determine the
percentage number of criminals under 35 year using the Lagrange’s formula.
Age % No. of
criminals
Under25 year 52
Under30year 67.3
Answer 77.405
2
[hint tabulate the value of f ( x )=x + 6 x−1 for x=−1 , 1 , 4 , 6]
Solution
2 2
x +6 x−1 x + 6 x−1
=
( x −1 ) ( x −4 )( x−6 )
2
( x +1 ) ( x −1 )( x−4 ) ( x−6 )
2
x +6 x−1 y0 1 y1 1
= . + . +¿
( x+1 ) ( x−1 ) ( x −4 )( x−6 ) ( x 0−x 1 )( x 0 −x2 ) ( x 0−x 3 ) x−x 0 ( x 1−x 0 ) ( x1 −x2 ) ( x 1−x 3 ) x −x1
y2 1 y3 1
. + .
( x 2−x 0 )( x 2−x 1 ) ( x 2−x 3 ) x−x 2 ( x 3−x 0 ) ( x 3−x 1 ) ( x 3−x 2) x−x 3
x 2 +6 x−1
=
3 1
+
1 1
− ( ) ( ) ( ) ( )
13 1
+
71 1
( x+1 ) ( x−1 ) ( x −4 )( x−6 ) 3 5 x+1 5 x−1 10 x−4 70 x−6
This labor of recomputing the interpolation coefficients is saved by using Newton’s divided
differences interpolation formula.
Let the function y=f ( x ) take the values y 0 , y 1 , … , y n corresponding to the values x 0 , x 1 , … , x n
which are not equally spaced. The difference of the function values with respect to the difference
of the arguments is called divided differences.
y −y y −y y −y
[ x 0 , x 1 ]= x 1−x 0 , [ x 1 , x 2 ]= x 2−x 1 , … , [ xn −1 , xn ]= xn −x n−1 are called first order divided
1 0 2 1 n n−1
difference.
y n +1− y n y n− y n−1
( − )
[ x n , x n +1 ]−[ x n−1 , x n ] x n +1−x n x n−x n−1 is called the second order divided
[ x n−1 , x n , x n+1 ] = x n +1−x n−1
=
x n +1−x n−1
difference for the arguments x n−1 , x n , x n+1
In general the nth order divided differences for the arguments x 0 , x 1 , … , x n is given by
[ x 1 , x 2 , … , x n ]−[ x 0 , x 1 , … , x n−1 ]
[ x 0 , x 1 ,… , x n ]= x n−x 0
y− y
[ x , x 0 ]= x−x 0
0
⟹ y= y 0 + ( x−x 0 ) [ x , x 0 ] …………..( i )
[ x , x 0 ] −[ x 0 , x 1 ]
[ x , x 0 , x 1 ]= ⟹ [ x , x 0 ]=¿ [ x 0 , x 1 ] + ( x−x 1 ) [ x , x0 , x 1 ]
x−x 1
[ x , x 0 , x 1 ]−[ x 0 , x1 , x2 ]
[ x , x 0 , x 1 , x 2 ]= x−x 2
⟹ [ x , x 0 , x 1 ] =[ x 0 , x 1 , x 2 ] + ( x−x 2 ) [ x , x 0 , x 1 , x 2 ]
y0
x0 [ x0 , x1 ]
y1 [ x0 , x1 , x2 ]
x1 [ x1, x2 ] [ x 0 , x1 , x2 , x3 ]
y2 [ x1 , x2 , x3 ] [ x0 , x1 , x2 , x3 , x4 ]
x2 [ x2, x3 ] [ x1 , x2 , x3 , x4 ] [ x0 , x1 , x2 , x3 , x4 , x5]
y3 [ x2 , x3 , x4 ] [ x1 , x2 , x3 , x4 , x5 ]
x3 [ x 2 , x3 , x4 , x5 ]
[ x3 , x4 ]
y4 [ x 3 , x 4 , x5 ]
x4
[ x 4 , x5 ]
y5
x5
Example
Solution
1 3
31−3
=14
3−1
3 31 64−14
6−1
19−10
=10
223−31 10−1
=64
6−3
=1
6 223 1−1
=0
11−1
197−64
10−3
1011−223
27−19
10−6 =19
11−3
10 1011
=197
=1
332−197
11−6
1343−1011
11−10 =27
11 1343
=332
y= y 0+ ( x−x 0 ) [ x 0 , x1 ] + ( x−x 0 ) ( x−x 1 ) [ x0 , x 1 , x 2 ] + ( x−x 0 )( x −x1 ) ( x−x 2 ) [ x0 , x 1 , x 2 , x 3 ]
y=3+ ( x−1 ) 14 + ( x−1 ) ( x −3 ) 10+ ( x −1 )( x−3 )( x−6 ) 1+ ( x−1 ) ( x−3 ) ( x−6 ) ( x−10 ) 0
y ( 8 )=3+ ( 8−1 ) 14+ ( 8−1 ) ( 8−3 ) 10+ ( 8−1 ) ( 8−3 )( 8−6 ) 1=521
Exercise
From the following data estimate the number of persons having incomes b/n 2000 and 2500:
Solution
8.5
3.6 0.00000084
1 .5 0.000000208
0 . 65
4000 16000
y=6000+ ( x−500 ) 8.5+ ( x−500 ) ( x−1000 )(−0.00326 ) + ( x−500 ) ( x−1000 ) ( x −2000 ) 0.00000084
+¿ 0
y=6000+ ( 2500−500 ) 8.5+ ( 2500−500 ) (2500−1000 ) (−0.00326 ) + ( 2500−500 )( 2500−1000 ) ( 2500−2000 ) 0.0000
+¿ 0
y=6000+ ( 2000 ) 8.5+ ( 2000 )( 1500 )(−0.00326 )+ ( 2000 )( 1500 ) ( 500 ) 0.00000084+0
y 2500 =14480
That means the number of persons having income less than 2500 is 14675
The number of persons having income b/n 2000 and 2500 is 14675−13850=825
Chapter2: Revision on Numerical Integration
Chapter Objectives
After studying this chapter, you should be able to:
Drive the formula for numerical differentiation.
Find the derivatives of functions using a numerical method.
Drive a formula for the trapezoidal rule.
Set error bound for the trapezoidal rule.
Solve definite integrals using the trapezoidal rule.
Drive a formula for the Simpson’s rule.
Set error bound for the Simpson’s rule.
Solve definite integrals using the Simpson’s.
Let the interval of integration ( a , b ) be divided into n equal subintervals of width h= ( b−a
n )
so that x 0=a , x 1=x 0 +h , x 2=x 0+ 2h , … , x n=x 0 +nh=b.
b x0 +nh
x−x 0 1
Where P= ⟹ dP= dx ⟹ dx=hdP
h h
[ ]
b n
P ( P−1 ) 2 P ( P−1 )( P−2 ) 3
I =∫ f (x) dx=h ∫ y0 + P ∆ y0 + ∆ y0+ ∆ y 0 +… dP
a 0 2! 3!
[ ]
2 2 3
n n ( 2 n−3 ) n ( n−2 )
I =hn y 0 + ∆ y 0 + ∆ y0 + ∆ y 0 +…+up ¿ ( n+1 ) terms …( ii )
2 12 24
Area
Putting n=1 in equation ( ii ) and taking the curve y=f ( x ) through ( x 0 , y 0 )∧( x 1 , y 1 ) as a
polynomial of degree one so that differences of order higher than one vanish, we get:
x0 +h
∫
x0
( 1 h
) h
f ( x)dx=h y 0 + ∆ y 0 = ( 2 y 0 + ( y 1− y 0 ) )= ( y 1+ y 0 )
2 2 2
x0 +2 h x 0+3 h x 0+nh
h h h
∫ f (x ) dx= ( y 1 + y 2 ) , ∫ f (x )dx= ( y 2+ y 3 ) ,… , ∫ f ( x )dx= ( y n−1+ y n )
2 2 2
x 0 +h 0x +2 h x + ( n−1 ) h 0
b x0 +h x 0+2 h x 0 +3 h x 0 +nh
h h h h
¿ ( y 1 + y 0 ) + ( y 1+ y2 ) + ( y 2+ y 3 ) +…+ ( y n−1+ y n )
2 2 2 2
h
¿ [ ( y + y )+ 2 { y1 + y 2 + y 3 +…+ y n−1 } ]
2 0 n
Which is known as Trapezoidal rule?
( )
x0 +2 h
1 2 2h h
∫ f ( x ) dx=2 h y 0 +∆ y 0 + ∆ y 0 = [ 6 y 0 +6 ( y 1− y 0 ) + ( y 2−2 y 1− y 0 ) ]= ( y 0 +4 y 1+ y 2 )
6 6 3
x0
( )
x0 +4 h
1 2 h
Similarly ∫ f ( x ) dx=2 h y 2 + ∆ y 2 + ∆ y 2 = ( y 2 +4 y 3+ y 4 ) , … ,
x +2 h 0
6 3
( )
x 0+nh 2
1 h
∫ f (x )dx=2h y n−2+ ∆ y n−2 + 6 ∆ y n−2 = 3 ( y n−2 + 4 y n−1+ y n )
x + ( n−2) h
0
b
h
I =∫ f ( x ) dx ≅
3[ 0
y +4 ( y 1+ y 3+ …+ y n−1 ) +2 ( y 2+ y 4 +…+ y n −2 ) + y n ]
a
Note: To use Simpson’s one-third rule, the given interval of integration must be divided in to an
even number of subintervals.
( )
x0 +3 h
3 3 2 1 3
∫ f ( x ) dx=3 h y 0 + ∆ y + ∆ y 0+ ∆ y 0
2 0 4 8
x0
3h
¿
8
[ 8 y 0 +12 ( y 1− y 0 ) +6 ( y 2−2 y 1 + y 0 ) +( y 3−3 y 2+ 3 y1 − y 0 ) ]
3h
¿
8 0
( y +3 y 1 +3 y 2+ y3 )
Similarly
x0 +6 h x0 +nh
3h 3h
∫ f ( x) dx= 8 ( y 3 +3 y 4 +3 y 5 + y 6 ) , … , ∫ f ( x)dx= 8 ( y n−3 +3 y n−2 +3 y n−1+ y n )
x +3 h
0 x + ( n−3) h 0
Adding the above integrals, we get:
b
3h
I =∫ f ( x ) dx ≅
8 [ 0 n
( y + y ) +3 ( y 1 + y 2 + y 4 + y 5 …+ y n−2 + y n−1 ) +2 ( y 3+ y 6 +…+ y n−3 ) ]
a
Note : To use Simpson’s three-eight rule, the given interval of integration must be divided in
to subintervals whose number n is a multiple of 3.
1.2.5. Boole’s-Rules
b
2h
I =∫ f ( x ) dx ≅
45 [
7 ( y 0+ y n ) +32 ( y 1+ y 3 …+ y 2 n−1 ) +12 ( y 2+ y 6 +…+ y 4 n−2) +14 ( y 4 + y 8 + …+ y 4 n ) ]
a
1.2.6. Weddle’s-Rules
b
3h
I =∫ f ( x ) dx ≅ [ y + 5 y 1 + y 2 +6 y 3 + y 4 +5 y 5 +2 y 6 +5 y 7+ y 8 ]
a 10 0
Example
6
dx
Evaluate ∫ 2 by using
0 1+ x
a. Trapezoidal rule
b. Simpson’s 1/3 rule
c. Simpson’s 3/8 rule
d. Boole’s rule
e. Weddle’s rule
Solution
1
Divide the interval( 0,6 ) in to six parts each of widthh=1. The value of f ( x )= 2 are
1+ x
f ( 0 )=1 , f ( 1 )=0.5 , f ( 2 )=0.2, f ( 3 )=0.1 , f ( 4 )=0.0588 , f ( 5 ) =0.0385∧f ( 6 )=0.027
a. By Trapezoidal rule
6
h
∫ 1+dxx 2 = 2 [ y 0 +2 ( y 1 + y 2 + y 3 + y 4 + y 5 ) + y 6 ]
0
1
¿
2
[ 1+ 2 ( 0.5+ 0.2+ 0.1+0.0588+0.0385 ) +0.027 ]
¿ 1.4108
Or in matlab
>> x=0:1:6;
>> y=1./(1+x.^2);
>> I=trapz(x,y)
I =1.4108
∫ 1+dxx 2 = h3 [ y 0 +4 ( y 1+ y3 + y 5 ) + 2 ( y 2 + y 4 ) + y 6 ]
0
1
¿
3
[ 1+4 ( 0.5+0.1+0.0385 ) +2 ( 0.2+0.0588 ) +0.027 ] =1.3662
c. By Simpson’s 3/8 rule
6
∫ 1+dxx 2 = 38h [ ( y 0 + y 6 ) +3 ( y 1 + y 2+ y 4 + y 5 ) +2 ( y 3 ) ]
0
3
¿
8
[ ( 1+0.027 ) +3 ( 0.5+ 0.2+ 0.0588+0.0385 ) +2 ( 0.1 ) ]=1.3571
d. By Boole’s rule
6
2
¿
45
[7 ( 1+0.027 )+ 32 ( 0.5+ 0.1+ 0.0385 )+ 12 ( 0.2 ) +14 ( 0.588 ) ]
e. By Weddle’s rule
6
3
¿
10
[ 1+5 ( 0.5 ) +0.2+6 ( 0.1 ) +0.0588+5 ( 0.0385 ) +2 ( 0.027 ) ]
¿ 1.3735
a. Numerical double integration
d b
in x and y directions considering one variable at a time. Repeated application of trapezoidal rule
(or Simpson’s rule) yields formula for I .
1. Trapezoidal rule: Dividing the interval (a , b) into n equal sub-intervals each of length h ,
and the interval (c , d) into m equal sub intervals each of length k , we have:
x i=x 0 +ih , x 0=a , x n=b
y j= y 0 + jk , y 0=c , y m=d
Using trapezoidal rule in both directions, we get
d
h
[ ]
I = ∫ f ( x 0 , y ) + f ( x n , y ) +2 { f ( x1 , y ) + f ( x 2 , y )+ …+ f ( x n−1 , y ) } dy
2c
hk
¿ ¿
4
Where f ij =f (x i , y i)
The computational molecule of the method (¿) for n=m=1 and n=m=2 can be written as
2. Simpson’s rule: WE divide the interval (a , b) into 2 n equal sub-intervals each of length h
and the interval (c , d) into 2 m equal sub-intervals each of length k . Then applying
Simpson’s rule in both directions, we get
d b
I =∫ ∫ f ( x , y )dxdy
c a
[{ }]
n n−1
hk
I= f 00 + 4 ∑ f 2 i−1+ 2 ∑ f 2 i ,0 + f 2 n ,0
9 i=1 i=1
{ }
m n n−1
+ 4 ∑ f 0,2 j−1+ 4 ∑ f 2 i−1,2 j−1 +2 ∑ f 2 i ,2 j−1 + f 2 n ,2 j−1
j=0 i=1 i=1
{ }
m−1 n n−1
+2 ∑ f 0,2 j+ 4 ∑ f 2 i−1,2 j +2 ∑ f 2i , 2 j +f 2 n , 2 j
j=1 i=1 i=1
{ }
n n−1
+ f 0,2 m+ 4 ∑ f 2 i−1,2 m +2 ∑ f 2 i ,2 m + f 2 n ,2 m
i=1 i=1
Where h and k are the spacing in the x and y directions respectively and
b−a d−c
h= ,k=
2n 2m
y j= y 0 + jk , j=1,2 , … ,2 m−1
Example
1. Using trapezoidal rule evaluate
2 2
dxdy
I =∫ ∫ taking h=k =0.25 so that n=m=4
1 1 x+y
2. Apply Simpson’s rule to evaluate the integral
2.6 4.4
dxdy
I =∫ ∫ taking h=0.2∧k=0.3 so that n=m=2
2 4 xy
Solution
Exercise
2 1
2 xy
∫∫ dxdy
1 0 ( 1+ x 2 )( 1+ y 2 )
Using
Solution
a.
>> x=0:0.25:1;
>> y=1:0.25:2;
>> [X,Y]=meshgrid(x,y);
>> I=trapz(y,trapz(x,F,2))
I =0.3482
Chapter-3
Least square approximation
This method of curve fitting was suggested early in the nineteenth century by the French
mathematician
Adrian Legendre.
The method of least squares assumes that the best fitting line in the curve for which the sum of
the squares of
the vertical distances of the points ( x i , y i ) from the line is minimum.
The simplest example of a least-squares approximation is fitting a straight line to a set of paired
observations:
( x 1 , y 1 ) ,( x 2 , y 2 ) ,…,( x n , y n). The mathematical expression for the straight line is
y=a0 +ax +e
k=1
∂ φ 0∧∂ φ
= =0
∂ a0 ∂a
∑ 2 ( a0 +a x k − y k ) =0
k=1
n
∑ 2 ( a0 +a x k− y k ) x k =0
k=1
Or
¿
Simply notation
n n n n
Let p=∑ (x k );q=∑ ( y k ) ; r =∑ ( x k y k )∧s=∑ (x k ) yields
2
{
a0 n+ap=q
a0 p+ as=r
⟹
n
p [ ]( ) ( )
p a0
s a
=
q
r
That is
pq−nr
a= 2
p −ns
pr −sq
a 0=
p 2−ns
The matrix has more rows than columns. There are more equations than unknowns.
We cannot always get the error e=b− Ax downs to zero. When e is zero x is an exact solution to
Ax=b. When the length of e is as small as possible, ^x is a least squares solution. Our goal in this
section is to compute ^x and use it. These are real problems and they need an answer.
How do we make the error e=b− Ax as small as possible? This is an important question with a
beautiful answer. The best x (called ^x ) can be found by geometry or algebra or calculus:
0
90 angle or project using P or set the derivative of the error to zero.
By calculus:
Suppose y=a0 +ax be the line which fits best for the data ( x 1 , y 1 ) , ( x 2 , y 2 ) … , ( xn , y n )
Most functions are minimized by calculus. Here the error function E to be minimized is a sum of
squares e 21+ e 22+ e23 +…+ e2n is minimized.
2
E=‖ Ax−b‖ =( a 0+ a x1 − y 1 )2+ ( a0 +a x 2− y 2 )2 +…+ ( a0 + a x n− y n )2
n n n
∂E
=2 ∑ ( a 0+ a xi − y i )=0 ⟹ ∑ ( a 0+ a xi ) =∑ y i
∂ a0 i=1 i=1 i=1
n n n
∂E
=2 ∑ ( a0 + a x i− y i ) x i=0 ⟹ ∑ ( a0 x i +a x 2i )=∑ xi y i
∂a i=1 i=1 i=1
( ) [ ]
n
1 x1
n ∑ xi
Thus
i=1
= AT A , where A= 1 x 2
n n
⋮ ⋮
∑ xi ∑ x 2i 1 xn
i=1 i=1
( )
n
∑ yi
And
i=1
n
= AT b
∑ xi yi
i=1
The equation is identical with AT A ^x = A T b. The best a 0 anda are the components of ^x . The
equations from calculus are the same as the ‘’normal equations’’ from linear algebra. These are
the key equations of least squares:
2
The partial derivatives of ‖ Ax−b‖ are zero when AT A ^x = A T b.
Example: Suppose our data (x i , y i ) consist of pairs (−2,4 ) , (−1,2 ) , ( 0,1 ) , ( 2,1 ) and(3,1).
Solution
x 1=−2 , x2 =−1; x 3=0 ; x 4 =2 abd x 5=3
5
p=∑ ( x k )=−2−1+ 0+2+3=2
k=1
5
q=∑ ( y k )=4+2+1+1+1=9
k=1
n
r =∑ ( x k y k )=x 1 y 1 + x 2 y 2 + x 3 y 3 + x 4 y 4 + x 5 y 5=−8−2+0+2+3=−5
k=1
5
s=∑ (x 2k )=x 21+ x 22 + x 23 + x 24 + x 25=4 +1+0+ 4+ 9=18
k=1
Therefore the linear equation which fits best for the given data is y=−0.566 x+2.026 .
Or using matrix
( )( )
n 5
n ∑ xi 5 ∑ xi
n
i=1
n
= 5
i=1
5
= A T A= (52 182 )
∑ x i ∑ x 2i ∑ xi ∑ x 2i
i=1 i=1 i=1 i=1
( )( )
n 5
∑ yi ∑ yi
i=1
n
= i=1
5 ( )
= A T b= 9
−5
∑ xi yi ∑ xi yi
i=1 i=1
Let ^x = (aa )
0
T T
A A ^x = A b ⟹ x^ = (aa )=inv ( A A )∗A b=(−0.5
0 T 2 T
)
Therefore the best fitting straight line is y=2−0.5 x
Curve fitting: Suppose we know that the relation between x and y is given by quadratic law
2 2
y=a+bx +c x , so we want to fit a parabola y=a+bx +c x to the data. Then our unknowns are
a , b andc and should satisfy the equation
2
y i=a+b x i+ c x i , i=1,2,3 , … , n
In a matrix form
( )( ) ( )
1 x1 x12 y1
2 a
1 x2 x2 y
b = 2
⋮ ⋮ ⋮ ⋮
c
1 xn xn
2
yn
Example: using the data (−2,4 ) , (−1,2 ) , ( 0,1 ) , ( 2,1 ) and(3,1) find the least square solution
2
y=a+bx +c x .
Solution
( )( ) ( )
1 −2 4 4
1 −1 1 a 2
1 0 0 b= 1
1 2 4 c 1
1 3 9 1
( )
1 −2 4
( )
1 −1 1 5 2 18
A= 1 0 0 ⟹ AT A= 2 18 26
1 2 4 18 26 114
1 3 9
()
9
AT y = −5
31
() ( )
a 1.1169
b =inv ( A A )∗( A y )= −0.8052
T T
c 0.2792
2
0.2792 x .
Orthogonal Polynomials
Discrete Least-Squares Approximation Problem
Given a set of n discrete data points (x i , y i ), i=1 , 2 ,. . . ,m .
Find the algebraic polynomial
2 n
P n(x )=a0 + a1 x +a 2 x + ・・ ・+ an x ( n<m)
such that the error E(a0 , a1 ,. . . , an) in the least-squares sense is minimized; that is,
m
E( a 0 , a 1, . . ., a n)=∑ ( y i−(a0 + a1 x i +a2 x i + …+an x i ) ) is minimum.
2 n 2
i=1
Since E(a0 , a1 ,. . . , an) is a function of the variable a 0 , a 1 , . .. , a n for this function to be minimum
we must have
∂E
=0 , i=0,1,2 , … , n
∂ ai
{
m
∂E
=−2 ∑ ( yi −( a 0+a1 xi +a2 x i +…+a n x i ) )
2 n
∂ a0 i=1
m
∂E
⟹ ∂ a =−2 ∑ ( y i−( a0 +a1 x i+ a2 x 2i +…+an x ni ) ) x i
1 i=1
⋮
m
∂E
=−2 ∑ ( y i−( a0 +a 1 x i+a2 x i +…+ an xi ) ) x i
2 n n
∂ an i=1
Set
m m
sk =∑ xi , k =0,1,2 , … ,2 n and b k =∑ x i y i , k =0,1,2 , … ,n
k k
i=1 i=1
{
m
s 0 a0 + s1 a1 +…+ sn a n=b0 (notethat ∑ x i =s0 )
0
i=1
s 1 a 0+ s 2 a 1+ …+s n+1 an =b1
⋮
s n a 0+ s n+1 a1 +…+ s2 n an =bn
( )( ) ( )
s0 s 1 ⋯ sn a 0 b0
s1 s 2 ⋯ s n+1 a 1 b
= 1
⋮ ⋮ ⋯ ⋮ ⋮ ⋮
sn s n+1 ⋯ s 2n a n bn
( ) () ()
s0 s 1 ⋯ sn a0 b0
s s2 ⋯ s n+1 a1 b
Or Sa=b , where S= 1 , a= ∧b= 1
⋮ ⋮ ⋯ ⋮ ⋮ ⋮
sn s n+1 ⋯ s 2n an bn
Define
( )
2 n
1 x1 x1 ⋯ x1
2 n
1 x2 x2 ⋯ x2
A= 1 x3 x3 ⋯
2
x3
n
⋮ ⋮ ⋮ ⋯ ⋮
1 xm x 2m ⋯ x nm
Thus, if x i ' s are distinct, the equation Sa=b has a unique solution.
∂E
=0 , i=0 , 1 ,. . . ,n .
∂ ai
As before, these conditions will give rise to a system of (n+1) normal equations in (n+1)
unknowns: a 0 , a 1 , . .. , a n. Solution of these equations will yield the unknowns: a 0 , a 1 , . .. , a n.
a
b
∂E
=−2∫ [ f ( x )−(a0 + a1 x +a 2 x + ・・ ・+ an x ) ] dx
2 n
∂ a0 a
b
∂E
=−2∫ x [ f ( x )−(a 0+ a1 x +a 2 x + ・・ ・+ an x ) ] dx
2 n
∂ a1 a
⋮
b
∂E
=−2∫ x [ f ( x ) −(a 0+ a1 x+ a2 x +・・ ・+an x ) ] dx
n 2 n
∂ an a
∂E
Since =0 , for i =0,1,2 ,… , n we have
∂ ai
b b b b
b b b b
a a a a
⋮
b b b b
a a a a
Denote
b b
a a
{
a 0 s0 + a1 s1 +a 2 s2 +…+ an s n=b 0
a0 s 1+ a1 s 2+ a2 s 3+ …+an sn+ 1=b1
⋮
a0 s n +a1 s n+1 + a2 sn +2+ …+a n s2 n=bn
Or in matrix form
( )( ) ( )
s0 s 1 ⋯ sn a 0 b0
s1 s 2 ⋯ s n+1 a 1 b
= 1
⋮ ⋮ ⋯ ⋮ ⋮ ⋮
sn s n+1 ⋯ s 2n a n bn
() ( )
b0 s0 s1 ⋯ sn
()
a0
b s s2 ⋯ s n+1
Sa=b , where a= ⋮ ,b= 1 ∧S= 1
⋮ ⋮ ⋮ ⋯ ⋮
an ⋯ s2 n
bn s n s n+1
Example
Find Linear and Quadratic least-squares approximations to f (x)=e x on [−1 ,1].
Solution
Linear Approximation: n=1; P1 (x )=a 0+ a1 x
1 1 1
2
s0 =∫ dx=2 , S 1=∫ xdx=0 , S 2=∫ x dx =
2
−1 −1 −1 3
1 1
1
b 0=∫ f ( x ) dx=∫ e dx =e− =2.35
x
−1 −1 e
1 1
2
b 1=∫ xf ( x ) dx=∫ xe dx= =0.7358
x
−1 −1 e
( )
2 0
S=
( )
S0 S 1
S1 S 2
=
0
2
3
b=
( )(b0
b1
=
2.35
0.7358 )
( )( ) (
2 0
0
3
a
2 0=
a1
2.35
0.7358 )
⟹ a0=1.1752∧a1=1.1037
−1
( )( ) ( )
2 0 2/3 a0 2.3504
0 2/3 0 a1 = 0.7358
2/3 0 2/5 a2 0.8789
Hence
()( )
a0 0.9963
a1 = 1.1037
a2 0.5368
a
{
∫ w ( x ) ϕ j ( x ) ϕi ( x ) dx= C0 ifif i≠
j
j
i= j
b
E ( a 0 , a 1 , . .. , a n )=∫ ¿ ¿ ¿ is minimized.
a
As before, we set
∂E
=0 , i=0,1 , … , n
∂ ai
Now
b b
∂E
=0 ⟹∫ Q0 ( x ) f ( x ) dx =∫ Q 0 (x) ¿ ¿ ¿
∂ a0 a a
Since, {Q k ( x) }nk =0 is an orthogonal set, we have,
b
∫ Q20 ( x ) dx=C0
a
∫ Q0 ( x ) f ( x ) dx=¿ C 0 a0 ¿.
a
That is
∫ Q 0 ( x ) f ( x ) dx
a
a 0=
C0
Similarly
b
1
ak= ∫ ϕ ( x ) f ( x ) dx , k=0,1,2, … , n
Ck a k
Where
b
C k =∫ ϕ k ( x ) dx
2
b
1
a k = ∫ w(x )ϕ k ( x ) f ( x ) dx , k=0,1,2 , … , n
Ck a
Where
b
C k =∫ w ( x ) Qk (x)dx
2
Recall that the first few Legendre polynomials are given by:
Q0 ( x )=1 1 3
Q3 ( x ) = (5 x −3 x)
2
Q 1 ( x )= x
1
1 Q4 ( x )= (35 x 4−30 x 2+ 3)
Q2 ( x ) = ( 3 x −1 )
2
8
2
1
Q5 ( x ) = ¿
8
To use the Legendre polynomials to approximate least-squares solution of a function f (x), we
set w (x)=1, and [a , b]=[−1 ,1]and compute
C k anda kwhere k =0 , 1 ,. . . ,n . That is
b
C k =∫ Q k (x )dx and
2
b
1
a k = ∫ f (x )Qk (x ) dx
Ck a
The least-squares polynomial will then be given by
Pn (x )=a0 Q0 ( x )+ a1 Q1 ( x )+ ・・ ・+ an Qn (x) .
A few C k ’ s are now listed below:
{
1 1
( )
2
1 2 1 2
C2=∫ ϕ 2 ( x)dx=∫
2
x− dx=
−1 −1 4 3 45
And So on
Example
Find linear and quadratic least-squares approximation to f (x)=e x using Legendre polynomials.
Solution
Linear Approximation: P1 ( x )=a0 ϕ 0 ( x)+ a1 ϕ1 (x )
ϕ 0 ( x )=1 , ϕ1 ( x )=x
Step1. Compute
1 1
C 0=∫ ϕ ( x ) dx=∫ dx=2
2
0
−1 −1
1 1
2
C 1=∫ ϕ ( x ) dx=∫ x dx=
2 2
1
−1 −1 3
b 1
1 1 1 1
a 0= ∫ ϕ 0 ( x ) f ( x ) dx= ∫ e dx = (e− )
x
C0 a 2 −1 2 e
b 1
1 3 3
a 1= ∫ ϕ 1 ( x ) f ( x ) dx= ∫ xe dx=
x
C1 a 2 −1 e
1 1 3
P1 ( x )= (e− )+ x
2 e e
a 0=
1
2 ( )
1
e− , a1 =
e
3
e
b 1
( )
2
1 1 2
C 2=∫ Q ( x ) dx= ∫ x − dx =
2 2
2
a 4 −1 3 45
b 1
a 2=
1
∫ ϕ ( x ) f ( x ) dx= 45
C2 a 2 ( )
∫ x 2− 13 e x dx=4 (e− 7e )
2 −1
The quadratic least square polynomial is
P2 ( x ) =
1
2 ( )
1 3 7
e− + x+ 2 e− ( 3 x 2−1 )
e e e ( )
Chebyshev polynomials: Another wonderful family of orthogonal polynomials
To see that T n (x)is a polynomial of degree n in our familiar form, we derive a recursive
Relation by noting that
T 0 (x)=1 (The Chebyshev polynomial of degree zero).
T 1( x)=x (The Chebyshev polynomial of degree 1).
A Recursive Relation for Generating Chebyshev Polynomials
Substituteθ=a rccos x . Then,T n (x)=cos(nθ), 0 ≤θ ≤ π .
Using this recursive relation, the Chebyshev polynomials of the successive degrees can be
generated:
2
n=1: T 2 ( x)=2 x T 1 (x )−T 0 ( x)=2 x −1,
n=2: T 3 ( x )=2 x T 2 (x )−T 1 ( x)=2 x (2 x 2−1)−x =4 x 3−3 x and so on.
The orthogonal property of the Chebyshev polynomials
We now show that Chebyshev polynomials are orthogonal with respect to the weight function
1
w (x)= in the interval [−1,1]
√ 1−x 2
To demonstrate the orthogonal property of these polynomials, we show that
{
1
T m (x )T n ( x) 0 , if m≠ n
∫ = π
−1 √ 1−x 2 2
,m=n
1 1
T m ( x )T n (x) cos (marccosx)cos (narccosx )
First,∫ dx=∫ dx ,m ≠ n
−1 √ 1−x 2
−1 √1−x 2
−1
Since, arccosx=θ , dθ= dx
√ 1−x 2
The above integral becomes:
0 π
−∫ cosmθcosnθdθ =∫ cosmθcosnθdθ
π 0
1
Now, cosmθcosnθ can be written as
2
[ cos ( m+n ) θ+cos ( m−n ) θ ]
So
π π
1
∫ cosmθcosnθdθ= 20
∫ [ cos ( m+n ) θ+cos ( m−n ) θ ] dθ=0
0
1
T 20 (x )
C 0=∫ dx=π
−1 √ 1−x 2
1 2
T k (x )
π
C k =∫ dx= , k =1, … , n
−1 √ 1−x 2 2
These
1
1 f (x)
a 0= ∫
π −1 √1− x2
dx
1
2 f (x )T i ( x )
a i= ∫ dx , i=1 ,… , n
π −1 √ 1−x 2
Example
Solution
Where
1 1
x
1 f (x) 1 e
a 0= ∫
π −1 √ 1− x2
dx= ∫
π −1 √1−x 2
dx =1.2660
1 1
2 f (x) T 1 ( x )
x
2 e (x )
a 1= ∫ dx= ∫ dx=1.1303
π −1 √ 1−x 2 π −1 √ 1−x 2
'
y =f ( x , y ) , y ( x 0 )= y 0 Can be classified mainly into two types. They are
We denote the numerical solution and the exact solution at x iby y iand y ( x i) respectively
In single step methods, we use information from only one preceding point that is to estimate the
value y i we need the conditions at the previous y i−1 only.
In multi-step methods, we use information at two or more previous steps to estimate a value of
y ( x).
The DE in equation (1) above together with the conditions at a point is called initial value
problem (IVP) whereas the DE in equation (1) above together with the conditions at two or more
points is called boundary value problems.
y ' =f ( x , y ) , y ( x 0 )= y 0
1 1
y ( x ) = y ( xi ) + ( x −xi ) y ' ( xi ) + ( x−x i )2 y ' ' ( x i )+ …+ ( x−x i ) p y( p) ( x i )
2! p!
+1 p+1
( x−x i ) y ( p +1) (x i+θh) (¿)
( p+ 1 ) !
Where 0<θ <1 , x ∈ [ x 0 , b ]and b is the point up to which the solution is required.
We denote the numerical solution and the exact solution at x iby y iand y ( x i) respectively.
Now, consider the interval[ xi , xi +1 ]. Then length of the interval ish=x i+1−x i.
2 p p+1
' h '' h ( p) h ( p+1 )
y ( x i+1 )= y ( x i ) +h y ( x i ) + y ( x i ) +…+ y ( xi ) + …+ y ( xi +θh).
2! p! ( p+1 ) !
2 p
h '' h ( p)
y i+1 = y i+ h y 'i+ y i + …+ y .
2! p! i
p +1
h ( p +1)
The truncation error is T i+1= y (x i+ θh) and the order is p.
( p+1 ) !
Example
Find using Taylor’s method to solve the equation y ' =x− y 2 and y ( 0 )=1 and find y ( 0.5 ) correct
to five decimal place accuracy.
Solution
Now y ' ' ( x )=1−2 y y ' ⟹ y ' ' ( 0 )=1−2 y ( 0 ) y ' ( 0 )=1−2 ( 1 ) (−1 )=3
3 2 4 3 17 4 31 5
y ( x ) =1−x + x − x + x − x + …
2 3 12 20
3 2 4 3 17 4 31 5
y ( 0.5 )=1−0.5+ ( 0.5 ) − ( 0.5 ) + ( 0.5 ) − ( 0.5 )
2 3 12 20
y ( 0.5 )=1−0.5+0.375−0.16666+0.08854−0.04843=0.74851
Exercise
1. Find the analytic solution of y ' =x 2 + y , y ( 0 )=1 and compare to Taylor’s series.
2. Use Taylor’s series method solve y ( 0.25 ) an d y ( 0.5 ) giventhat
' 2 3
y =x + y , y ( 0 )=1
Euler method
The method of Taylor’s series yields the solution of a DE in the form of a power series. Now
Euler’s method which gives the solution in the form of a set of tabulated values.
dy
=f ( x , y ) ⟹ dy=f ( x , y ) dx ⟹∫ dy=∫ f ( x , y ) dx
'
Consider y =f ( x , y ) ⟹
dx
y1 x1
y1 x1 y1 x1
⟹ y 1− y 0=f ( x 0 , y 0 ) ( x 1−x 0 ) ⟹ y 1= y 0+ hf ( x 0 , y 0 )
Proceeding in this manner we obtain the general formula in the interval ( x n , x n +1)
y n+ 1= y n +hf ( x n , y n )
Remark:
Taylor series method cannot be applied to all problems as we need the higher order derivatives.
The higher order derivatives are obtained as
'
y =f ( x , y ) ,
'' ∂ f ∂ f dy
y = + =f + f f y ,
∂ x ∂ y dx x
' ''
y = (
∂ ∂ f ∂ f dy
+ + + ) (
∂ ∂ f ∂ f dy dy
∂ x ∂ x ∂ y dx ∂ y ∂ x ∂ y dx dx xx )2
=f +2 f f xy + f f yy+ f y ( f x +f f y ) ,etc.
The number of partial derivatives required, increases as the order of the derivative of y increases.
Therefore, we find that computation of higher order derivatives is very difficult. Hence, we need
suitable methods which do not require the computation of higher order derivatives.
Example:
1. Solve the initial value problem y y ' =x , y ( 0 )=1 ,using Euler method in 0 ≤ x ≤ 0.8 ,with h=0.2
andh=0.1. Compare the results with the exact solution at x=0.8 .
Solution:
' x
We have y =f ( x , y )=
y
hx i
Euler method gives y i+1 = y i+ hf ( xi , y i )= y i + .
yi
0.2 x 0
y ( x 1) = y ( 0.2 ) ≈ y 1= y 0+ =1.0.
y0
0.2 x 1
y ( x 2) = y ( 0.4 ) ≈ y 2= y 1 + =1.04 .
y1
0.2 x 2
y ( x 3 )= y ( 0.6 ) ≈ y 3= y 2 + =1.11692.
y2
0.2 x 3
y ( x 4 ) = y ( 0.8 ) ≈ y 4 = y 3 + =1.22436 . M
y3
0.1 x i
When h=0.1 ,we get y i+1 = y i+ .
yi
0.1 x 0
y ( x 1) = y ( 0.1 ) ≈ y 1= y 0+ =1.0.
y0
0.1 x1
y ( x 2) = y ( 0.2 ) ≈ y 2= y 1+ =1.01 .
y1
0.1 x 2
y ( x 3 )= y ( 0.3 ) ≈ y 3= y 2 + =1.02980.
y2
0.1 x 3
y ( x 4 ) = y ( 0.4 ) ≈ y 4= y 3 + =1.05893 .
y3
0.1 x 4
y ( x 5 )= y ( 0.5 ) ≈ y 5= y 4 + =1.09670 .
y4
0.1 x 5
y ( x 6 )= y ( 0.6 ) ≈ y 6= y 5 + =1.14229 .
y5
0.1 x6
y ( x 7 )= y ( 0.7 ) ≈ y 7= y 6 + =1.19482 .
y6
0.1 x 7
y ( x 8 )= y ( 0.8 ) ≈ y 8= y 7 + =1.25341 .
y7
The exact solution is y= √ x 2 +1.
h=0.2 :|1.28062−1.22436|=0.05626.
h=0.1 :|1.28062−1.25341|=0.02721.
2. Consider the IVP y ' =x ( y+1 ) , y ( 0 )=1. Compute y ( 0.2 )with h=0.1using
i. Euler method
ii. Taylor series method of order two,
2
x
iii. Fourth order Taylor series method. (Exact y=−1+ 2e 2 )
x1
y 1= y 0 +∫ f ( x , y ) dx
x0
h
y 1= y 0 +
2
( f ( x 0 , y 0 ) +f ( x1 , y 1))
h
In general we obtain the integral formula y 1
(n +1)
= y0+
2
( f ( x0 , y 0 ) + f ( x1 , y(n)1 ) )
(0 )
The iteration formula can be started by y 1 from Euler’s formula.
That is y 1 = y 0 +h ( f ( x 0 , y 0 ) )
(0 )
h
(n +1)
Therefore y k +1 = y k +
2
( k+1 ) ) is the ( n+1 ) approximation of y k +1.
f ( x k , y k ) + f ( x k+1 , y (n) th
Example
Find the solution y ' =x− y 2 at (0,1) and find y (0.1) correct to three decimal place accuracy with
Solution
Let us find y 1 = y 0 +h ( f ( x 0 , y 0 ) )
(0 )
h
That is y (01 )=1+0.1 ( 0−12 )=0.9 and then y 1
(n +1)
= y0+
2
( f ( x0 , y 0 ) + f ( x1 , y(n)1 ) )
0.1
( 1)
Take n=0 ⟹ y1 =1+ (−1+ 0.1−0.92 ) =0.9145
2
0.1
(2 )
Take n=1⟹ y 1 =1+ (−1+0.1−0.91452 )=0.9132
2
0.1
(3 )
Take n=2⟹ y 1 =1+ (−1+0.1−0.91322 )=0.9133
2
Exercise
Determine the value of y when x=0.1∧h=0.05 given that y ( 0 )=1∧ y ' =x 2+ y using modified
Euler’s method.
Runge-Kutta’s method
Euler’s method is less efficient in practical problems since it requires h to be small for obtaining
reasonable accuracy.
Runge-Kutta’s methods are designed to give greater accuracy and they possess the advantage of
requiring only the function values at some selected points on the sub interval.
( h
k 1=hf x 0 + , y 0 +
2
k0
2 )
⟹ k 1=0.1 f ( 0+0.05,1−0.05 )
Take n=1
h=0.1 , y 1 =0.9138 , x 1=0.1
1
y 2= y 1 + ¿
6
k 0=hf ( x 1 , y 1 )=−0.073503
( h
)
k0
k 1=hf x 1 + , y 1+ =−0.0619
2 2
k =hf ( x + , y + )=−0.0629
h k 1
2 1 1
2 2
k 3=hf ( x 1+ h , y 1 +k 2) =−0.0524
1
y 2=0.9138+ ¿
6
Take n=2
h=0.1 , y 2 =0.8501 , x 1=0.2
k 0=hf ( x 2 , y 2 )=−0.05227
( h
)
k0
k 1=hf x 2 + , y 2+ =−0.042895
2 2
k =hf ( x + , y + )=−0.050963
h k 1
2 2 2
2 2
k 3=hf ( x 2+ h , y 2 +k 2 )=−0.033865
1
y 3= y ( 0.2 )= y 2+ ¿
6
Exercise
Apply Runge-Kutta’s method approximate values of y for x=0.2 for h=0.1 given
that y ' =x + y 2 and y (0)=1
Multistep methods are methods require function values at x n , x n−1 , x n−2 , … for the computation of
the function value at x n+1. A predictor formula is used to predict the value of y at x n+1 and the
corrector formula is used to improve the value of y n+ 1.
dy
Given =f ( x , y) and y 0= y ( x 0), we compute
dx
y−1= y ( x 0−h ) , y−2= y ( x 0−2 h ) , y−3= y ( x 0−3 h ) by Taylor’s series or Euler’s method or Runge-
Kutta’s method.
Next we calculate
x 0+h
in y 1= y 0 + ∫ f (x , y )dx … … … … … … … … … … … … … … … … … … … … … … ..(1)
x0
x1
n ( n+1 ) 2 n ( n+1 ) ( n+2 ) 3
y 1= y 0 +∫ [f 0 +n ∇ f 0 + ∇ f 0+ ∇ f 0 + …]dx
x0
2 3!
x−x 0 1
Sincen= ⟹ dn= dx ⟹ dx=hdn , for x= x0 , n=0 , for x=x 1 ,n=1
h h
1
n ( n+1 ) 2 n ( n+1 ) ( n+2 ) 3
y 1= y 0 + h∫ [f 0 +n ∇ f 0 + ∇ f 0+ ∇ f 0 + …] dn
0 2 3!
1 5 2 3 3 251 4
y 1= y 0 + h[1+ ∇+ ∇ + ∇ + ∇ + …]f 0
2 12 8 720
Neglecting fourth and higher order differences and expressing
2 3
∇ f 0 , ∇ f 0 and ∇ f 0 in terms of function values, we get
h
y 1= y 0 +
24
[ 55 f 0−59 f −1 +37 f −2−9 f −3 ] … … … … … … … … … … … … … … … … … …(2)
p h
Hence y i+1 = y i+ [55 f i−59 f i−1 +37 f i−2 −9 f i−3 ]
24
We get
x1
n ( n+1 ) 2 n ( n+ 1 )( n+2 ) 3
y 1= y 0 +∫ [f 1 +n ∇ f 1 + ∇ f 1+ ∇ f 1+ …]dx
x0
2 3!
0
n ( n+1 ) 2 n ( n+1 )( n+ 2 ) 3
y 1= y 0 + h ∫ [ f 1 +n ∇ f 1 + ∇ f 1+ ∇ f 1 +…] dn
−1 2 3!
1 1 2 1 3 19 4
y 1= y 0 + h[1− ∇− ∇ − ∇ − ∇ −…] f 1
2 12 24 720
2 3
∇ f 0 , ∇ f 0 and ∇ f 0 in terms of function values, we get
h
y 1= y 0 + [9 f 1+19 f 0−5 f −1 +f −2 ] ,where f 1=f (x 0+ h , y 1 )
24
Which is called Adams-Moulton corrector formula.
c h
Hence y i+1 = y i+ [9 f i+1 +19 f i −5 f i−1 +f i −2 ] is called Adams-moulton corrector formula for
24
i=0,1,2 , … .
Note
∇ f 0 =f 0 −f −1
∇ 2 f 0=f 0 −2 f −1 + f −2 and so on
Note
The values y−1 , y−2 and y−3 which are required on the right side of the predictor formula
obtained by means of the Taylor series or Euler’s method or Runge-Kutta’s method due to this
reason.
Example
Solve y ' =x− y 2 with h=0.1 correct to four decimal place and find y (0.4 ) using predictor-
corrector Adams-moulton for y (0)=1
Solution
Using 4th .O.R.K method we have to find y ( 0.1 ) , y ( 0.2) and y (0.3)
p h
y i+1 = y i+ [55 f i−59 f i−1 +37 f i−2 −9 f i−3 ]
24
Take i=0
h
y 1p= y 0+
24
[ 55 f 0 −59 f −1 +37 f −2−9 f −3 ]
0.1
y 1p=0.8070+
24
[ 55 f ( 0.3,0.8070 )−59 f ( 0.2,0 .8512 ) +37 f ( 0.1,0 .9138 )−9 f ( 0,1 ) ]
p
y 1 =0.7796 and
c h p
y 1= y 0 + [9 f 1 +19 f 0−5 f −1 +f −2 ]
24
c 0.1
y 1=0.8070+ [9 f ( 0.4,0 .7796 ) +19 f ( 0.3,0 .8070 )−5 f ( 0.2,0.8512 ) + f (0.1,0 .9138)]
24
c
y 1=0.7793
Exercise
Milne’s method
dy
Given =f ( x , y) and y ( x 0 )= y 0 ; to find an approximate value of y for x=x 0 +nh by
dx
Milne’s method , we proceed as follows:
The value y 0= y ( x 0 ) being given, we compute
y 1= y ( x 0 +h ) , y 2= y ( x 0+ 2 h ) , y 3 = y ( x 0 +3 h ) by Picard or Taylor’s series method.
Next we calculate
f 0=f ( x0 , y 0 ) , f 1=f ( x 0+ h , y 1) , f 2=f ( x 0 +2 h , y 2 ) , f 3=f ( x0 +3 h , y 3 )
∫ dy=∫ f (x , y )dx
x0 x0
x4
y ( x 4 ) = y ( x 0 ) +∫ f (x , y )dx
x0
x4
y 4 = y 0 +∫ f (x , y )dx
x0
x i+1
[ ]
x i+1
n( n−1) 2 n (n−1)(n−2) 3
y ( x i+1 )= y ( x j ) + ∫ f 0 +n ∆ f 0 + ∆ f 0+ ∆ f 0+ … dx
xj
2 3!
[ ]
4
n(n−1) 2 n (n−1)(n−2) 3
Hence y ( x 4 ) = y ( x 0 ) + h∫ f 0 +n ∆ f 0 + ∆ f 0+ ∆ f 0+ … dn
0 2 3!
20 2 8
y 4 = y 0 +h[ 4 f 0+ 8 ∆ f 0 + ∆ f 0 + ∆3 f 0 +… ]
3 3
20 2 8 3
y 4 ≅ y 0+ h[4 f 0 +8 ∆ f 0 + ∆ f 0+ ∆ f 0]
3 3
Neglecting 4th and higher order difference and expressing ∆ f 0 , ∆2 f 0 and ∆ 3 f 0 in terms of
the function value , we get.
4h
y4= y0+ [2 f 1−f 2 +2 f 3 ] Which is called a predictor.
3
Having found y 4 , we obtain a first approximation to
f 4=f (x 0 + 4 h , y 4 )
Then a better value of y 4 is found by Simpson’s rule as
h
y 4 = y 2 + [ f 2+ 4 f 3 +f 4 ] which is called a corrector.
3
Then an improved value of f 4 is computed and again the corrector is applied to find a still
better value of y 4 . We repeat this step until y 4 remains unchanged.
Once y 4 and f 4 are obtained to the desired accuracy , y 5=f (x 5 , y 5 ) is found from predictor as
h
y 5= y 3 + [2 f 2−f 3 +2 f 4 ] and f 5=f (x 5 , y 5 ) is calculated then a better approximation to the value
3
of y 5 is obtained from the corrector as
h
y 5= y 3 + [f 3 + 4 f 4 + f 5 ]
3
In general
4h
y 4 +i= y i + [2 f i +1−f i+2 +2 f i +3 ], for i=0,1,2 , … is called a predictor and
3
h
y 4 +i= y 2 +i+ [f i +2+ 4 f i+3 + f i+ 4 ], for i=0,1,2 , … is called a corrector
3
Example solve y ’=1+ y 2 with h=0.2 correct to four decimal place and find y (1) using Milne’s
predictor-corrector method when y (0)=0.
Solution
x 0=0 , x 1=0.2 , x2=0.4 , x3 =0.6 , x 4=0.8 and x 5=1
We know by Picard method
x
y n= y 0+∫ f ( x , y n−1 ) dx
0
f ( x , y )=1+ y 2
x
y 1= y 0 +∫ f ( x , y 0 ) dx=x
0
x x
x3
y 2= y 0 +∫ f ( x , y 1 ) dx=∫ (1+ ¿ x )dx= x+
2
¿
0 0 3
( )
x x 3 2 3 5 7
x x 2x x
y 3= y 0+∫ f ( x , y 2 ) dx=∫ (1+ ¿ x + ) d x=x + + + ¿
0 0 3 3 15 63
3
0.4
y ( 0.2 )=0.2 , y ( 0.4 ) =0.4+ =0.4213 , y ( 0.6 ) =0.6828
3
f 1=f ( x 1 , y 1 ) =1+0.22=1.04
f 2=f ( x 2 , y 2) =1+0.42132=1.177
2
f 3=f ( x 3 , y 3 )=1+0.6828 =1.4662
Predictor
4h
y4= y0+ ¿
3
0.8
y 4 =0+
3
[ 2 ( 1.04+1.4662 ) −1.177 ]=1.0227
2
f 4=f ( x 4 , y 4 ) =1+ 1.0227 =2.046
Corrector
h
y 4 = y 2 + [ f 2+ 4 f 3 +f 4 ]
3
0.2
y 4 =0.4213+
3
[ 1.177+ 4 ( 1.4662 )+ 2.046 ] =1.02715
2
f 4=f ( x 4 , y 4 ) =1+ 1.02715 =2.05504
Again corrector
0.2
y 4 =0.4213+
3
[ 1.177+ 4 ( 1.4662 )+ 2.05628 ]=1.027756
f 4=f ( x 4 , y 4 ) =1+ 1.0277562=2.05628
Again corrector
h
y 4 = y 2 + [ f 2+ 4 f 3 +f 4 ]
3
0.2
y 4 =0.4213+
3
[ 1.177+ 4 ( 1.4662 )+ 2.05628 ]=1.027838
The answer is y ( 0.8 )=1.0278
Using predictor
4h
y 5= y 1 + ¿
3
f 4=1+1.0278 2=2.0564
+0.8
y 5=0.2+ [ 5.0006 ] =1.5335
3
2
f 5=1+1.5335 =2.352
Using the corrector
h
y 5= y 3 + [ f +4 f 4 +f 5 ]=1.4857
3 3
f 5=f ( x 5 , y 5 )=1+1.48572=3.2074
Again the corrector
h
y 5= y 3 + [ f +4 f 4 +f 5 ]=1.543
3 3
f 5=f ( x 5 , y 5 )=1+1.5432=3.381
Again the corrector
h
y 5= y 3 + [ f +4 f 4 +f 5 ]=1.554
3 3
f 5=f ( x 5 , y 5 )=1+1.554 2=3.4149
Again the corrector
h
y 5= y 3 + [ f +4 f 4 +f 5 ]=1.556
3 3
The correct value of y ( 1 ) is 1.556
We can reduce this second order initial value problem to a system of two first order equations.
1 1
u'2=u '1' = y' ' =
a0 (x )
[ r ( x )−a1 ( x ) y '( x )−a 1 ( x ) y ( x ) ]=
a0 (x )
[ r ( x )−a1 ( x ) u2 −a1 ( x ) u1 ] ,
u2 ( x 0 )=b 1= y ' (x 0 )
[][
u'1
u2'
=
f 2 ( x
u2
, u 1 , u 2 )][ ] [ ]
u (x ) b
, 1 0 = 0 … … … … … … … … ..(2)
u2 ( x 0 ) b 1
1
Where f 2 ( x , u1 , u2 ) =
a0 ( x )
[ r ( x )−a1 ( x ) u 2−a1 ( x ) u1 ]
[ ][ ][ ] [ ]
'
y1 f ( x , y 1 , y 2) y 1 (x 0) b 0
'
= 1 , = … … … … … … … … … … …(3)
y2 f 2 ( x , y 1 , y 2) y 2 (x 0) b1
y=
[] [] []
y1
y2
f b
, f = 1 , b= 0
f2 b1
Then we can rewrite the system as
'
y =f ( x , y ) , y ( x 0 )=b … … … … … … … … … … .(4 )
Therefore, the methods derived for the solution of the first order initial value problem
dy
=f ( x , y ) , y ( x 0 ) = y 0 … … … … … … … … … … ..(5)
dx
can be used to solve the system of equations (3) or (4), that is, the second order initial
value problem (1), by writing the method in vector form.
Example: Reduce the following second order initial value problems into systems of first order
equations:
[][ ][ ] [ ]
'
u1 f ( x ,u 1 , u2 ) u1 (0) 1
= 1 , =
'
u2 f 2 ( x , u1 , u2 ) u2 (0) 2
1
Where f 1 ( x ,u 1 , u2 ) =u2 and f 2 ( x , u1 , u2 ) =
2
[3 x +5 u2−6 u 1 ]
b. Let u1= y . Then, we have the system
'
u1=u 2 , u1 (1)=2
1
'
u2 = 2
[ 6−( 2 x +1 ) y ' −3 y ]= 12 [ 6−( 2 x+ 1 ) u2 −3u 1 ] , u2 ( 1 )=0.5
x x
The system may be written as
[][
u'1
u2'
= 1 ,
][ ] [ ]
f ( x ,u 1 , u2 ) u1 (1)
= 2
f 2 ( x , u1 , u2 ) u2 (1) 0.5
1
2[
Where f 1 ( x ,u 1 , u2 ) =u2 and f 2 ( x , u1 , u2 ) = 6−( 2 x +1 ) u2−3 u1 ]
x
Exercise
Rewrite the initial-value problem for the system of 2 second-order differential
equations
{
'' ' '
y 1 + y 1−2 y 2+ 2 y 1− y 2=x ' '
'' '
, y 1 ( 0 )=1 , y 2 ( 0 )=−1, y 1 ( 0 )=2 , y 2 ( 0 )=3
y 2 −3 y 1 + y 1 +4 y 2=2 sin ( x)
[ ]
k −1
d
f 1 ( x i , y 1 ,i , y 2, i )
[ ]
( k)
y d x k−1
Where y (ik )= 1, i
( k)
= k −1
y d
2, i
f 2 ( x i , y 1 ,i , y 2, i )
d x k−1
2 p
h h
( y 1 )i +1=( y 1 )i +h ( y ) + ( y'1' )i +…+ ( y (1p )) i … … … … … … … … … … …(ii)
'
1 i
2! p!
h2 '' hp
( y 2 )i +1=( y 2 )i +h ( y '2 )i + ( y 2 )i +…+ ( y (2p )) i … … … … … … … … … … …(iii)
2! p!
Where k 1= [ ] [ ] [ ] [ ]
k 11
k 21
k k k
, k 2= 12 , k 3= 13 , k 4 = 14
k 22 k 23 k 24
k n1 =h f n ( x i , ( y 1) i , ( y 2 )i ) , n=1,2.
( h
2
1
2
1
)
k n2 =h f n xi + , ( y 1 )i + k 11 , ( y 2 )i+ k 21 , n=1,2
2
( h
2
1
2
1
)
k n3 =h f n xi + , ( y1 )i + k 12 , ( y 2 )i + k 22 , n=1,2
2
1
( y 1 )i +1=( y 1)i + ( k 11+2 k 12 +2 k 13 +k 14 ) ,
6
1
( y 2 )i+1=( y 2)i + ( k 21+2 k 22+2 k 23 +k 24 )
6
1
(u)i+1=(u)i+ ( k 11 +2 k 12+ 2 k 13+ k 14 ) ,
6
1
(v)i+1 =(v)i + ( k 21 + 2k 22+2 k 23 +k 24 )
6
Example
Compute approximations to y ( 0.4 ) and y '(0.4 ), for the initial value problem
Using (i) Taylor series method of 4th order, (ii) Runge-Kutta’s method of 4th order, with step
( 2 cos 2 x+ cost )
length h=0.2. If exact solution is given by y ( x ) = , find the magnitudes of the
3
errors.
Solution
Let y=u . Reducing the given second order equation to a system of first order equations, we
obtain
'
u =v ,u ( 0 ) =1
We have u' =v , v ' =cosx−4 u , u' ' =v ' , v '' =−sinx−4 u' ,
u ( 0.2 )=u 1=u0 +0.2 u'0 +0.02 u'0' +0.0013 u'0' ' +0.000067 u(4)
0 =0.940733
v ( 0.2 )=v 1=v 0+ 0.2 v '0 +0.02 v '0' +0.0013 v ''0 ' + 0.000067 v (40 )=−0.585333
|v ( 0.2 ) −v 1|=0.000115
|u ( 0.4 )−u2|=0.000052
( h
2
1
2
1
)
k 12=h f 1 x 0 + , u0 + k 11 , v 0 + k 21 =0.2 f 1 ( 0.1,1 ,−0.3 ) =0.2 (−0.3 )=−0.06
2
( h
2
1
2
1
)
k 13=h f 1 x 0 + , u0 + k 12 , v 0 + k 22 =0.2 f 1 ( 0.1 , 0.97 ,−0.3004995 ) =0.2 (−0.3004995 )=−0.60100
2
( h
2
1
2
1
)
k 23 =h f 2 x 0 + ,u0 + k 12 , v 0 + k 22 =0.2 f 2 ( 0.1,0 .97 ,−0.3004995 )=0.2 ( cos ( 0.1 )−4 ( 0.97 ) )=−0.576999
2
k 24 =h f 2 ( x 0 +h , u0 +k 13 , v 0 +k 23) =0.2 f 2 ( 0.2,0 .9399 ,−0.576999 )=0.2 ( cos ( 0.2 )−4 ( 0.9399 ) )=−0.555907
1
u ( 0.2 )=u 1=u0 + ( k 11+2 k 12 +2 k 13 +k 14 ) =0.940733
6
1
v ( 0.2 )=v 1=v 0+ ( k 21 +2 k 22 +2 k 23+ k 24 ) =−0.585317
6
( h
2
1
2
1
)
k 12=h f 1 x 1 + , u1 + k 11 , v1 + k 21 =0.2 f 1( 0.3,0.882202 ,−0.863604)=−0.172721
2
( h
2
1
2
1
)
k 22=h f 2 x 1 + , u1 + k 11 , v 1+ k 21 =0.2 f 2 ( 0.3,0 .882202 ,−0.863604 )=−0.514694
2
( h
2
1
2
1
)
k 13 =h f 1 x 1 + , u1 + k 12 , v 1+ k 22 =0.2 f 1 ( 0.3,0 .854372 ,−0.842664 )=−0.168533
2
( h
2
1
2
1
)
k 23 =h f 2 x 1 + , u1 + k 12 , v 1+ k 22 =0.2 f 2 ( 0.3,0 .854372 ,−0.842664 )=−0.492430
2
1
u ( 0.4 )=u2=u 1+ ( k 11 +2 k 12+2 k 13+ k 14 )=0.771546
6
1
v ( 0.4 )=v 2=v 1 + ( k 21+ 2k 22+2 k 23 +k 24 )=−1.086045
6
|v ( 0.2 ) −v 1|=0.000131
|u ( 0.4 )−u2|=0.000055
This method requires good initial guesses for the slope and can be applied to both linear and non-
linear problems. Its main advantage is that it is easy to apply. Let us consider
Consider the boundary value problems (BVPs) for the second order differential equation
of the form
y ' ' =f ( x , y , y ' ) , a≤ x ≤ b , y ( a )=α and y ( b )= β … … … … … … … … … (1)
Under what conditions a boundary value problems has a solution or a unique solution.
Exercise
Consider the following boundary value problems:
+sin ( y )=0,1≤ x ≤ 2 , y ( 1 )= y ( 2 )=0
'' −xy '
y +e
Determine if the boundary value problem has a unique solution.
2
d y
Example: solve the boundary value problem 2
−2 y=8 x (9−x) subject to
dx
the boundary condition y ( 0 )=0 , y ( 9 ) =0.
Solution
First change the given boundary value problem into systems of initial value
problem.
Guess y ' (0). That is y ' ( 0 )=4
dy
=z ( say )=f 1 ( x , y , z ) … … … … … … … … … … … … .(i)
dx
dz d2 y
= =2 y+ 8 x ( 9−x ) =f 2 (x , y , z )… … … … … … (ii)
dx d x2
For i=0
y 1= y 0 +3 z 0=0+3 ( 4 )=12
For i=1
y 2= y 1 +3 z 1=24
For i=2
Suppose z ( 0 )=−24
y i+1 = y i+ f 1 ( x i , y i , z i ) h= y i+3 z i
z i+1=z i + f 2 ( x i , yi , z i ) h=z i +3[2 y i +8 x i ( 9−x i ) ]
For i=0
y 1= y 0 +3 z 0=−72
For i=1
y 2= y 1 +3 z 1=−144
For i=2
y 3= y 2 +3 z 2=−216= y (9)≠ 0
Let p be between z ( 0 )=4 and z ( 0 )=−24 and q be between y ( 9 )=1548 and y ( 9 )=−216
Let ( p , q) be on the line then the equation of the line is given by:
q−q 0=
( q1 −q0
p1 −p 0 )
( p− p 0 ) ,where( p0 , q0 ) =(−24 ,−216 ) and( p1 , q1 )=(4 , 1548) .
p= p 0+
( p 1− p0
q 1−q 0 )
( q−q0 )
dy
Therefore z ( 0 )= ( 0 )=−20.57
dx
dy
For z ( 0 )= ( 0 )=−20.57 by using Euler’s formula we get
dx
y 1= y ( 3 )=−20.57
y 2= y ( 6 ) =−123.42
y 3= y ( 9 ) =0.09
Consider the boundary value problems (BVPs) for the second order differential equation of the
form
y =f ( x , y , y ) , a≤ x ≤ b , y ( a )=α , y ( b )=β
'' '
When f ( x , y , y ' )is not linear in y and y ' . Assume a given boundary value problem has a unique
solution y ( x ). We will approximate the solution y ( x ) by solving a sequence of initial value
problems.
Let y ' ' + p ( x ) y ' +q ( x ) y=r ( x ) , y ( a )=α , y ( b )=β … … … … … … … … .(¿) be BVP
We know how to solve IVP.
Can we convert (¿) as an IVP? Yes it is. By supplying initial condition on y ' we can convert (¿)
into IVP.
That is
y ' ' + p y ' + qy=r , y ( a )=α , y ' ( a )=? say δ is an IVP
Solve IVP to get the solution at y (b) by finding suitable slope( y ' (a)).
Let y ' ' + p ( x ) y ' +q ( x ) y=r ( x ) , a ≤ x ≤ b , y ( a )=α , y ( b )=β is BVP
The equivalent IVP is given by:
{ '
y ' =z , y ( a ) =α
z =r− pz−qy , z ( a )=? say δ
IVP can be solved using a favorite methods such as Euler’s method ,R.K method, Taylor series
method etc.
The interval [a , b] can be divided into n sub intervals with equal step size h . We discretize x we
get
x 0=a , x 1 , x 2 ,… , x n=b such that y ( x 0 )= y ( a ) =α , y ( x1 ; δ ) , y ( x 2 ; δ ) , … , y ( x n ; δ )= y (b ; δ )
y (b ; δ ) means y at b using δ .
The target is y ( b )= β
Compare y ( b ;δ )−β If | y ( b ; δ )−β|<ϵ we have solved the BVP.
Looking for δ such that y ( b ; δ )−β ≅ 0.
Find solution of ϕ ( x )= y ( b ; δ ) −β=0 .
How do we find the roots of ϕ ( x )=0 ?
Using secant or Newton Raphson method we can find the roots of ϕ ( x )=0.
For simplicity we use only secant method.
( δn−δ n −1 )
δ n+1=δ n − ϕ ( δn )
ϕ ( δ n )−ϕ ( δ n−1 )
We need two initial approximation δ 0 and δ 1
The two initial slopes δ 0 and δ 1 define two IVPs given as follows:
IVP1: y ' ' + p y ' + gy =r , y ( a )=α ; y ' ( a )=δ 0
IVP2: y ' ' + p y ' + gy =r , y ( a )=α ; y ' ( a )=δ 1
Solve IVP1 and IVP2 to get y (b ; δ 0 ) and y (b ; δ 1)
ϕ ( δ 0 )= y ( b ; δ 0 ) −β
ϕ ( δ 1 )= y ( b ; δ 1 )−β
{
'
y =z , y ( 0 )=1
IVP1: ' 2
z =6 y −x , z ( 0 )=1.2
From IVP1 and using Euler’s formula we have
y n+ 1= y n +h z n
From IVP2 and using Euler’s formula we have
z n+1=z n +h (6 y 2n−x n )
Hence
1 2
For i=0 (we have x 0=0 , x 1= , x 2= ∧x3 =1 )
3 3
1
y n+ 1= y n +h z n ⟹ y 1= y 0 +h z 0=1+ ( 1.2 )=1.4
3
1
z n+1=z n +h ( 6 y n−x n ) ⟹ z 1=z 0 + h ( 6 y 0−x 0 ) =1.2+
2 2
( 6 ( 1 )2−0 )=3.2
3
For i=1
y 2= y 1 +h z 1=2.466
For i=2
y 3= y ( 1 )= y 2 +h z 2=4.7966= y ( b ; δ 0 )
Similarly for IVP2 we have
{
'
y =z , y ( 0 )=1
IVP2: ' 2
z =6 y −x , z ( 0 )=1.5
Using Euler’s formula we get
y n+ 1= y n +h z n and z n+1=z n +h ( 6 y 2n−x n )
1
y 1= y 0 + h z 0=1+ (1.5 )=1.5
3
1
z 1=z 0 +h ( 6 y 0 −x 0) =1.5+
2
( 6 ( 1 )2−0 ) =3.5
3
y 2= y 1 +h z 1=2.666
( δn−δ n −1 )
δ n+1=δ n − ϕ ( δn )
ϕ ( δ n )−ϕ ( δ n−1 )
For n=1
( δ1 −δ 0 ) ( 1.5−1.2 )
δ 2=δ 1− ϕ ( δ 1) =1.5− ( 0.29 )=1.32
ϕ ( δ 1 ) −ϕ ( δ 0 ) 0.29−(−0.2034 )
Solve IVP3:
{ '
y ' =z , y ( 0 )=1
2
z =6 y −x , z ( 0 )=1.32=δ 2
1 1
y 1= y 0 + h z 0=1+ (1.32 ) =1.44 , z1 =z 0+ h ( 6 y 0−x 0 ) =1.32+ ( 6 ( 1 ) −0 )=3.32
2 2
3 3
y 2=2.51 , z 2=7.3672
y 3=4.96= y ( b )= y (1 ; 1.32)
| y ( 1; 1.32 ) −5|=|4.96−5|=0.035
ϕ ( δ 2 )= y ( 1; 1.32 ) −5=−0.035
{
'
y =z , y ( 0 )=1
Solve IVP4:
z =6 y 2−x , z ( 0 )=1.338
'
1
y 1= y 0 + h z 0=1+ (1.338 )=1.446
3
1
z 1=z 0 +h ( 6 y 0 −x 0) =1.338+ ( 6 )=3.338
2
3
1
y 2= y 1 +h z 1=1.446+ ( 3.338 )=2.558
3
1
y 3= y 2 +h z 2=2.558+ (7.4087 )=5.027= y ( 1 ) = y (1; 1.338)
3
ϕ ( δ 3 )= y ( 1; 1.338 )−5=5.027−5=0.027
( δ 3−δ 2 ) ( 1.338−1.32 )
ϕ ( δ¿¿ 4 )=δ 3− ϕ ( δ 3 )=1.338− ( 0.027 )=1.330 ¿
ϕ ( δ 3 ) −ϕ ( δ 2) 0.027+ 0.035
{
'
y =z , y ( 0 )=1
Solve IVP5: ' 2
z =6 y −x , z ( 0 )=1.330
1
y 1= y 0 + h z 0=1+ (1.330 )=1.443
3
1
z 1=z 0 +h ( 6 y 20 −x 0) =1.330+ ( 6 )=3.330
3
1
y 2= y 1 +h z 1=1.443+ ( 3.330 ) =2.553
3
Exercise
In finite difference methods, the derivatives in the differential equation are replaced with finite
difference approximations. As shown in Fig.below,
The domain of the solution [ a , b ] is divided into N subintervals of equal length h , that are
b−a
defined by ( N +1 ) points called grid points. The length of each sub-interval ¿ is then h= .
N
Points a and b are the end points and the rest of the points are interior points. The differential
equation is then written at each of the interior points of the domain. This results in a system of
linear algebraic equations when the differential equation is linear, or in a system of non-linear
algebraic equations when the differential equation is non-linear. The solution of the system is the
numerical solution of the differential equation.
Frequently, the central difference formulas are used in a finite difference methods since they give
better accuracy. Recall that for a function y (x ) that is given at points
( x 1 , y 1 ) , ( x 2 , y 2 ) , … , ( x i , y i ) ,… , ( x N +1 , y N +1 ) that are equally spaced the finite difference
' y i+1− y i
y i= +O(h)
h
' y i− y i−1
y i= +O( h)
h
Approximation of the first and the second derivatives at the interior points, with the central
difference formulas, are given by:
Three point forward and backward difference formula for first derivative
The central formula evaluates the first derivative at a given point x i by using the points x i−1 and
x i+1. Consequently, for a function that is given by a discrete set of n points, the central difference
formula is useful only for interior points and not for the end points ( x 0∨x n ). An estimate for the
first derivative at the endpoints, with error of O ( h2 ), can be calculated with three point for ward
and backward difference formulas.
The three-point forward difference formula calculates the derivatives at point x i from the value at
the point and the next two points, x i+1 and x i+2. It is assumed that the points are equally spaced
such that h=x i+2−x i+1=x i +1−x i.
2 3
y ' ' (xi ) ( 2h ) y ' ' ' (xi ) ( 2h )
'
y ( x i+2 )= y ( x i ) + y ( x i ) 2 h+ + ..........................**
2! 3!
'
−3 y ( x i ) +4 y ( x i+1 ) − y ( xi +2 ) 2
y ( xi )= +O( h ) which is called three-point forward difference
2h
formula. The formula can be used for calculating the derivatives at the first point of a function
that is given by a discrete set of n points.
The three-point backward difference formula yields the derivative at points x i from the value of
the function at that point and at the previous two points, x i−1 and x i−2.
y ' ' ( x i ) ( 2 h )2 3
y ' ' ' ( xi ) ( 2 h )
'
y ( x i−2 ) = y ( xi ) − y ( x i ) 2 h+ − ..........................****
2! 3!
Multiplying *** by 4 and subtracting **** we get
The finite difference approximation for a linear second-order differential equation of the form:
d2 y dy
2
=f ( x ) + g ( x ) y =r (x) (2)
dx dx
y i−1−2 y i + y i +1 y i+1− y i
is 2
+ f ( xi ) + g ( x i ) y i=r ( x i ) (3)
h 2h
The process of converting the differential equation(2), into the algebraic form, equation(3) at
each point x i is called discretization. For a two point BVP, the value of the solution at the end
points, y 1 and y N+1 are known. Equation (3) is written N−1 times for
i=2 , … , N . This gives a system of N−1 linear equations for the unknowns y 2 , … , y N , that can be
solved numerically with any of the methods.
The approach for solving a non-linear ODE with the finite difference method is the same as that
used for solving a linear ODE. The only difference is that the resulting system of simultaneous
equations is non-linear.
d2 y
1. 2
= y + x , y ( 1 )=0 , y ' ( 0 )=1,when h=0.5 , h=0.25
dx
2
d y dy
2. 2
+2 x +5 y−cos ( 3 x )=0 for , 0 ≤ x ≤ π
dx dx
d2 y dy
3. + x + y=2 x for , 0 ≤ x ≤1 , with y (0)=1 and y (1)=1
dx 2
dx
2
d y dy
4. −2 + y =0, with y (0)=0 and y ' ( 1 ) =5 , whenh=0.25
dx
2
dx
2
d y −0.2 x
5. −2 2
+ y=e ,With y ' ( 1 ) = y and y (0)=1 , divide the solution domain into 8 sub-
dx
intervals.
Solution
2
d y y i−1−2 y i + y i +1
1. 2
=¿ 2
= yi + x i
dx h
y i+1 + (−2−h ) y i + y i−1=h xi
2 2
For i=1
y 2 + (−2−0.5 ) y 1+ y 0 =0.5 x1
2 2
9 1
y 2− y 1 + y 0= x 1
4 4
−9 1
y1 + y0 = x1
4 4
−9 y 1 +4 y 0=x 1
−9 y 1 +4 y 0=0.5
{
−3 y 0 +4 y 1=1
−9 y 1+ 4 y 0 =0.5
2
d y −0.2 x
5. −2 2 + y=e with y ' ( 1 ) = y and y (0)=1
dx
1−0 1
N=8 means h= =
8 8
y i−1−2 y i+ yi +1 −0.2 xi
−2( 2
)+ y i=e
h
1
−2 y i−1+ ( h2 +4 ) y i−2 y i+1=h 2 e
−0.2 xi
since h=
8
( )
257 e−0.2 x i
−2 y i−1+ y −2 y i+1=
64 i 64
−0.2 x i
−128 y i−1+ 257 yi −128 y i+1=e
For i=1
−0.2 x1
−128 y 0 +257 y 1−128 y 2=e
3 yi −4 y i−1 + y i−2
= yi
2h
11 y 8−16 y 7 +4 y 6=0
16 4
y 8= y 7− y
11 11 6
( )( )
y1 1.7049
y2 2.4155
y3 3.1376
y4 3.8769
=
y5 4.6395
y6 5.4314
y7 6.2590
7.1298
y8
Chapter 6
Example
( )
0 0 −2
Given the matrix A= 1 2 1 then,
1 0 3
a. Find the Eigen values of A .
b. Find the Eigen vectors of A
| |
λ 0 2
λ−2 −1 =λ [ ( λ−2 )( λ−3 ) ] +2 ( λ−2 )=( λ−2 ) ( λ −3 λ+2 )
2
det( λI − A )= −1
−1 0 λ−3
()
x
b. Let the corresponding vector be y
z
| |( ) ( ) | |( ) ( )
λ 0 2 x 0 2 0 2 x 0
−1 λ−2 −1 y = 0 ⇒ −1 0 −1 y = 0 ⇒ 2 x +2 z =0 ⇒ x=−z
−1 0 λ−3 z 0 −1 0 −1 z 0
Let x=s∧ y=t
()( )( )() ( ) ()
x s s 0 1 0
y = t = 0 + t =s 0 +t 1 ,t , s ∈ R
z −s −s 0 −1 0
( ) ()
1 0
0 ∧ 1 are the corresponding eigen vectors w.r.t λ=2
−1 0
For λ=1
()
x
Let the corresponding eigen vector be y
z
| |( ) ( ) | |( ) ( )
λ 0 2 x 0 1 0 2 x 0
−1 λ−2 −1 y = 0 ⇒ −1 −1 −1 y = 0
−1 0 λ−3 z 0 −1 0 −2 z 0
⇒ x +2 z=0 ⇒ x=−2 z∧−x− y −z=0 but x=−2 z ⇒−(−2 z )− y−z=0 ⇒ y =z
()( ) ( )
x −2 z −2
y = z =z 1 , z∈ R
z z 1
()
−2
1 is the corresponding eigen vector For λ=1
1
1. The sum of the Eigen values of a matrix is the sum of the elements of the principal (main)
diagonal.
2. The product of the eigen values of a square matrix A is equals to the determinant of A .
1
3. If λ is an eigen value of a square matrix A then is the eigen value of the inverse of
λ
matrix A( A−1)
4. If λ 1 , λ2 , … , λn are the Eigen value of a square matrix A then Am has the Eigen values
λ m1 , λ m2 , … , λ mn where m is positive integer.
Methods of finding Eigen values
There are several methods for finding the Eigen values of a general matrix or a
symmetric matrix.
Among those method we will see only the power method and the Householder's method
for finding the Eigen value of a matrix including the corresponding Eigen vector.
1. power method
The method for finding the largest Eigen value in magnitude and the corresponding Eigen vector
of the Eigen value problem Ax=λx is called the power method.
What is the importance of this method? The necessary and sufficient condition for convergence
of the
Gauss-Jacobi and Gauss-Seidel iteration methods is that the spectral radius of the iteration matrix
H is less than one unit, that is, ρ(H )<1 , where ρ(H )is the largest eigen value in magnitude of
H( ρ ( H )=max i=1|λ i| ). If we write the matrix formulations of the methods, then we know H.
n
We can now find the largest Eigen value in magnitude of H, which determines whether the
methods converge or not.
We assume that λ 1 , λ2 , … , λn are distinct eigen values such that |λ 1|>|λ 2|> …>|λ n|.
Consider Ax=b .
We have to splitting matrix A as A=D+ L+ U , where
[ ]
a11 ⋯ a1 n
A= ⋮ ⋱ ⋮
a n1 ⋯ a nn
[ ]
a11 ⋯ 0
D= ⋮ ⋱ ⋮ → diagonal ¿
0 ⋯ ann
[ ]
0 ⋯ 0
L= ⋮ ⋱ ⋮ → lower triangular ¿
an 1 ⋯ 0
[ ]
0 ⋯ a1 n
U = ⋮ ⋱ ⋮ →upper triangular ¿
0 ⋯ 0
2
We have A V =λ c 1 v 1+ c 2
2
1
(
λ2 2
λ1 2 ( )
v + …+c n
λn 2
λ1 n
v . ( ) )
( ( ) ( ) )
3 3
λ2 λ
A3 V = λ31 c 1 v 1 +c 2 v 2 +…+c n n v n .
λ1 λ1
⋯ ⋯ ⋯
( ( ) ( ) )
k k
k k λ2 λn
A V = λ c1 v 1 +c 2
1 v 2 +…+ c n v .
λ1 λ1 n
( ( ) ( ) )
k+1 k +1
λ2 λn
Ak +1 V =λ1k+1 c 1 v 1+ c 2 v 2 +…+ c n vn .
λ1 λ1
( )
k+1
λn λn
Since |λ 1|>|λ 2|> …>|λ n|, −1< <1⟹ → 0 , as k → ∞
λ1 λ1
k+1 k +1
A V λ1 c 1 v 1
lim k
= k =λ1
k→∞ A V λ 1 c1 v 1
A k+1 V r
λ 1=lim , r =1, 2 , 3 ,… , n
k →∞ Ak V r
A k+1 V r ( y k+1 )r
Then λ 1=lim k can be written as λ 1=lim , r=1 , 2 ,3 ,… , n and v k+1is the required
k →∞ A Vr k →∞ ( v k )
r
Eigen vector.
Remark: It may be noted that as k → ∞ , mk+1 also gives |λ 1|.
The eigenvectors are computed very accurately by this method. Further, the method is powerful
to calculate accurately the eigenvectors, when the eigenvalues are not well separated.
Example: Find the largest eigen values in modulus and the corresponding eigen vector of the
matrix.
a. A=
1 2
3 4 ( )
( )
25 1 2
b. A= 1 3 0
2 0 −4
Solution :Let the initial approximation to the eigen vector be v 0. Then the power method
is given by
{
y k+1 =A v k
y k+1
v k +1=
m k+1
Where mk+1 is the largest element in magnitude of y k +1. The dominant eigen value in
magnitude is given by
( y k+1 )r
λ 1=lim , r=1,2,3 , … , n and v k+1 is the required eigen vector.
k →∞ ( v k )
r
T
Let v 0=[ 1,1 ] . We have the following results.
[] y 1
[][ ]
y 1= A v 0= 3 ,m1=7 , v 1= 1 = 3 = 0.42857
7 m1 7 7 1
y = A v =[ ] m 5.28571 [ 5.28571 ] [ 1 ]
2.42857 y 1 2.42857
2 0.45946
2 1 , m =5.28571 , v = =
2 2 =
5.28571 2
y 3= A v 2= [2.459946
5.37838 ] ,m =5.37838 , v = =
3
y
3
3 1
[ 2.459946
m 5.37838 5.37838
3
] =[
1 ]
0.45729
y = A v =[ ] [ ]=[
1 ]
2.45729 y 1 4 2.45729 0.45744
4 3 , m =5.37187
4 , v = =
4
5.37187 m 5.37187 5.37187
4
[ ]
y 5= A v 4=
2.45744
5.37232
y5
, m5=5.37232 , v 5= =
1 2.45744
m5 5.37232 5.37232
= [
0.45743
1 ][ ]
y =A v =
6 [2.45743
5.37229 ]
5
Householder Algorithm
In Householder’s method, A is reduced to the tridiagonal form by orthogonal transformations
representing reflections. This reduction is done in exactly n – 2 transformations.
The transformations are of the form
T n T T 2 2 2
P=I−2W W where W ∈ R , such that W =[ x 1 , x 2 , … , x n ] and W W =x 1+ x2 +…+ x n =1.
P is symmetric and orthogonal. The vectors W are constructed with the first (r −1) components
as zero, that is
T 2 2 2
W r =(0,0 , … ,0 , x r , xr +1 , … , x n ) with x r + xr +1 +…+ x n=1 . With this choice of W r , form the
matrices
T
Pr =I −2W r W r . The similarity transformation is given by
A Pr =Pr A Pr =P r A P r . Put A=A 1 and form successively
−c 1 T
Pr
Ar =Pr Ar −1 Pr , r =2,3 , … ,n−1
At the first transformation, we find xr ’ s such that we get zeros in the positions
(1 , 3) ,(1 , 4) , ... ,(1 ,n) and in theCorresponding positions in the first column.
In the second transformation, we find xr ’ s such that we get zeros in the positions
(2 , 4) ,(2 , 5), ... ,(2 , n) and in the
Corresponding positions in the second column. In (n – 2) transformations, A is reduced to the
tridiagonal form.
Note:
1. A square matrix of order n is said to be orthogonal matrix if and only if A At =I = At A
2. An n × nmatrix A is called tridiagonal matrix if a ij=0whenever |i− j|>1.
3.
For example, consider
[ ]
a 11 a12 a13 a14
a a22 a23 a24
A= 21
a 31 a32 a33 a34
a 41 a42 a43 a44
2
x 2=
1
2
1+ (
a12 sign ( a12 )
S1 )
a13 sign ( a12 )
x 3=
2 S1 x2
a 14 sign ( a12)
x4 =
2 S1 x2
This transformation produces two zeros in the first row and first column.
One more transformation produces zeros in the (2 , 4) and ( 4 , 2) positions.
Example
Find all the eigenvalues of the matrix
[ ]
1 2 −1
A= 2 1 2 Using the Householder method.
−1 2 1
Solution
T 2 2
Choose W 2 =[0 , x 2 , x 3 ] such that x 2+ x3 =1. The parameters in the first House-holder
transformation are obtained as follows:
2
x 2=
1
2 (a 1
1+ 12 sign(a12) = 1+
S1 2
2
=
2+ √5
√5 2 √5 ) ( )
⟹ x 2=
2+ √ 5
2√5 √
√ √ √ )
(
x 3=
a13
sign ( a12 )=
−1
=
−1 √ √2 5
2 S1 x 2 2 S1 x2 2 5 2+ 5
[ ]
1 0 0
T
P2=I 3−2 W 2 W = 0 −2/ √ 5 1/ √ 5
2
0 1/ √ 5 2/ √ 5
The required Householder transformation is
[ ]
1 − √5 0
A2=P 2 A1 P2= − √5 −3/5 −6/5 where A1= A
0 −6/5 13/5
To find the eigen value of A
λ−1 √5
|
Let f n=det ( λI − An ) and det ( λI − A2 ) = √ 5 λ +3/5
0 6/5
0
6/5
|
λ−13 /5
f 0=1
f 1=λ−1
f 2= | λ−1
5
5
λ+3/ 5
2 2
=λ − λ−
5
28
5 |
f 3=
| λ−1
√5
0
√5
λ+3 /5
6 /5
0
λ−13/5
|
6/ 5 = λ −3 λ −6 λ+ 16=( λ−2 ) ( λ −λ−8 )
3 2 2
Since f 3=0 , for λ=2, λ=2 is the eigen value of matrix A . The other two eigen values lies in the
interval (−3 ,−2 ) and ( 3,4 ). So we can find the other two eigen values using Newton-Raphson
method. That is
f 3 ( λk ) λ3k −3 λ2k −6 λk +16
λ k+1= λk − =λ k − for k =0,1,2 , …
f '3 ( λk ) 3 λ2k −6 λ k −6
Consider the interval ( 3,4 )
3+4
λ 0= =3.5
2
After a certain iteration we get λ=3.372 .
Consider the interval (−3 ,−2 )
−3−2
λ 0= =−2.5
2
After a certain iteration we get λ=– 2.372 .
Example
Use the House-holder’s method to reduce the given matrix A into the tridiagonal form
[ ]
4 −1 −2 2
A= −1 4 −1 −2
−2 −1 4 −1
2 −2 −1 4
Solution
Let W 2=[0 , x2 , x3 , x 4 ]T where x 22+ x23 + x 24 =1
2
x 2=
1
2 (
a sign(a 12 ) 1
1+ 12
S1
= 1+
2 3
=
) (
(−1)(−1) 2
3 )
x 2=
√ 2
3
a13 1
x 3= sign ( a12 )=
2 S1 x 2 √6
a14 −1
x4 = sign ( a12) =
2 S1 x2 √6
[ ]
1 0 0 0
0 −1/ 3 −2/T3 2 /3
So P2=I 4 −2W 2 W = 2
0 −2 /3 2/3 1 /3
0 2/3 1/3 2 /3
A2=P 2 A1 P2 where A1= A
[ ]
4 3 0 0
3 16 /3 2/3 1/3
A2=
0 2 /3 16/3 −1/3
0 1/3 −1/3 4/3
T 2 2
W 3 =[ 0,0 , x3 , x 4 ] where x 3+ x 4=1
2
x 3=
1
2 (
a sign(a23 ) 1
1+ 23
S2
= 1+
2
2/3
√ 5/ 3 ) (
⟹ x 3=
2+ √ 5
2 √5 )
sign ( a23 )= √
a24 2 √5
x4 =
2 S2 x3 2 √ 2+ √ 5
( )
T
W 3 = 0,0 , √ , √ √
2+ 5 2 5
2 √ 5 2 √ 2+ √ 5
P3=I 4 −2W 3 W T3
The required Householder transformation is
[ ]
4 0 0 3
−5
3 16/3 0
A3 =P 3 A2 P3= 3√5
0 −5/3 √ 5 16 /3 9/5
0 0 9 /5 12/5
Questions
Time(sec) 0 5 10 15 20
Velocity(m/sec) 0 3 14 69 228
1. Compute f ' (0) and f ' ' (4 )for the data
x 0 1 2 3 4
f ( x) 1 2.718 7.381 20.086 54.598
6
2. Using trapezoidal rule, find∫ f ( x )dx from the following set of value of
0
x and f ( x).
x 0 1 2 3 4 5 6
f (x) 1.56 3.64 4.62 5.12 7.05 9.22 10.44
1
3. Using the Simpson’s 1/3 rule evaluate ∫ x e x dx taking four interval and
0