Labels

Thursday, June 18, 2020

Runge-Kutta Method

The fourth order Runge-Kutta method (RK4) is the most widely used algorithm for solving an ordinary differential equation.
\[ dy/dx = f(x,y) \]
\[ y_{n+1} = y_n +\frac{h}{6} (k_1+k_2+k_3+k_4) \],
where
\[ k_1 = f(x_n,y_n) \]
\[ k_2 = f(x_n+\frac{h}{2}, y_n+\frac{h}{2} k_1 \]
\[ k_3 = f(x_n+\frac{h}{2}, y_n+\frac{h}{2} k_2 \]
\[ k_4 = f(x_n+h,y_n+hk_3) .\]

$k_1$ is the slope at the beginning of the interval $[x_n,x_n+h]$.
$k_2$ is the slope at the midpoint of the interval, using slope $k_1$ to determine the value of $y$ at the point $x_n+h/2$ using Euler's method. 
$k_3$ is again the slope at the midpoint, but now using the slope $k_2$ to determine the $y$ value, $y(x_0+n*h+h/2) = y(x_0+n*h)+h/2*f(x_0+n*h+h/2,y(x_0+n*h)+h/2*k1)$.
$k_4$ is the slope at the end of the interval, with its $y$ value determined using $k_3$.
  

No comments:

Post a Comment