Вы находитесь на странице: 1из 25

G. H.

Patel College of Engineering &


Technology

Branch : Information Technology

Name Of Subject : Numerical Methods For Computer Engineering

Subject Code : 2710210

Name Of Unit : Ordinary differential equations

Topic : Eulers method and Runge-Kutta methods


Guided By : Prof. Krupal Parikh
Submitted By : Mira Y Patel (140110723006)

Eulers Method

Derivation of Eulers method :

At x = 0, we are given the value of y = y. Let us call x = 0


as x. Now since we know the slope of y with respect to x,
that is, f(x,y) , then at x =x, the slope is f(x,y). Both
x and y are known from the initial condition y(x) = y.

Eulers Method

Derivation of Eulers method :


y

dy
f x, y , y 0 y 0
dx
True value

x0,y0

Slope

y1,
Predicted
value

Rise
Run
y1 y 0
x1 x0

f x0 , y 0

Step size, h
x

Figure 1 Graphical interpretation of the first step of


Eulers method

y1 y 0 f x0 , y 0 x1 x0

y0 f x0 , y0 h

Eulers Method

Derivation of Eulers method :


yi 1 yi f xi , yi h

h xi 1 xi
True Value

This formula is known as Eulers


method
yi+1, Predicted value

and

is

illustrated

graphically in Figure 2.

yi
h

In some books, it is also called

Step size
xi

xi+1

Figure 2. General graphical interpretation of


Eulers method

the Euler-Cauchy method.

Eulers Method
Modified Eulers method :

A fundamental source of error in Eulers method is that the derivative at


the beginning of the interval is assumed to apply across the entire
interval.

Two simple modifications are available to circumvent this shortcoming:


o

Heuns Method

The Midpoint (or Improved Polygon) Method

Eulers Method

Modified Eulers method (Heuns method) :

To improve the estimate of the slope,


determine two derivatives for the
interval:
o

At the initial point

At the end point

The two derivatives are then averaged


to obtain an improved estimate of the
slope for the entire interval.

Predictor :

yi01 yi f ( xi , yi ) h

f ( xi , yi ) f ( xi 1 , yi01 )
Corrector : yi 1 yi
h
2

Eulers Method

Modified Eulers method (The Midpoint Method):

Uses

Eulers method to predict a

value of y using the slope value at


the midpoint of the interval:

yi 1/ 2

h
yi f ( xi , yi )
2

yi 1 yi f ( xi 1/ 2 , yi 1/ 2 )h

Eulers Method

Error analysis for Eulers method :


Numerical solutions of ODEs involves two types of error:

Truncation error

Local truncation error

Propagated truncation error


The sum of the two is the total or global truncation error

Round-off errors (due to limited digits in representing numbers in


a computer)

Eulers Method

Error analysis for Eulers method :

We can use Taylor series to quantify the local truncation error in Eulers
method.
Given y' f ( x , y )
"
i

( n)
i

y 2
y
h ...
h n Rn
2!
n!
f ' ( x i , yi ) 2
f ( n1) ( x i , y i ) n
yi 1 yi f ( x i , yi )h
h ...
h O( h n1 )
2!
n!
yi 1 yi yi' h

EULER

f ( xi , yi ) 2
h R3
2!
f ( xi , yi ) 2
Ea
h O(h 2 )
2!
Ea

Local Truncation ERROR

The error is reduced by 4 times if the step size is halved O(h2).

In real problems, the derivatives used in the Taylor series are not easy to
obtain.

If the solution to the differential equation is linear, the method will provide
error free predictions (2nd derivative is zero for a straight line).

Eulers Method

How to write Ordinary Differential Equation :


How does one write a first order differential equation in the form of
dy
f x, y
dx

Example
dy
2 y 1.3e x , y 0 5
dx

is rewritten as
dy
1.3e x 2 y, y 0 5
dx
In this case

f x, y 1.3e x 2 y

Eulers Method

Application of Eulers method :


A ball at 1200K is allowed to cool down in air at an ambient temperature of
300K. Assuming heat is lost only due to radiation, the differential equation
for the temperature of the ball is given by
d
2.2067 10 12 4 81108 , 0 1200 K
dt

Find the temperature at t = 480 seconds using Eulers method. Assume a step
size of h = 240 seconds.

Eulers Method

Application of Eulers method :

Solution step 1:
d
2.2067 10 12 4 81 10 8
dt

f t , 2.2067 10 12 4 81 10 8

i 1 i f ti , i h
1 0 f t0 , 0 h
1200 f 0,1200 240

1200 2.2067 10 12 1200 4 81108 240


1200 4.5579 240

106.09 K

is the approximate temperature at t t1 t0 h 0 240 240

240 1 106.09 K

Eulers Method

Application of Eulers method :

Solution step 2:
For i 1,

t1 240, 1 106.09

2 1 f t1 , 1 h
106.09 f 240,106.09 240

106.09 2.2067 10 12 106.09 4 81108 240


106.09 0.017595 240
110 .32 K

2 is the approximate temperature at t t 2 t1 h 240 240 480


480 2 110 .32 K

Runge-Kutta Methods

Runge-Kutta (RK) methods achieve the accuracy of a Taylor series


approach without requiring the calculation of higher derivatives.

yi 1 yi ( xi , yi , h) h

a1k1 a2 k 2 an k n

IncrementFunction

a ' s areconstants

k1 f ( xi , yi )
k 2 f ( xi p1h, yi q11k1h)

p s andq s areconstants

k3 f ( xi p3 h, yi q21k1h q22 k 2 h)

k n f ( xi pn 1h, yi qn 1k1h qn 1, 2 k 2 h qn 1,n 1k n 1h)

Runge-Kutta Methods

Fourth-Order Runge-Kutta Methods :


For ODEs that are a function of x
alone, the classical fourth-order RK
method is similar to Simpsons 1/3
rule.
In addition, the fourth-order RK
method is similar to the Heun
approach in that multiple estimates
of the slope are developed in order
to come up with an improved
average slope for the interval.

Graphical depiction of the slope


estimates comprising the fourth-order
RK method.

As depicted in Fig., each of the ks


represents a slope.

Runge-Kutta Methods

Fourth-Order Runge-Kutta Methods :


For

dy
f ( x, y ), y (0) y0
dx

Runge-Kutta 4th order method is given by


1
yi 1 yi k1 2k 2 2k3 k4 h
6
where

k1 f xi , yi
1
1

k2 f xi h, yi k1h
2
2

1
1

k3 f xi h, yi k2 h
2
2

k4 f xi h, yi k3h

Runge-Kutta Methods

Application of Fourth-Order Runge-Kutta Methods :


A ball at 1200K is allowed to cool down in air at an ambient temperature
of 300K. Assuming heat is lost only due to radiation, the differential
equation for the temperature of the ball is given by

d
2.2067 10 12 4 81 10 8 , 0 1200 K
dt
Find the temperature at t = 480 seconds using Runge-Kutta 4 th order
method. Assume a step size of h = 240 seconds.
d
2.2067 10 12 4 81 10 8
dt

f t , 2.2067 10 12 4 81 108

i 1 i

1
k1 2k 2 2k 3 k 4 h
6

Runge-Kutta Methods

Application of Fourth-Order Runge-Kutta Methods :

Solution step 1:
i 0, t0 0, 0 (0) 1200

k1 f t0 , o f 0,1200 2.2067 10 12 1200 4 81108 4.5579


1
1
1
1

k 2 f t0 h, 0 k1h f 0 240 ,1200 4.5579 240


2
2
2
2

f 120,653.05 2.2067 10 12 653.054 81108 0.38347

1
1
1
1

k3 f t0 h, 0 k 2 h f 0 240 ,1200 0.38347 240


2
2
2
2

f 120,1154 .0 2.2067 10 12 1154 .0 4 81108 3.8954

k 4 f t0 h, 0 k3h f 0 240 ,1200 3.984 240

f 240,265.10 2.2067 10 12 265.10 4 81 108 0.0069750

Runge-Kutta Methods

Application of Fourth-Order Runge-Kutta Methods :

Solution step 1:
1
k1 2k2 2k3 k4 h
6
1
1200 4.5579 2 0.38347 2 3.8954 0.069750 240
6
1
1200 2.1848 240
6
675.65 K

1 0

1 is the approximate temperature at


t t1 t0 h 0 240 240

240 1 675.65K

Runge-Kutta Methods

Application of Fourth-Order Runge-Kutta Methods :

Solution step 2:
i 1, t1 240, 1 675.65K

k1 f t1 , 1 f 240,675.65 2.2067 10 12 675.654 81108 0.44199


1
1
1
1

k 2 f t1 h,1 k1h f 240 240 , 675.65 0.44199 240


2
2
2
2

f 360,622.61 2.2067 10 12 622.614 81108 0.31372

1
1
1
1

k3 f t1 h,1 k 2 h f 240 240 ,675.65 0.31372 240


2
2
2
2

f 360, 638.00 2.2067 10 12 638.00 4 81108 0.34775


k 4 f t1 h,1 k3h f 240 240 ,675.65 0.34775 240

f 480,592.19 2.2067 10 12 592.19 4 81108 0.25351

Runge-Kutta Methods

Application of Fourth-Order Runge-Kutta Methods :

Solution step 2:
1
k1 2k2 2k3 k 4 h
6
1
675.65 0.44199 2 0.31372 2 0.34775 0.25351 240
6
1
675.65 2.0184 240
6
594.91K

2 1

is the approximate temperature at

t 2 t1 h 240 240 480


480 2 594.91K

Comparison of Euler's Method and Runge-Kutta Methods

Figure 3. Comparison of Euler's Method and Runge-Kutta Methods

References

http://mat.iitm.ac.in

http://en.m.wikipedia.org/wiki/Euler_method

http://en.m.wikipedia.org/wiki/Runge-Kutta_methods

http://www.classzone.com

http://mathforcollege.com

Certificate

I Mira Y Patel(140110723006) assure that material which I


prepared is not plagiarized material. I Prepared it under the
guidance of subject faculty. The references are also
mentioned, which are used for the ppt.

Sign
Mira Y Patel

K
N
A
H
T

U
O
Y

Вам также может понравиться