- 99 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about ' Scientific Computing' - louvain

**An Image/Link below is provided (as is) to download presentation**

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 - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

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 .

Better Methods

- 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 :

Better Methods

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 vs Actual 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

Runge-Kutta Order 2 Method

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

Runge-Kutta Order 2 Method

Then,

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

Thus, our weighted average approximation will be good to

O(h3) if

Runge-Kutta Order 2 Method

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

xi+1

xi

x

ti+1

ti

Heun’s Method (Pav’s RK-Order 2)Heun’s method

resulting in

where

Heun’s method is ~ Trapezoidal Rule in Integration

Ralston’s Method

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

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

Find the temperature at

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

seconds.

http://numericalmethods.eng.usf.edu

Solution Cont

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

Comparison with exact results

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

http://numericalmethods.eng.usf.edu

Effect of step size

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

(exact)

http://numericalmethods.eng.usf.edu

Comparison of Euler and Runge-Kutta 2nd Order Methods

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

(exact)

http://numericalmethods.eng.usf.edu

Comparison of Euler and Runge-Kutta 2nd Order Methods

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

(exact)

http://numericalmethods.eng.usf.edu

Comparison of Euler and Runge-Kutta 2nd Order Methods

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

http://numericalmethods.eng.usf.edu

Runge-Kutta Order 4 Example

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

Runge-Kutta Order 4 Example

The example of a single step:

Runge-Kutta Order 4 Example

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.

Runge-Kutta Order 4 Example

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

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 !!!

Download Presentation

Connecting to Server..