I am creating Euler's method for $\frac{dw}{dt}=(3-w)(w+1)$ for $\Delta t=0.5$ from $0\le t \le 3$. I tried the following.
S[w_, t_] := (3 - w)*(w + 1)
S[0, 0] := 3
h = 0.5
S[w + 1, t] == w + h*S[w, t]
P[m_] := S[m, m]
Table[P[x], {x, 0, 3/(0.5)}]
Which gives
out[321]= 0.5
out[322]= {3, 3, 3, 0, -5, -12, -21}
However, I doubt this is the correct answer. What should I do instead?


S[w_, t_] := (3 - w)*(w + 1)F[w_, t_, h_] := w + h*S[w, t]{h, n} = {0.1, 20};pnts = NestList[{#1[[1]] + h, F[#1[[2]], #1[[1]], h]} &, {0, 0}, n];
– Arbuja Sep 12 '19 at 16:15ListLinePlot[pnts, PlotRange -> All]but instead getListLinePlot::lpn General::stop NestList::intnm ListLinePlot::lpn NestList::intnm NestList::intnm Set::altno NestList::intnm NestList::intnmHow do we fix this?S[w_, t_] := (3 - w)*(w + 1); F[w_, t_, h_] := w + h*S[w, t]; {h, n} = {0.1, 20}; pnts = NestList[{#1[[1]] + h, F[#1[[2]], #1[[1]], h]} &, {0, 0}, n]; ListLinePlot[pnts, PlotRange -> All]– Anton Antonov Sep 12 '19 at 16:49