2
$\begingroup$

Consider the following system of differential equations: $$x'(t) = a\, x(t) - b \,x(t) y(t),$$ and $$ y'(t) = c\, x(t) y(t) - d \,y(t),$$ with $$ x(0) = x_0, y(0) = y_0$$

For example, we may have:

a = 2.2; b = 0.03; c = 1.4; d = 0.02;
eq1 = x'[t] == a*x[t] - b*x[t]*y[t]
eq2 = y'[t] == -c*y[t] + d*y[t]*x[t]
sol = NDSolve[{eq1, eq2, x[0] == 150, y[0] == 10}, {x, y}, {t, 0, 30}]
gr1 = Plot[Evaluate[{x[t], y[t]} /. sol], {t, 0, 30}, PlotStyle -> {{Thick, 
Hue[0.7]}, { Dashing[{0.03}], Hue[1]}}, Ticks -> {{{0.01, 0}, {10, "time"}, 
20}, {500, {700, "number"}, 1000}}, LabelStyle -> {FontFamily -> "Times", 
FontSize -> 16}, PlotLabel -> "solid blue: rabbits, dashed red: foxes"];
gr2 = ParametricPlot[Evaluate[{x[t], y[t]} /. sol], {t, 0, 30}, PlotStyle -> 
{Thick, Hue[0.3]}, Ticks -> {{{0.01`, 0}, 500, {700, "rabbits"}, 1000}, {500, 
{700, "foxes"}, 1000}}, LabelStyle -> {FontFamily -> "Times", FontSize -> 
16}];
sp = StreamPlot[{2.2` x - 0.03 y x, -1.4 y + 0.02` y x}, {x, 0, 200}, {y, 0, 
150}, StreamScale -> Large]
GraphicsRow[{gr1, gr2, sp}]
f[x_, y_] = {2.2 x - 0.03 x y, -1.4 y + 0.02 x y};
Show[VectorPlot[f[x, y], {x, 0, 4}, {y, 0, 4}], Frame -> True, 
BaseStyle -> {FontFamily -> "Times", FontSize -> 14}]
Show[VectorPlot[
f[x, y]/(10^-8 + Norm[f[x, y]]), {x, 0, 4}, {y, 0, 4}], 
Frame -> True, BaseStyle -> {FontFamily -> "Times", FontSize -> 14}]

I can't use a numerical method (e.g. Euler method) instead of NDSolve. I need the same method for $m x''(t)=-g x(t)^3$ Is there any idea?

$\endgroup$
  • 3
    $\begingroup$ What do you mean by "I can't use a numerical method (e.g. Euler method) instead of NDSolve. I need the same method for $mx′′(t)=−gx(t)^3$"? What exactly do you need? $\endgroup$ – xzczd Jan 19 at 10:06
  • $\begingroup$ I don't need to use NDSolve for solving the above system, that's all $\endgroup$ – George Jan 19 at 10:07
  • $\begingroup$ Do you mean you need to solve the problem without NDSolve? $\endgroup$ – xzczd Jan 19 at 10:13
  • $\begingroup$ yes, without NDSolve $\endgroup$ – George Jan 19 at 10:15
  • 3
    $\begingroup$ But you've already asked a question about Euler method and received an answer here. Solving a ODE and a system of ODE with Euler method are just the same. If you have difficulty in understanding that answer, you should continue asking in the comment under that answer, rather than ask essentially the same question again. $\endgroup$ – xzczd Jan 19 at 11:06
5
$\begingroup$

This is the famous Lotka-Volterra predator-prey model. I don't think there is a closed-form solution for the time dynamics but there is one for the orbits in the phase plane, which is described on that wikipedia page.

You can derive it in Mathematica with

DSolve[{y'[x] == (-c*y[x] + d*y[x]*x)/(a*x - b*x*y[x])}, y, x]

Mathematica graphics

| improve this answer | |
$\endgroup$

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