Mws Gen Ode PPT Euler

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 13

Euler Method

Euler s Method
y

dy ! f x, y , y 0 ! y0 dx
Slope

True value y1, Predicted value

!
!

Rise Run
y1  y 0 x1  x0

x0,y0

Step size, h x

! f x 0 , y 0

y1 ! y 0  f x0 , y 0 x1  x0

! y0  f x0 , y0 h
2

Figure 1 Graphical interpretation of the first step of Euler s method

Euler s Method
y

yi 1 ! yi  f xi , yi h h ! xi 1  xi
yi h Step size xi xi+1

True Value

yi+1, Predicted value

Figure 2. General graphical interpretation of Euler s method


3

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
4

Example
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
dU ! 2 .2067 v 10 12 U 4  81 v 10 8 , U 0 ! 1200 K dt

Find the temperature at

t ! 480 seconds using Eulers method. Assume a step size of

h ! 240 seconds.

Solution
Step 1:

dU ! 2.2067 v 10 12 U 4  81 v 10 8 dt

f t , U ! 2.2067 v 10 12 U 4  81 v 10 8 U i 1 ! U i  f ti , U i h U1 ! U 0  f t0 , U 0 h ! 1200  f 0,1200 240

! 1200   2.2067 v 10 12 1200 4  81 v 10 8 240 ! 1200   4.5579 240 ! 106 .09 K

U1
6

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

U 240 } U1 ! 106.09 K

Solution Cont
Step 2:
For

i ! 1,

t1 ! 240, U1 ! 106.09

U 2 ! U1  f t1 , U 1 h ! 106 .09  f 240 ,106 .09 240 ! 106 .09   2 .2067 v 10 12 106 .09 4  81 v 10 8 240 ! 106 .09  0 .017595 240 ! 110 .32 K

U 2 is the approximate temperature at t ! t2 ! t1  h ! 240  240 ! 480


U 480 } U 2 ! 110.32 K

Solution Cont
The exact solution of the ordinary differential equation is given by the solution of a non-linear equation as

0.92593 ln

U  300  1.8519 tan 1 0.00333U ! 0.22067 v 10 3 t  2.9282 U  300

The solution to this nonlinear equation at t=480 seconds is

U (480) ! 647.57 K

Comparison of Exact and Numerical Solutions


1400

(K)
Temperature,

1200 1000 Exact Solution 800 600 400

h=240
200 0 0 100 200 300 400 500

Time, t(sec)

Figure 3. Comparing exact and Euler s method


9

Effect of step size


Table 1. Temperature at 480 seconds as a function of step size, h

Step, h

U(480)

Et

| t|%

480 240 120 60 30

987.81 110.32 546.77 614.97 632.77

1635.4 537.26 100.80 32.607 14.806


(exact)

252.54 82.964 15.566 5.0352 2.2864

U (480) ! 647.57 K

10

Comparison with exact results


1500 Temperature, (K) 1000 500 0 0 -500 -1000 -1500 100 200 300 400 500

Exact solution h=120 h=240

Tim e, t (sec)

h=480

Figure 4. Comparison of Euler s method with exact solution for different step sizes
11

Effects of step size on Euler s Method


800 400

e at e

K)

0 0 -400 100 200 300 400 500

Ste s ze h s)
-800

-1200

Figure 5. Effect of step size in Euler s method.


12

Errors in Euler s Method


It can be seen that Euler s method has large errors. This can be illustrated using Taylor series. 1 d2y 1 d3y dy 2 xi 1  xi  xi 1  xi  xi 1  xi 3  ... y i 1 ! y i  2! dx 2 x , y 3! dx 3 x , y dx xi , yi
i i i i

yi 1 ! y i  f ( xi , y i ) xi 1  xi 

1 1 2 3 f ' ( xi , y i ) xi 1  xi  f ' ' ( xi , yi ) xi 1  xi  ... 2! 3!

As you can see the first two terms of the Taylor series
y i 1 ! yi  f xi , y i h are the Euler s method.

The true error in the approximation is given by


d f d i , yi 2 f d i , yi 3 x x Et ! h  h  ... 2! 3!
13
t

w h2

You might also like