0% found this document useful (0 votes)
261 views

Nge Kutta

Runge-Kutta methods are used to numerically solve ordinary differential equations (ODEs) with initial value problems. The methods work by approximating the solution of an ODE at discrete time steps. First order Runge-Kutta is Euler's method, which approximates the next value as the current value plus the derivative times the step size. Higher order methods use multiple estimates within each step to improve accuracy. Adaptive Runge-Kutta varies the step size based on error estimates to balance accuracy and efficiency. Fehlberg's method uses a fifth order estimate and lower order estimate to control step size for solving problems with abrupt changes.

Uploaded by

aislah_1
Copyright
© Attribution Non-Commercial (BY-NC)
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)
261 views

Nge Kutta

Runge-Kutta methods are used to numerically solve ordinary differential equations (ODEs) with initial value problems. The methods work by approximating the solution of an ODE at discrete time steps. First order Runge-Kutta is Euler's method, which approximates the next value as the current value plus the derivative times the step size. Higher order methods use multiple estimates within each step to improve accuracy. Adaptive Runge-Kutta varies the step size based on error estimates to balance accuracy and efficiency. Fehlberg's method uses a fifth order estimate and lower order estimate to control step size for solving problems with abrupt changes.

Uploaded by

aislah_1
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 10

Runge-Kutta Methods

for Ordinary Differential Equations

Initial Value Problems


(ODE-IVP )
dyi
= f ( x , yi )
dx
where initial condition is given: yi= ai at x = 0

1 step methods:
yi +1 = yi + φ ( xi , yi , h)h
φ = a1k1 + a2 k 2 + L + an k n (increment function)

1st order: yi +1 = yi + k1h Euler’s method


k1 = f ( xi , yi )
1 1
2nd order: yi +1 = yi + ( k1 + k 2 )h Heun method with a Single corrector
2 2
k1 = f ( xi , yi ) k 2 = ( xi + h, yi + h)

yi +1 = yi + k 2 h Midpoint corrector
1 1
k 2 = ( xi + h, yi + k1h)
k1 = f ( xi , yi ) 2 2
1 2
yi +1 = yi + ( k1 + k 2)h Raltson’s method
3 3 3 3
k1 = f ( xi , yi ) k 2 = f ( xi + h, yi + k 1h)
4 4
Comparison of three 2nd-order RK methods with the true solution

Runge Kutta
1
3rd order: yi +1 = yi + (k1 + 4k 2 + k3 )h
6
k1 = f ( xi , yi )
1 1
k 2 = f ( xi + h, yi + k1h)
2 2
k3 = f ( xi + h, yi − k1h + 2k 2 h)

Classical RK
4th order: 1
yi +1 = yi + (k1 + 2k 2 + 2k3 + k 4 )h
6
k1 = f ( xi , yi )
1 1
k 2 = f ( xi + h, yi + k1h)
2 2
1 1
k3 = f ( xi + h, yi + k2 h)
2 2
k 4 = f ( xi + h, yi + k3h)
4th order Runge Kutta

Butcher’s
5th order: 1
yi +1 = yi + (7k1 + 32k3 + 12k 4 + 32k5 + 7 k6 )h
90

k1 = f ( xi , yi )
1 1
k 2 = f ( xi + h, yi + k1h)
4 4
1 1 1
k3 = f ( xi + h, yi + k1h + k 2 h)
4 8 8
1 1
k 4 = f ( xi + h, yi − k2 h + k3h)
2 2
3 3 9
k5 = f ( xi + h, yi + k1h + k 4 h)
4 16 16
3 2 12 12 8
k6 = f ( xi + h, yi − k1h + k2 h + k3h − k 4 h + k5 h)
7 7 7 7 7
f(x,y)=4e0.8x-0.5y

b−a
Effort = n f
h

nf = no. function

System of equations
dy1
= f1 ( x, y1 , y2 , L , yn )
dx
dy2
= f 2 ( x, y1 , y2 , L , yn )
dx

M
dyn
= f n ( x, y1 , y2 , L , yn )
dx

Example: kinetic reactions


Example 25.10:
Use 4th RK method to solve the ODEs below:
dy1 dy2
= −0.5 y1 = 4 − 0.3 y2 − 0.1y1
dx dx
assuming x = 0, y1=4 and y2 = 6. Integrate to x = 2 with h = 0.5
Solution:
k1 = f ( xi , yi )

1 1
k 2 = f ( xi + h, yi + k1h)
2 2

1 1
k3 = f ( xi + h, yi + k2 h)
2 2

k 4 = f ( xi + h, yi + k3h)
1
yi +1 = yi + (k1 + 2k 2 + 2k3 + k 4 )h
6

Proceeding in a like manner for the remaining steps:

x y1 y2

0 4 6

0.5 3.115234 6.857670

1.0 2.426171 7.632106

1.5 1.889523 8.326886

2.0 1.471577 8.946865

4th order RK method for system


ODE with abrupt change:
Adaptive Runge-Kutta Methods

Adapt to the step size


trajectory
– adaptive step-size control

Require local truncation


error at each step.

Basis for lengthening or


decreasing the step
size.

Adaptive RK/step-halving method

Taking each step twice, a full step and 2 half steps.

Then, calculate the difference between 2 results

∆ = y2 − y1
For 4th order RK, the correction is


y2 ← y2 +
15
This estimate is fifth-order accurate.
Example 25.12: (Adaptive RK)

Use adaptive 4th RK method to integrate y’ from x = 0 to x = 2


y ' = 4e 0.8 x − 0.5 yi
step size =2, initial condition is y(0) = 2 (true solutions is y (2) = 14.84392 )
Solution:
- Single prediction with a step of h is computed as
1
y (2) = 2 + (k1 + 2k 2 + 2k3 + k 4 )h = 15.10584
6
- Two half step predictions are:
1
y (1) = 2 + ( k1 + 2k 2 + 2k3 + k 4 )h = 6.20104
6
1
y (2) = 6.20104 + (k1 + 2k 2 + 2k3 + k 4 )h = 14.86249
6
- The approximate error is
14.86249 − 15.10584
Ea = = −0.01622
15
- The true error is Et = 14.84392 − 14.86249 = −0.01857
- Corrected prediction y ( 2) = 14.86249 − 0.01622 = 14.84627
- with true error: Et = 14.84392 − 14.84627 = −0.00235

Runge-Kutta Fehlberg/embedded RK/Cash-Karp RK method


37 250 125 512
4th order est.: yi +1 = yi + ( k1 + k2 + k3 + k 4 )h
378 621 594 1771
2825 18,575 13,525 277 1
5th order est.: yi +1 = yi + ( k1 + k3 + k4 + k5 + k 6 ) h
27,648 48,384 55,296 14,336 4
where k1 = f ( xi , yi )
1 1
k 2 = f ( xi + h, yi + k1h)
5 5
3 3 9
k3 = f ( xi + h, yi + k1h + k2 h)
10 40 40
3 3 9 6
k 4 = f ( xi + h, yi + k1h − k 2 h + k3 h)
5 10 10 5
11 5 70 35
k5 = f ( xi + h, yi − k1h + k 2 h − k3h + k 4 h)
54 2 27 27
7 1631 175 575 44,275 253
k6 = f ( xi + h, yi − k1h + k2h + k3 h − k4 h + k5 h)
8 55,296 512 13,824 110,592 4096
Lower order

- ODE is solved by 5th order estimation.


- The error estimation :

Ea = 5th-order prediction yi - 4th-order prediction yi


Refer to example 25.13.
37 250 125 512
4th order est.: y1 = yi + ( k1 + k2 + k3 + k 4 )h = 14.83192
*

378 621 594 1771


2825 18,575 13,525 277 1
5th order est.: y1 = yi + ( k1 + k3 + k4 + k5 + k6 )h
27,648 48,384 55,296 14,336 4
= 14.83677
Ea = 14.83677 − 14.83192 = 0.004842

Step size control


α
∆ new
hnew = h present
∆ present
h = step size
∆ present = the computed present accuracy
∆ new = the desired accuracy
0.2 when ∆ present ≤ ∆ new (h increase)
α=
0.25 when ∆ present > ∆ new (h decrease)

∆ new = ε yscale ε = an overall tolerance


dy
yscale = y + h
dx

You might also like