2
$\begingroup$

I am trying to solve the following system of nonlinear ODEs (Lotka-Volterra equations: Predator-Prey Model, see: http://greenteapress.com/matlab/PhysModMatlab.pdf p. 108)

eq1 = R'[t] - r R[t] - alpha R[t] F[t];
eq2 = F'[t] - delta F[t] + beta R[t] F[t];

with the following set of parameters

r = 5/10; alpha = 1/100; delta = -5/10; beta = 1/100;

Initial conditions are F[0] == 0 and R[0] == 0 and the time interval of interest is {t,0,50}. I use NDSolve.

NDSolve[
 eq1 == 0 && eq2 == 0 && R[0] == 80 && F[0] == 100, {R, F}, {t, 0, 
  50}]

I get an error message:

Error test failure at t == 47.273657697681124`; unable to continue.

and as an output two interpolating functions. I have solved the same initial problem in Octave making use of ode45 function. Mathematica's interpolating solutions behavior does not match that obtained in Octave.

How can I ameliorate NDSolve performance (Mathematica version number: 11.3)?

$\endgroup$

closed as off-topic by Chris K, eyorble, MarcoB, Henrik Schumacher, m_goldberg May 9 '18 at 22:51

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Chris K, eyorble, MarcoB, Henrik Schumacher, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Try Method -> "Adams" in NDSolve. And other methods. $\endgroup$ – Αλέξανδρος Ζεγγ May 9 '18 at 11:00
  • $\begingroup$ You can try with, Quiet@NDSolve[ eq1 == 0 && eq2 == 0 && R[0] == 80 && F[0] == 100, {R, F}, {t, 0, 50}] $\endgroup$ – Gopal Verma May 9 '18 at 12:02
  • $\begingroup$ As @Alan mentioned, please check your equations and parameter setups, e.g., with Lotka-Volterra equations. $\endgroup$ – Αλέξανδρος Ζεγγ May 9 '18 at 12:11
5
$\begingroup$

That's not an LV system. It looks like you lost track of the parameter signs. Try this:

With[{r = 5/10, alpha = 1/100, delta = 5/10, beta = 1/100},
 eq1 = R'[t] == r R[t] - alpha R[t] F[t];
 eq2 = F'[t] == -delta F[t] + beta R[t] F[t];]
slv = NDSolve[
  eq1 && eq2 && R[0] == 80 && F[0] == 100, {R, F}, {t, 0, 50}]
Plot[Evaluate[{R[t], F[t]} /. slv], {t, 0, 30}]
$\endgroup$
  • $\begingroup$ Ooo. I am very naif:-)! Thanks a lot! $\endgroup$ – Dimitris May 9 '18 at 12:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.