You are on page 1of 9

Runge-Kutta (R-K) Methods

Sep 30, 2016


File: 001-Runge Kutta Methods Presentation-V3

1
RK-4
• The Runge-Kutta method is the most popular method for solving ordinary
differential equations (ODEs) by means of numerical approximations.
• There are several version of the method depending on the desired accuracy.
• The most popular RK method is of fourth order (i.e., RK-4), which in simpler terms
means that the error is of the order of h4 , abbreviated as O(h4).

2
RK-4

initially, i.e., @ 𝑡𝑗


at half interval, i.e., @ 𝑡𝑗 + 2


at half interval, i.e., @ 𝑡𝑗 +
2

at the end, i.e., @ 𝑡𝑗 +h

• k1, k2, k3, k4 Runge-Kutta slopes


• The calculation sequence is k1, k2, k3, k4, and then yi+1.
3
4
Example

5
matlab program:
% RK-4
clc, clear
h=0.1; a=0; b=3; % h is the step size, t=[a,b] is the domain
t = a:h:b; % Computes t-array from a to b, in steps of h; initial time is t(1)
y(1) = 5; % initial condition; in MATLAB indices start at 1
F= @(t,y) 3.*exp(-t)-0.4*y; % the RHS function of Euler’s standard format

for ii=1:1:numel(t)-1 % numel(t) computes the number of elements of t-array (i.e., nodes)
k1 = F(t(ii),y(ii));
k2 = F(t(ii)+0.5*h,y(ii)+0.5*h*k1);
k3 = F((t(ii)+0.5*h),(y(ii)+0.5*h*k2));
k4 = F((t(ii)+h),(y(ii)+h*k3));
y(ii+1) = y(ii) + (h/6)*(k1+2*k2+2*k3+k4); % main equation
end

See: Runge-Kutta-4-Order with Solution.doc


6
code output

i t(i) k1 k2 k3 k4 y(i) i t(i) k1 k2 k3 k4 y(i)


1 0.00 1.000 0.834 0.837 0.681 5.000 16 1.50 -1.080 -1.091 -1.090 -1.100 4.372
2 0.10 0.681 0.535 0.538 0.401 5.084 17 1.60 -1.100 -1.107 -1.107 -1.113 4.263
3 0.20 0.401 0.273 0.276 0.156 5.138 18 1.70 -1.113 -1.118 -1.117 -1.121 4.153
4 0.30 0.156 0.045 0.047 -0.057 5.165 19 1.80 -1.121 -1.122 -1.122 -1.123 4.041
5 0.40 -0.057 -0.154 -0.152 -0.242 5.170 20 1.90 -1.123 -1.122 -1.122 -1.121 3.929
6 0.50 -0.242 -0.326 -0.324 -0.402 5.155 21 2.00 -1.121 -1.118 -1.118 -1.115 3.817
7 0.60 -0.402 -0.475 -0.473 -0.540 5.122 22 2.10 -1.115 -1.110 -1.110 -1.105 3.705
8 0.70 -0.540 -0.602 -0.601 -0.658 5.075 23 2.20 -1.105 -1.099 -1.099 -1.093 3.594
9 0.80 -0.658 -0.711 -0.709 -0.758 5.015 24 2.30 -1.093 -1.086 -1.086 -1.078 3.484
10 0.90 -0.758 -0.802 -0.801 -0.842 4.944 25 2.40 -1.078 -1.070 -1.070 -1.061 3.375
11 1.00 -0.842 -0.879 -0.878 -0.912 4.864 26 2.50 -1.061 -1.052 -1.052 -1.042 3.268
12 1.10 -0.912 -0.942 -0.942 -0.969 4.776 27 2.60 -1.042 -1.032 -1.033 -1.022 3.163
13 1.20 -0.969 -0.994 -0.993 -1.015 4.682 28 2.70 -1.022 -1.012 -1.012 -1.001 3.060
14 1.30 -1.015 -1.035 -1.035 -1.052 4.583 29 2.80 -1.001 -0.990 -0.990 -0.979 2.959
15 1.40 -1.052 -1.067 -1.067 -1.080 4.479 30 2.90 -0.979 -0.967 -0.968 -0.956 2.860

7
Numerical Solution

8
List of Runge Kutta
• https://en.wikipedia.org/wiki/List_of_Runge%E2%80%93Kutta_methods

You might also like