[Math] $2$-dimensional Runge-Kutta for system of polynomial ODEs

numerical methodsordinary differential equationsrunge-kutta-methods

I have just started getting into ODEs, and have come across the Runge-Kutta method for numerically solving them. However, in playing around with them to model hypothetical situations, I came across the equations:

$$\begin{aligned} \dot x &= x – x^2 – y\\ \dot y &= xy – y^2 \end{aligned}$$

I was trying to think of how one would use Runge Kutta methods to do this, and I couldn't figure it out. What is this type of differential equation called, and how can I simulate/solve it?

Best Answer

The Runge-Kutta formulas for a system of differential equations are really the same as for a single equation, it's just that your dependent variable is a vector rather than a scalar. Write your system as $$\dfrac{dX}{dt} = F(t, X(t))$$ where $X = (x, y)$. If you're using the classical fourth-order Runge-Kutta with step size $h$, your iteration is $$ \eqalign{K_1 &= h F(t_n, X_n)\cr K_2 &= h F(t_n + h/2, X_n + K_1 /2)\cr K_3 &= h F(t_n + h/2, X_n + K_2 /2)\cr K_4 &= h F(t_n + h, X_n + K_3)\cr t_{n+1} &= t_n + h\cr X_{n+1} &= X_n + (K_1 + 2 K_2 + 2 K_3 + K_4)/6\cr}$$