Second-order Runge-Kutta scheme (RK2)
Put simply, it improves upon the Euler method by adding a midpoint in the step which increases the accuracy by one order.
Heun method
- \(y_n\) is the approximation of solution at time \(t_n\)
- \(y_{n+1}\) is the approximation of solution at time \(t_{n+1}\)
- \(h\) is the step size
- \(f(t,y)\) is the function that defines the derivative of \(y\) with repsect to \(t\), ie \(\dot y = f(t, y)\)
- In the first step, calculate the estimate of slope of solution at beginning of time step. Then calculate a provisional value of the solution at the end of the time step, by using explicit Euler.
- Calculate the estimate of slope of solution at provisional value of the solution. Then use this estimate to calculate a new improved estimate of solution at end of time step.
\[\begin{aligned}p_1&=x_n\\v_1&=v_n\\a_1&=a(p_1,v_1)\\p_2&=p_1+v_1\cdot\Delta t\\v_2&=v_1+a_1\cdot \Delta t\\a_2&=a(p_2,v_2)\\x_{n+1}&=x_n+\frac{v_1+v_2}{2}\cdot \Delta t\\v_{n+1}&=v_n+\frac{a_1+a_2}{2}\cdot \Delta t \end{aligned} \]
Comparison to basic Euler
Midpoint method
Explicit Midpoint method
Implicit Midpoint method
Fourth-order Runge Kutta method (RK4)
The "classic Runge-Kutta method" or simply the "Runge-Kutta method" refers to the following.
The formula is given by
\[\begin{aligned} y_{n+1}&=y_{n}+{\frac {h}{6}}\left(k_{1}+2k_{2}+2k_{3}+k_{4}\right),\\ t_{n+1}&=t_{n}+h\\ \end{aligned} \]
for n = 0, 1, 2, 3, ..., using:
\[{\displaystyle {\begin{aligned}k_{1}&=\ f(t_{n},y_{n}),\\k_{2}&=\ f\!\left(t_{n}+{\frac {h}{2}},y_{n}+h{\frac {k_{1}}{2}}\right),\\k_{3}&=\ f\!\left(t_{n}+{\frac {h}{2}},y_{n}+h{\frac {k_{2}}{2}}\right),\\k_{4}&=\ f\!\left(t_{n}+h,y_{n}+hk_{3}\right)\end{aligned}}}\]
Here \(y_{n+1}\) is the RK4 approximation of \(y(t_{n+1})\), and the next value \((y_{n+1})\) is determined by the present value \((y_{n})\) plus the weighted average of four increments, where each increment is the product of the size of the interval, h, and an estimated slope specified by function f on the right-hand side of the differential equation.