0% found this document useful (0 votes)
16 views30 pages

PSNM - Ch. 6

Uploaded by

atayappa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views30 pages

PSNM - Ch. 6

Uploaded by

atayappa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

FACULTY OF ENGINEERING AND TECHNOLOGY

DEPARTMENT OF APPLIED SCIENCE AND HUMANITIES


4th SEMESTER B.TECH PROGRAMME
PROBABILITY, STATISTICS AND NUMERICAL METHODS
(203191251)
ACADEMIC YEAR 2019-2020

Numerical Integration:
The process of evaluating a definite integral from a set of tabulated values of f (x ) is called numerical
integration. This process when applied to a function of a single variable is known as quadrature. In
numerical integration, f (x ) is represented by an interpolation formula and then it is integrated
between the given limits. In this way, the quadrature formula is derived for approximate integration of a
function defined by a set of numerical values only.

Newton-Cotes Methods:
Let the function y  f (x) takes values y0 , y1 , y 2 ,............ y n for x , x1 , x 2 ,.............x n respectively.

b
Let I   f ( x)dx
a
. Dividing the interval (a, b) into n sub-intervals of width h such that

x0  a , x1  x0  h , x2  x0  2h ,......., xn  x0  nh  b

b x0  nh

  f ( x)dx   f ( x)dx
a x0

Putting x  x0  rh , dx  hdr

When x  x0 , r  0

When x  x0  nh , r  n

b n
 
a
f ( x)dx  h  f ( x0  rh )dr
0

 r (r  1) 2 r (r  1)( r  2) 3 
n
 h   y 0  ry 0   y0   y 0  ........ dr
0  
2! 3!
n
 r3 r2   r4 
2      r3  r2 
r
 h ry 0  y 0   3 2  y  
2 4 3 y  .........
2  2 
0
 6  0

   
    0
x0  nh
 n n(2n  3) 2 n ( n  2) 2 3 
 
x0
f ( x)dx  hn  y 0  y 0 
 2 12
 y0 
24
 y 0  ........

This equation is known as the Newton-Cotes quadrature formula.

1) Trapezoidal Rule:
By the Newton-Cotes quadrature formula,

x0  nh
 n n(2n  3) 2 n ( n  2) 2 3 
 
x0
f ( x)dx  hn  y 0  y 0 
 2 12
 y0 
24
 y 0  ........

Putting n  1 in above formula and ignoring the differences of order higher than one.

x0  h
 1 
  f ( x)dx  h  y
x0
0  y 0 
2 
 1 
 h  y 0  ( y1  y 0 )
 2 
h
 ( y 0  y1 )
2

Similarly,

x0  2 h
h
  f ( x)dx  2 ( y
x0  h
1  y2 )

.
.
.
x0  nh
h
 f ( x)dx  2 ( y
x0  ( n 1) h
n 1  yn )

Adding all these integrals,


x0  nh

 f ( x)dx  2 ( y  y n )  2( y1  y 2  .....  y n 1 )
h
 0
x0

This is known as the trapezoidal rule.


Example: Evaluate e x dx , with n  10 using the trapezoidal rule.
0

Solution:

a  0, b  1, n  10
b  a 1 0
h   0.1
n 10
y  f ( x)  e x

x 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
1 1.1052 1.2214 1.3499 1.4918 1.6487 1.8221 2.0138 2.2255 2.4596 2.7183
f ( x)
y0 y1 y2 y3 y4 y5 y6 y7 y8 y9 y10

By the trapezoidal rule,

x0  nh
h
  f ( x)dx  ( y0  yn )  2( y1  y2  .....  yn1 )
x0
2
1
0.1
  e dx 
x
( y0  y10 )  2( y1  y2  .....  y9 )
0
2
0.1 (1  2.7183)  2(1.1052  1.2214  1.3499  1.4918  1.6487 

2   1.8211  2.0138  2.2255  2.4596) 
 1.7196

Example: Given the data below, find the isothermal work done on the gas if it is compressed from
v2

v1  22 L to v2  2 L .Use W    p dv
v1

v1 , L 2 7 12 17 22
P, atm 12.20 3.49 2.049 1.44 1.11

Solution:

v1  22 , v2  2 , h  5

By the trapezoidal rule,

x0  nh
h
  f ( x)dx  ( y0  yn )  2( y1  y2  .....  yn1 )
x0
2

v2

and we have W    p dv
v1
2
W    p dv
22
22
W  p dv
2

h
  ( y0  y4 )  2( y1  y2  y3 ) 
2
5
  (12.20  1.11)  2(3.49  2.049  1.44) 
2
 68.17

1
2) Simpson’s Rule:
3

By the Newton-Cotes quadrature formula,

x0  nh
 n n(2n  3) 2 n ( n  2) 2 3 
 
x0
f ( x)dx  hn  y 0  y 0 
 2 12
 y0 
24
 y 0  ........

Putting n  2 in above formula and ignoring the differences of order higher than two.
x0  2 h
 1 
  f ( x)dx  2h  y
x0
0  y 0  2 y 0 
6 
  y  2 y1  y 0 
 2h  y 0  ( y1  y 0 )   2 
  6 
h
 ( y 0  4 y1  y 2 )
3

Similarly,

x0  4 h
h
  f ( x)dx  3 ( y
x0  2 h
2  4 y3  y 4 )

.
.
.
x0  nh
h
 f ( x)dx  3 ( y
x0  ( n 1) h
n2  4 y n 1  y n )

Adding all these integrals,

x0  nh

 f ( x)dx  3 ( y  y n )  4( y1  y 3  .....  y n 1 )  2( y 2  y 4  .....  y n  2 )


h
 0
x0

1
This is known as Simpson’s Rule.
3

Example: Consider the following values:

x 10 11 12 13 14 15 16
y 1.02 0.94 0.89 0.79 0.71 0.62 0.55
16
1
Find  f ( x)dx by Simpson’s 3 Rule.
10

Solution:
a  10, b  16, h  1

1
By Simpson’s Rule
3
x0  nh
h
  f ( x)dx  ( y0  yn )  4( y1  y3  .....  yn1 )  2( y2  y4  .....  yn2 )
x0
3
16
1
  f ( x)dx  3 (1.02  0.55)  4(0.94  0.79  0.62)  2(0.89  0.71)
10

 4.7233

Example: A rocket is launched from the ground. Its acceleration is registered during the first 80 seconds
and is given as follows.

t (s) 0 10 20 30 40 50 60 70 80
2
a(m / s ) 30 31.63 33.34 35.47 37.75 40.33 43.25 46.69 50.67
1
By Simpson’s rule, find the velocity t  80s .
3

Solution:

a  10, b  16, h  1

1
By Simpson’s rule,
3
80
h
 Velocity   a dt  ( y0  y8 )  4( y1  y3  y5  y7 )  2( y2  y4  y6 )
0
3
10 (30  50.67)  4(31.63  35.47  40.33  46.69) 
 
3   2(33.34  37.75  43.25) 
 3086.1 m / s

3
3) Simpson’s Rule:
8

By the Newton-Cotes quadrature formula,


x0  nh
 n n(2n  3) 2 n ( n  2) 2 3 
 
x0
f ( x)dx  hn  y 0  y 0 
 2 12
 y0 
24
 y 0  ........

Putting n  3 in above formula and ignoring the differences of order higher than three.

x0  3 h
 3 3 1 
  f ( x)dx  3h  y
x0
0 
2
y 0  2 y 0  3 y 0 
4 8 
3h
 ( y 0  3 y1  3 y 2  y 3 )
8

Similarly,

x0  6 h
3h
  f ( x)dx 
x0  3 h
8
( y3  3 y 4  3 y5  y6 )

.
.
.
x0  nh
3h
 f ( x)dx 
x0  ( n  3 ) h
8
( y n 3  3 y n  2  3 y n 1  y n )

Adding all these integrals,

x0  nh

 f ( x)dx  8 ( y  y n )  2( y3  y 6 .....  y n 3 )  3( y1  y 2  y 4  y5 .....  y n 1 )


3h
 0
x0

3
This is known as Simpson’s Rule.
8
3
1
Example: Evaluate  1  x dx , with n  6 using Simpson’s 3/8 rule.
0

Solution:

a  0, b  3, n  6
b  a 30
h   0.5
n 6
1
y  f ( x) 
1 x
x 0 0.5 1.0 1.5 2.0 2.5 3.0
f ( x) 1 0.6667 0.5 0.4 0.3333 0.2857 0.25

By Simpson’s 3/8 rule,

x0  nh
3h
  f ( x)dx  ( y0  yn )  2( y3  y6 .....  yn3 )  3( y1  y2  y4  y5 .....  yn1 ) 
x0
8
3
1 3h
  1  x dx  8 ( y
0
0  y6 )  2( y3 )  3( y1  y2  y4  y5 ) 

3
1 3(0.5)
  1  x dx  (1  0.25)  2(0.4)  3(0.6667  0.5  0.3333  0.2875) 
0
8
 1.3888

Example: Find the volume of a solid of revolution formed by rotating about the x  axis the area
bounded by the lines x  0, x  1.5, y  0 and the curve passing through the following points:

x 0.00 0.25 0.50 0.75 1.00 1.25 1.50


2
y 1.00 0.9826 0.9589 0.9089 0.8415 0.7624 0.7589

Solution:

Volume is given by V    y 2 dx

x 0.00 0.25 0.50 0.75 1.00 1.25 1.50


2
y 1.00 0.9826 0.9589 0.9089 0.8415 0.7624 0.7589

h  0.25

By Simpson’s 3/8 rule,


x0  nh
3h
  f ( x)dx  ( y0  yn )  2( y3  y6 .....  yn3 )  3( y1  y2  y4  y5 .....  yn1 ) 
x0
8
3h
  y dx  8 ( y  y6 )  2( y3 )  3( y1  y2  y4  y5 ) 
2
0

3(0.25) (1.00  0.5759)  2(0.8261)  3(0.9655 



8   0.9195  0.7081  0.5812) 
 1.1954

Volume    y 2 dx   (1.1954)  3.7555

Error formulae for Trapezoidal and Simpson’s formulas:


1. Error in Trapezoidal rule:

(b  a)h 2
E y ''( x )
12

1
2. Error in Simpson’s rule:
3
(b  a)h4 iv
E y (x )
180
3
3. Error in Simpson’s rule:
8

3h5 iv
E y (x )
80

Gaussian Quadrature Formulae:


In Newton-Cotes quadrature formula, we require values at equally spaced points of the interval.

The Gaussian quadrature formula uses the values of x which are not all equidistant points.

b
Consider I   f (t )dt
a
1
1
The substitution t 
2
[(b  a) x  (b  a )] transforms the above integral into  f ( x)dx .
1

An n  point Gaussian quadrature formula is a quadrature formula constructed to give an exact result
for polynomials of degree 2n 1or less by a suitable choice of the point xi and weights wi for
i  1, 2,3,.....n . Gauss quadrature formula can be expressed as

1 n

 f ( x)dx   wi f ( xi )
1 i 1

1) One-point Gaussian Quadrature Formula:

Consider a function f ( x ) over the interval [-1, 1] with sampling point x1 and weight w1 .

The one-point Gaussian quadrature formula is

 f ( x)dx  w f ( x )
1
1 1

This formula will be exact for polynomials of degree up to 2n  1  2(1)  1  1 , i.e. it is exact for

f ( x)  1 and x

1 n
Substituting f ( x ) in the formula  f ( x)dx   wi f ( xi ) , we have
1 i 1

 1 dx  w
1
1

x 1  w1
1

2  w1.............................................................................(1)
1

 x dx  w x
1
1 1

1
x2
 w1 x1
2 1

0  w1 x1..........................................................................(2)

Solving (1) and (2), we get

w1  2
x1  0
1
Hence ,  f ( x)dx  2 f (0)
1

This is known as one-point Gaussian quadrature formula. This formula is exact for polynomials up to
degree one.

2) Two-point Gaussian Quadrature Formula:

Consider a function f ( x ) over the interval [-1, 1] with sampling point x1 , x2 and weight w1 , w2
respectively.

The two-point Gaussian quadrature formula is

 f ( x)dx  w f ( x )  w
1
1 1 2 f ( x2 )

This formula will be exact for polynomials of degree up to 2n  1  2(2)  1  3 , i.e. it is exact for

f ( x)  1, x, x2 and x3 .

Similarly by above procedure we have

 1   1 
1

 f ( x)dx  f  
1

3
f
 3

This is known as two-point Gaussian quadrature formula. This formula is exact for polynomials up to
degree three.

3) Three-point Gaussian Quadrature Formula:

Consider a function f ( x ) over the interval [-1, 1] with sampling point x1 , x2 , x3 and weight w1 , w2 , w3
respectively.

The three-point Gaussian quadrature formula is


1

 f ( x)dx  w f ( x )  w
1
1 1 2 f ( x2 )  w3 f ( x3 )

This formula will be exact for polynomials of degree up to 2n  1  2(3)  1  5 , i.e. it is exact for

f ( x)  1, x, x 2 , x3 , x 4 and x 5 .

Similarly by above procedure we have

1
5  3 8 5  3
 f ( x)dx  9 f     f  0   f  
1  5 9 9  5 

This is known as two-point Gaussian quadrature formula. This formula is exact for polynomials up to
degree three.

Example:

1
dx
Evaluate  1 x
1
2
by one-point, two-point and three point Gaussian formulae.

Solution:

1
f ( x) 
1  x2

By the one-point Gaussian formula,

1
1
 1 x
1
2
dx  2 f (0)

 1 
 2 
 1 0 
2

By the two-point Gaussian formula,


 1   1 
1
1
 1 x
1
2
dx  f  

 f 
3  3

1 1
 
1 1
1 1
3 3
 1.5

By the three-point Gaussian formula,

5  3 8 5  3
1
1
 1 x dx  f     f  0   f  
1
2
9  5 9 9  5 
   
5 1  8 5 1 
    (1)   3 
9  1 3  9 9  1 
 5  5
 1.5833

Example:

1
dt
Evaluate  1  t by one-point, two-point and three point Gaussian formulae.
0

Solution:

Here, the original limits 0 to 1 of the integration have to be changed to -1 to 1 for this we use the
substitution,

1
t  [(b  a) x  (b  a )] where a  0 and b  1
2
1
 t  [(1  0) x  (1  0)]
2
1
 ( x  1)
2

1
 dt  dx and x  2t  1
2
t 0  x  1
t 1  x 1

1
dt
Now, I  
0
1 t
1
dx
  3 x
1

1
Here , f ( x) 
3 x

By the one-point Gaussian formula,

1
1
dx
 3  x  2 f (0)  2  3   0.6667
1

By the two-point Gaussian formula,

 1   1 
1
dx
 3  x  f  
1

3
f
 3
  0.6923

By the three-point Gaussian formula,

1
dx 5  3 8 5  3
 3  x  9 f     f  0   f    0.6931
1  5 9 9  5 
Numerical Solution of Ordinary Differential Equations:-

The fundamental laws of physics, mechanics, electricity and thermodynamics are usually based
on empirical observations that explain variations in physical properties and states of the systems. Rather
than describing the state of physical system directly, the laws are usually couched in terms of spatial and
temporal changes. The following table gives a few examples of such fundamental laws that are written
in terms of the rate of change of variables (t = time and x = position)

Physical Law Mathematical Expression Variables and Parameters

Newton’s second law of dv F Velocity(v), force (F) and mass



motion dt m (M)

Fourier’s Law of Heat dT Heat flux (q), thermal


q  k
Conduction dx conductivity(k) and
temperature (T)

Faraday’s Law (Voltage


VL  L
di Voltage drop ( VL ),
drop across an inductor) dt inductance4 (L) and current (i)

The above laws define mechanism of change. When combined with continuity laws for energy, mass or
momentum, differential equation arises. The mathematical expression in the above table is an example
of the Conversion of a Fundamental law to an Ordinary Differential Equation. Subsequent integration of
these differential equations results in mathematical functions that describe the spatial and temporal
state of a system in terms of energy, mass or velocity variations. In fact, such mathematical relationships
are the basis of the solution for a great number of engineering problems. But, many ordinary differential
equations arising in real-world applications and having lot of practical significance cannot be solved
exactly using the classical analytical methods. These ode can be analyzed qualitatively. However,
qualitative analysis may not be able to give accurate answers. A numerical methodcan be used to get an
accurate approximate solution to a differential equation. There are many programs and packages
available for solving these differential equations. With today's computer, an accurate solution can be
obtained rapidly. In this chapter we focus on basic numerical methods for solving initial value problems.
Analytical methods, when available, generally enable to find the value of y for all values of x.
Numerical methods, on the other hand, lead to the values of y corresponding only to some finite set of
values of x. That is the solution is obtained as a table of values,rather than as continuous function.
Moreover, analytical solution, if it can be found, is exact, whereas a numerical solution inevitably
involves an error which should be small but may, if it is not controlled, swamp the true solution.
Therefore we must be concerned with two aspects of numerical solutions of ODEs: both the method
itself and its accuracy.

In this chapter some methods for the numerical solution of ODEs are described.

The general form of first order differential equation, in implicit form, is F ( x, y, y / )  0 and in
dy
the explicit form is  f ( x, y ) . An Initial Value Problem (IVP) consists of a differential equation and a
dx
condition which the solution much satisfies (or several conditions referring to the same value of x if the
differential equation is of higher order). In this chapter we shall consider IVPs of the form

dy
 f ( x, y ), y ( x0 )  y0 . (1)
dx

Assuming f to be such that the problem has a unique solution in some interval containing x 0, we shall
discuss the methods for computing numerical values of the solution. These methods are step-by-step
methods. That is, we start from y0  y ( x0 ) and proceed stepwise. In the first step, we compute an
approximate value y1 of the solution y of (1) at x = x1 = x0 + h. In the second step we compute an
approximate value y2 of the solution y at x = x2 = x0 + 2h, etc. Here h is fixed number for example 0.1 or
0.001 or 0.5 depends on the requirement of the problem. In each step the computations are done by
the same formula.

The following methods are used to solve the IVP (1).

1. Taylor’s Series Method

2. Euler and Modified Euler Method

3. Runge – Kutta Method

4. Milne’s Method

1. Taylor’s Series Method:


dy
Consider an IVP  f ( x, y ), y ( x0 )  y0 . Let us approximate the exact solution y(x) to a power
dx
series in ( x  x0 ) using Taylor’s series. The Taylor’s series expansion of y(x) about the point x  x0 is
( x  x0 ) i ( x  x0 ) 2 ii ( x  x0 )3 iii ( x  x0 ) 4 iv
y( x)  y( x0 )  y ( x0 )  y ( x0 )  y ( x0 )  y ( x0 ) 
1! 2! 3! 4!
……………………….. (1)

dy
From the differential equation, we have y i ( x)   f ( x, y ) . Differentiating this successively, we can
dx
get y ii ( x), y iii ( x), y iv ( x), etc. Putting x  x0 and y  y0 , the values of y ii ( x0 ), y iii ( x0 ), y iv ( x0 ), etc.
can be obtained. Hence the Taylor’s series (1) gives the values of y for every value of x for which (1)
converges.

On finding the value of y1 for x  x1 from (1), y ii ( x), y iii ( x), y iv ( x), etc. can be evaluated at x  x1
from the differential equation

Example: Find by Taylor’s series method the value of y at x = 0.1 and 0.2 five places of decimals for the
dy
IVP  x 2 y  1, y (0)  1
dx

Solution:

Given x0  0, y 0  1 and f ( x, y )  x 2 y  1

Taylor’s series expansion about the point x  0( x0 ) is

( x  0) i ( x  0)2 ii ( x  0)3 iii ( x  0)4 iv


y ( x)  y (0)  y (0)  y (0)  y (0)  y (0) 
1! 2! 3! 4!

x 2 ii x3 x 4 iv
i.e. y ( x)  y (0)  xy i (0)  y (0)  y iii (0)  y (0)  (1)
2 6 24

It is given that y ( 0)  1

dy
 y i ( x)  x 2 y  1  y i (0)  1
dx

Differentiating y i ( x)  x 2 y  1 successively three times and putting x = 0 & y = 1, we get

yi ( x)  2 xy  x 2 yi  y ii (0)  0

y iii ( x)  2 y  4 xy i  x 2 y ii  y iii (0)  2

y iv ( x)  6 y i  6 xy ii  x 2 y iii  y iv (0)  6

Putting the values of y(0), y i (0), y ii (0), y iii (0), y iv (0) in (1), we get
x2 x3 x4
y ( x)  1  x(1)  (0)  (2)  (6)
2 6 24

x3 x4
y ( x)  1  x  
3 4

Hence, y(0.1) = 0.90033 and y(0.2) = 0.80227.

dy
Example:Using Taylor’s series method solve  x 2  y, y (0)  1 at 0.1 ≤ x ≤ 0.4. Compare the
dx
values with the exact solution.

Solution:

Given x0  0, y 0  1 and f ( x, y )  x 2  y

Taylor’s series expansion about the point x  0 is

x 2 ii x3 x 4 iv
y ( x)  y (0)  xy i (0)  y (0)  y iii (0)  y (0)  (4)
2 6 24

It is given that y (0)  0

dy
 y i ( x)  x 2  y  yi (0)  (0)2  1  1
dx

Differentiating y i ( x)  x 2  y successively and putting x =0, y = 1, we get

y ii ( x)  2 x  y i  yii (0)  0 yi (0)  0  (1)  1

y iii ( x)  2  y ii  yiii (0)  2  yii (0)  1

y iv ( x)   y iii  yiv (0)   yiii (0)  1

Putting the values of y(0), y i (0), y ii (0), y iii (0), y iv (0) in (4), we get

x2 x3 x4
y ( x)  1  x   
2 6 24

(0.1) 2 (0.1) 3 (0.1) 4


Hence, y (0.1)  1  (0.1)    = 0.9051625
2 6 24

(0.2) 2 (0.2) 3 (0.2) 4


y (0.2)  1  (0.2)    = 0.8212667
2 6 24
(0.3) 2 (0.3) 3 (0.3) 4
y (0.3)  1  (0.3)    = 0.7491625
2 6 24

(0.4) 2 (0.4) 3 (0.4) 4


y (0.4)  1  (0.4)    = 0.6896.
2 6 24

2. Euler’s Method:

dy
Consider the IVP  f ( x, y ), y ( x0 )  y0 . The following two methods can be used to determine the
dx
solution at a point x  xn  x0  nh .

The solution of the differential equation is represented by the curve as shown in the fig. The point
( x0, y0 ) lies on the curve. The equation of tangent to the curve at the point is given by

 dy 
y  y0   ( x  x0 )  f ( x0 , y0 )( x  x0 )
 dx x  x 
 0 

y  y0  f ( x0 , y0 )( x  x0 )

But we know that h  xn  xn 1 ,

Hence, yn1  yn  hf ( xn , yn ), n  0,1, 2,3,

Euler’s Method:

ynE1  yn  hf ( xn , yn ), n  0,1, 2,3, (1)

Modified Euler’s Method:

y n 1  y n 
h
2
 
f ( x n , y n )  f ( x n 1 , y nE1 ) , n  0,1,2,3,  (2)
Remark:

1. The formulae (1) and (2) are also known as Euler’s Predictor – Corrector formula.
When Modified Euler’s method is applied to find the solution at a given point, we first find the solution
at that point by using Euler’s method and the same will be used in the calculation of Modified Euler’s
method. Also Modified Euler’s method has to be applied repeatedly until the solution is stationary.

dy 2x
Example:Using Euler’s method, find y (0.2) given  y , y (0)  1 with h=0.1.
dx y

Solution :

dy 2x
 y
dx y

Given:

x0  0, y0  1, h  0.1, x  0.2
x  x0 0.2  0
n  2
h 0.1
x1  0.1
y1  y0  hf ( x0 , y0 )
 1  0.1 f (0,1)
 1.1
y2  y1  hf ( x1 , y1 )
 1  0.1 f (0.1,1.1)
 1.1918

Hence, y2  y(0.2)  1.1918

Example:Determine the value of y when x  0.1 correct up to four decimal places by taking h  0.05 .
dy
Given that y (0)  1 and  x 2  y using modified Euler’s method.
dx

Solution :

dy
 f ( x, y )  x 2  y
dx

(i) Given: x0  0, y0  1, h  0.05, x1  0.05


f ( x0 , y0 )  0  1  1
y10  y0  hf ( x0 , y0 )  1  0.05(1)  1.05

First approximation to y1

h
y11  y0   f ( x0 , y0 )  f ( x1 , y10 ) 
2
0.05
 1 1  f (0.05,1.05)
2
 1.0513

Second approximation to y1

h
y12  y0   f ( x0 , y0 )  f ( x1 , y11 ) 
2
0.05
 1 1  f (0.05,1.0513)
2
 1.0513

Since the values of y11 and y12 are equal.

y1  y(0.05)  1.0513

(ii) Now, x1  0.05, y1  1.0513, h  0.05, x2  0.1

f ( x1 , y1 )  f (0.05,1.0513)  1.0538
y20  y1  hf ( x1 , y1 )  1.0513  0.05(1.0538)  1.1040

First approximation to y 2

h
y12  y1   f ( x1 , y1 )  f ( x2 , y20 ) 
2
0.05
 1.0513  1.0538  f (0.1,1.1040)
2
 1.1055

Second approximation to y 2
h
y22  y1   f ( x1 , y1 )  f ( x2 , y12 ) 
2
0.05
 1.0513  1.0538  f (0.1,1.1055)
2
 1.1055

Since the values of y12 and y22 are equal.

y2  y(0.1)  1.1055

dy y2
Example: Solve  , y (0)  1 by Euler’s method by choosing h = 0.1 and h = 0.05. Also solve
dx 1 x
the same problem by modified Euler’s method by choosing h = 0.05. Compare the numerical solution
with analytical solution.

Solution :

Analytical solution is : -

dy dx 1
   log( 1  x)  c
y 2
1 x y

Using the condition y(0) = 1, we get c = 1.

1
Hence the analytical solution is y   y(0.2) = 0.84579
1  log( 1  x)

 y n2 
Now by Euler’s method, we have y n 1  y n  0.1 
 1  xn 

 (1) 2 
y1  y(0.1)  1  0.1   0.9
1 0 

 (0.9) 2 
y 2  y(0.2)  0.9  0.1   0.82636
 1  0.1 

Error = 0.84579 – 0.82636 = 0.01943

 y n2 
Now taking h = 0.05, Euler’s method is y n 1  y n  0.05 
 1  xn 
 (1) 2 
y1  y(0.05)  1.0  0.05   0.95
1 0 

 (0.95) 2 
y 2  y(0.1)  0.95  0.05   0.90702
 1  0.05 

 (0.90702) 2 
y3  y(0.15)  0.90702  0.05   0.86963
 1  0.1 

 (0.86963) 2 
y 4  y(0.2)  0.86963  0.05   0.83675
 1  0.15 

Error = 0.84579 – 0.83675 = 0.00904

Now we use modified Euler’s method to find y(0.2) with h = 0.05

 y n2 
Euler’s Formula is y n1  y n  0.05  , n = 0,1,2 and 3
 1  xn 

 y n2 yE 
Modified Euler Formula is y n1  y n  0.025  n1  , n = 0,1,2 and 3
 1  xn 1  xn1 

Stage – I: Finding y1 = y(0.05)

From Euler’s formula (for n = 0),

 (1) 2 
y1E  y(0.05)  1.0  0.05   0.95
1 0 

From Modified Euler’s formula, we have

 (1) 2 (0.95) 2 
y1(1)  y(0.05)  1.0  0.025    0.95351
 1  0 1  0.05 

 (1) 2 (0.95351) 2 
y1( 2)  y(0.05)  1.0  0.025    0.95335
 1  0 1  0.05 

 (1) 2 (0.95335) 2 
y1(3)  y(0.05)  1.0  0.025    0.95336
1 0 1  0.05 
 (1) 2 (0.95336) 2 
y1( 4)  y(0.05)  1.0  0.025    0.95336
1 0 1  0.05 

Hence y1  y(0.05)  0.95336

Stage – II: Finding y2 = y(0.1)

From Euler’s formula (for n = 1), we get

 (0.95336) 2 
y 2E  y(0.1)  0.95336  0.05   0.91008
 1  0.05 

From Modified Euler’s formula, we have

 (0.95336) 2 (0.91008) 2 
y (1)
 y(0.1)  0.95336  0.025    0.91286
 1  0.05 1  0.1 
2

 (0.95336) 2 (0.91286) 2 
y 2( 2)  y(0.1)  0.95336  0.025    0.91278
 1  0.05 1  0.1 

 (0.95336) 2 (0.91278) 2 
y 2( 2)  y(0.1)  0.95336  0.025    0.91278
 1  0.05 1  0.1 

Hence y2  y(0.1)  0.91278

Stage – III: Finding y3 = y(0.15)

From Euler’s formula (for n = 2), we get

 (0.91278) 2 
y  y(0.15)  0.91278  0.05
E
  0.87491
 1  0.1 
3

From Modified Euler’s formula (for n = 2), we have

 (0.91278) 2 (0.87491) 2 
y (1)
 y(0.15)  0.91278  0.025    0.87720
 1  0.1 1  0.15 
3

 (0.91278) 2 (0.87720) 2 
y3( 2)  y(0.15)  0.91278  0.025    0.87712
 1  0.1 1  0.15 
 (0.91278) 2 (0.87712) 2 
y3(3)  y(0.15)  0.91278  0.025    0.87712
 1  0.1 1  0.15 

Hence y3  y(0.15)  0.87712

Stage – IV: Finding y4 = y(0.2)

From Euler’s formula (for n = 3), we get

 (0.87712) 2 
y 4E  y(0.2)  0.87712  0.05   0.84367
 1  0.15 

From Modified Euler’s formula (for n = 3), we have

 (0.87712) 2 (0.84367) 2 
y 4(1)  y(0.2)  0.87712  0.025    0.84557
 1  0.15 1  0.2 

 (0.87712) 2 (0.84557) 2 
y 4( 2)  y(0.2)  0.87712  0.025    0.84550
 1  0.15 1  0.2 

 (0.87712) 2 (0.84550) 2 
y 4( 2)  y(0.2)  0.87712  0.025    0.84550
 1  0.15 1  0.2 

Hence y4  y(0.2)  0.84550

Hence y3  y(0.15)  0.87712

Stage – IV: Finding y4 = y(0.2)

From Euler’s formula (for n = 3), we get

 (0.87712) 2 
y  y(0.2)  0.87712  0.05
E
  0.84367
 1  0.15 
4

From Modified Euler’s formula(for n = 3), we have

 (0.87712) 2 (0.84367) 2 
y (1)
 y(0.2)  0.87712  0.025    0.84557
 1  0.15 1  0.2 
4
 (0.87712) 2 (0.84557) 2 
y 4( 2)  y(0.2)  0.87712  0.025    0.84550
 1  0.15 1  0.2 
 (0.87712) 2 (0.84550) 2 
y 4( 2)  y(0.2)  0.87712  0.025    0.84550
 1  0.15 1  0.2 

Hence y4  y(0.2)  0.84550

Error = 0.84579 – 0.84550 = 0.00029

Recall that the error from Euler’s Method is 0.00904

3. Runge – Kutta Method:


The Taylor’s series method to solve IVPs is restricted by the difficulty in finding the higher order
derivatives. However, Runge – Kutta method do not require the calculations of higher order derivatives.
Euler’s method and modified Euler’s method are Runge – Kutta methods of first and second order
respectively.

dy
Consider the IVP  f ( x, y ), y ( x0 )  y0 . Let us find the approximate value of y at x  xn1 , n =
dx
0,1,2,3,….. of this numerically, using Runge – Kutta method, as follows:

Second Order (Heun) method:

First let us calculate the quantities k1and k2 using the following formulae.

k1  hf ( xn , yn )
k2  hf ( xn  h, yn  k1 )
1
k  (k1  k2 )
2

Finally, the required solution y is given by

yn1  yn  k

Fourth Order method:

First let us calculate the quantities k1 , k 2 , k 3 and k 4 using the following formulae.

k1  hf ( xn , y n )
 h k 
k 2  hf  x n  , y n  1 
 2 2

 h k 
k 3  hf  xn  , y n  2 
 2 2

k 4  hf xn  h, y n  k 3 

Finally, the required solution y is given by

y n 1  y n 
1
k1  2k 2  2k 3  k 4 
6

dy
Example: Given that y  1.3 when x  1 and  3x  y. Use the second order R-K method to
dx
approximate y when x  1.2. Use a step size of 0.1.

Solution:

dy
 f ( x, y )  3x  y.
dx

(i) Given: x0  1, y0  1.3, h  0.1and n  0

k1  hf ( x0 , y0 )
 0.1 f (1,1.3)
 0.43
k2  hf ( x0  h, y0  k1 )
 0.1 f (1  0.1,1.3  0.43)
 0.503
1 1
k  (k1  k2 )  (0.43  0.503)  0.4665
2 2
y1  y0  k  1.3  0.4665  1.7665

(ii) Now, x1  1.1, y1  1.7665, h  0.1and n  1


k1  hf ( x1 , y1 )
 0.1 f (1.1,1.7665)
 0.5067
k2  hf ( x1  h, y1  k1 )
 0.1 f (1.1  0.1,1.7665  0.5067)
 0.5873
1 1
k  (k1  k2 )  (0.5067  0.5873)  0.5470
2 2
y2  y1  k  1.7665  0.5470  2.3135

Hence, y2  y(1.2)  2.3135

Example:Apply Runge – Kutta fourth order method, to find an approximate value of y when x = 0.2 given
dy
that  x  y, y (0)  1 .
dx

Solution:

Given: x0  0, y0  1, h  0.2 and f ( x, y)  x  y

By R – K method (for n = 0) is: y1  y (0.2)  y 0 


1
k1  2k 2  2k 3  k 4  -------- (1)
6

Now

k1  hf ( x0 , y0 )  0.2  [0  1] = 0.2

 h k   0.2   0.2 
k 2  hf  x0  , y 0  1   0.2   0    1   = 0.2400
 2 2  2   2 

 h k   0.2   0.24 
k 3  hf  x0  , y 0  2   0.2   0    1   = 0.2440
 2 2  2   2 

k 4  hf x0  h, y0  k 3   0.2  0  0.2  1  0.2440 = 0.2888

Using the values of k1 , k 2 , k 3 and k 4 in (1), we get


y1  y (0.2)  1 
1
0.2  0.24  0.244  0.2888 = 1.2468
6

Hence the required approximate value of y is 1.2468.

dy y 2  x 2
Example:Using Runge – Kutta method of fourth order, solve  , y (0)  1
dx y 2  x 2

at x = 0.2 & 0.4.

Solution:

y2  x2
Given: x0  0, y 0  1, h  0.2 and f ( x, y ) 
y2  x2

For y1  y(0.2)

By R – K method (for n = 0) is: y1  y (0.2)  y 0 


1
k1  2k 2  2k 3  k 4  -------- (2)
6

k1  hf ( x0 , y0 )  0.2  f (0,1) = 0.2

 k 
k 2  hf  x0  , y 0  1   0.2  f 0.1,1.1
h
= 0.19672
 2 2

 k 
k 3  hf  x0  , y 0  2   0.2  f 0.1,1.0936
h
= 0.1967
 2 2

k 4  hf x0  h, y0  k 3   0.2  f 0.2,1.1967 = 0.1891

Using the values of k1 , k 2 , k 3 and k 4 in (2), we get

y1  y (0.2)  1 
1
0.2  2(0.19672)  2(0.1967)  0.1891
6

= 1+0.19599

= 1.19599

Hence the required approximate value of y is 1.19599.

For y2  y(0.4)
We have x1  0.1, y1  1.19599 and h  0.2

By R – K method (for n = 1) is: y 2  y (0.4)  y1 


1
k1  2k 2  2k 3  k 4  -------- (3)
6

k1  hf ( x1 , y1 )  0.2  f (0.2, 1.19599) = 0.1891

 k 
k 2  hf  x1  , y1  1   0.2  f 0.3, 1.2906
h
= 0.1795
 2 2

 k 
k 3  hf  x1  , y1  2   0.2  f 0.3, 1.2858
h
= 0.1793
 2 2

k 4  hf x1  h, y1  k 3   0.2  f 0.4, 1.3753 = 0.1688

Using the values of k1 , k 2 , k 3 and k 4 in (3), we get

y 2  y (0.4)  1.19599 
1
0.1891  2(0.1795)  2(0.1793)  0.1688
6

= 1.19599 + 0.1792

= 1.37519

Hence the required approximate value of y is 1.37519.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy