Population growth in Mathematica with NDSolve
:
f[r_, a_, T_] := NDSolve[{x' t] == r*x[t]*(1 - x[t]), x[0] == a}, x, {t, 0, T}]
s1 = f[0.1, 0.5, 30];
s2 = f[0.1, 2, 30];
Plot[{x[t] /. s1, x[t] /. s2, 1}, {t, 0, 30}, PlotRange -> {0, 2}]
Plot[Evaluate[Table[x[t] /. f[0.3, 0.2 n, 10], {n, 1, 10}]], PlotRange -> {0, 2}]
How can we solve it with Improved Euler's method?
P[q_, h_, N_] := (
u[0] = 1;
Do[u[n + 1] = u[n] + h*f[n*h + (h*q/2), u[n] + (h*q/2)*f[n*h, u[n]]], {n, 0, N}]
)
f[x_, t_] := r*x[t]*(1 - x[t])
Comments
Post a Comment