1
$\begingroup$

I have two differential equations:

\begin{align}\frac{dx}{dt} &= 1 -(1+b)x+ax^2y\\ \frac{dy}{dt} &= bx - ax^2y\end{align}

I have been asked to solve them on Python using the Runge Kutta (4th order) method. I know how to solve a single ODE using this method, but don't know how to extend it to a system of ODEs.

Any help (or pointers) would be greatly appreciated,

Jack

$\endgroup$
2

1 Answer 1

1
$\begingroup$

HINT

You can reduce your system using the first equation: $$ ax^2y = x' - 1+b+bx $$ and so $$ y = \frac{x' - 1+b+bx}{ax^2} $$ (assuming $a \ne 0$) and now your ODE system will become a 2nd order ODE.

$\endgroup$
6
  • $\begingroup$ Thanks! Do I just substitute y from above into the bottom ode in my question? And then apply Runge Kutta? $\endgroup$ Commented Mar 16, 2017 at 15:59
  • $\begingroup$ @Jack yes, don't forget to compute $y'$ first :) Note that if you just add your equations, you get $x' + y' = 1-x$... $\endgroup$ Commented Mar 16, 2017 at 16:00
  • $\begingroup$ However, this helps you nothing with Runge-Kutta, as most numerical methods are formulated for first order systems. And if you wanted to reduce complexity, you would see that in the sum of both equations $x'+y'=1$ so that $x+y=t+C$. $\endgroup$ Commented Mar 16, 2017 at 16:11
  • 1
    $\begingroup$ Actually, converting nice smooth system of ODEs to a first order ODE with singularities is a bad idea when using numerical methods. $\endgroup$ Commented Mar 16, 2017 at 17:08
  • $\begingroup$ @Evgeny i agree, but if the only thing OP known how to implement is this, why not let him implement it in an unstable way instead of implementing nothing or spending a week reading up? $\endgroup$ Commented Mar 17, 2017 at 18:14

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.