- 56 Views
- Uploaded on
- Presentation posted in: General

Scientific Computing

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Numerical Solution Of

Ordinary Differential Equations

- Runge-Kutta Methods

- If we take more terms in the Taylor’s Series expansion of f(t,x), we would get a more accurate solution algorithm.
- Problem: It is difficult to compute higher-order derivatives numerically.
- Idea: Approximate the value of higher derivatives of f(t,x) by evaluating f several times between iterates: ti and ti+1 .

- The ODE +IV x(a)= x0 =s
can be alternatively solved as an integral equation. For example, on the first interval from x0 to x1 :

In general:

- The problem is that we don’t know x(t), so evaluating the integral is not trivial.
- We assume that if h is small enough, f(t,x) will not change that much over the interval [ti, ti+1]. Using “left-rectangular integration,”
- This is the Euler Method. A family of improved versions are called Runge-Kutta methods

Euler Solution

x

xi

true solution

h

ti

ti+1 = ti + h

Tuncation error:

true solution

Euler Solution

RK methods differ in how they estimate fi

For Euler Method (a type of RK method), fi ≈ f(ti, xi)

x

xi

true solution

fi

h

ti

ti+1 = ti + h

x

xi

fi

h

Weighted average of two slopes

x

ti

ti+αh

ti+1

- Let
- Then,
- Expand k2 using Taylor’s Series in (t,x):
where is a point between

Then,

The actual Taylor Series expansion for x(ti+h) is:

Thus, our weighted average approximation will be good to

O(h3) if

So, general RK order 2 Method is:

Examples:

1) ω1=1, ω2=0 -> Euler’s Method (Still O(h2) as no averaging)

Error is lower than Euler, but

now there are 2 calls to f(x,y)

required per step

Truncation error:

true solution

x

xi+1

xi

x

ti+1

ti

Heun’s method

resulting in

where

Heun’s method is ~ Trapezoidal Rule in Integration

resulting in

Midpoint method is ~ Midpoint Rule in Integration

where

Ralston (1962) and Ralston and Rabinowitiz (1978)

determined that choosing ω2 = 2/3 provides a minimum

bound on the truncation error for the second order RK

algorithms.

resulting in

where

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

Find the temperature at

seconds using Heun’s method. Assume a step size of

seconds.

http://numericalmethods.eng.usf.edu

Step 1:

http://numericalmethods.eng.usf.edu

Step 2:

http://numericalmethods.eng.usf.edu

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

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

http://numericalmethods.eng.usf.edu

Figure 2. Heun’s method results for different step sizes

http://numericalmethods.eng.usf.edu

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

(exact)

http://numericalmethods.eng.usf.edu

Table 2. Comparison of Euler and the Runge-Kutta methods

(exact)

http://numericalmethods.eng.usf.edu

Table 2. Comparison of Euler and the Runge-Kutta methods

(exact)

http://numericalmethods.eng.usf.edu

Figure 4. Comparison of Euler and Runge Kutta 2nd order methods with exact results.

http://numericalmethods.eng.usf.edu

weighted average

where

different

estimates

of slope

k2

k4

x

k3

k1

ti

ti + h/2

ti + h

- Consider Exact Solution
- The initial condition is:
- The step size is:

The example of a single step:

The RK values are nearly equivalent to those of the exact solution out to x=5.

y(5) = -111.4129 (-111.4132)

The error is small relative to the exact solution.

A comparison between the 2nd order and the 4th order Runge-Kutta methods show a slight difference.

ERRORS

Local

(single-step)

Global

(multi-step)

function

evals per step

RK

1st-order

1

O(h2)

O(h) = O(1/n)

2nd-order

O(h3)

O(h2) = O(1/n2)

2

4th-order

O(h5)

O(h4) = O(1/n4)

4

“local error”

For n steps,

Therefore, “global error”

Order of global error is 1 less than order of local error

A fair comparison between two RK methods must account

the differing number of function calls per step

RK1 (Euler Method)- - 1 function call per step

t0

t1

t2

t3

t4

t5

t8

t7

t6

RK4 - - 4 function calls per step

t0

t1

t2

Example: integrate from 0 to 4 using n=400 function evaluations

1st-order Euler with h = 0.01… global error = O(0.01)

4th-order RK with h = 0.04… global error = O(0.00000256)

104 times less error for same amount of work FREE LUNCH !!!