It is given the following problem: $$x'=rx-bx^2-cxy-\frac{\beta xy}{\alpha+x}$$ $$y'=-\mu y+\frac{\beta xy}{\alpha+x}$$ With parameters $r=1,b=1,c=0.01, \mu=0.4,\alpha= 0.36$ and initial values $x(0)=0.2, y(0)=0.05$
I have solved this problem with the NDSolve command
r = 1;
b = 1;
c = 0.01;
a = 0.36;
\[Mu] = 0.4;
deq1 = x'[t] ==
r* x[t] - b*x[t]^2 - c*x[t]*y[t] - 0.75*x[t]*y[t]/(a + x[t])
deq2 = y'[t] == -\[Mu]*y[t] + 0.75*x[t]*y[t]/(a + x[t])
soln = NDSolve[{deq1, deq2, x[0] == 0.2, y[0] == 0.05}, {x[t], y[t]}, {t, 0, 200}]
soln[t_] =
NDSolveValue[{deq1, deq2, x[0] == 0.2, y[0] == 0.05}, {x[t],
y[t]}, {t, 0, 200}];
Plot[soln[t], {t, 0, 200}, PlotRange -> All]
Now, I am trying the same with the Improved Euler's Method
UPDATED
r = 1;
b = 1;
c = 0.01;
a = 0.36;
\[Mu] = 0.4;
f[x_,y_]:=r* x[t] - b*x[t]^2 - c*x[t]*y[t] - 0.75*x[t]*y[t]/(a + x[t])
g[x_,y_]:=y'[t] == -\[Mu]*y[t] + 0.75*x[t]*y[t]/(a + x[t])
Q[a_, b_, h_, N_] := (u[0] = a; v[0] = b;
Do[{u[n + 1] =
u[n] + h*
F[u[n] + (h/2)*F[u[n], v[n]],
v[n] + (h/2)*
G[u[n], v[
n]]], \
v[n + 1] =
v[n] + h*
G[u[n] + (h/2)*F[u[n], v[n]], v[n] + (h/2)*G[u[n], v[n]]]}, {n,
0, N}])
Q[0.2, 0.05, 1,200]
u[200]
X = Interpolation[Table[{0.05 n, u[n]}, {n, 0, 100}]]
Y = Interpolation[Table[{0.05 n, v[n]}, {n, 0, 100}]]
ParametricPlot[{X[t], Y[t]}, {t, 0, 200}]
I have run this code on Mathematica but it did not give me results for the plot.
f
to three arguments, but it is only defined for two arguments. $\endgroup$