Here's the solution with streamplot. We need to enter the functions in a slightly different way now:
f = {x^2 - 0.2 x^3 - 2, 0}
or
f = {-1.3 x^2 + 0.2 x^3 + 2, 0}
or
f = {x^2, 0}
So we only need to add a second component which is zero. The program distinguishes again between the three main cases.
M = 12; zeros = DeleteDuplicates[NSolve[f[[1]] == 0, x, Reals]];
If[Length[zeros] == 0,
(*no fixed points*)
Print["There are no zeros."],
If[(Min[x /. zeros] - Max[x /. zeros]) != 0,
(*more than one fixed point*)
StreamPlot[
f, {x, Min[x /. zeros] - 0.2*(Max[x /. zeros] - Min[x /. zeros]),
Max[x /. zeros] +
0.2*(Max[x /. zeros] - Min[x /. zeros])}, {y, -0.1, 0.1},
AspectRatio -> 0.1, ImageSize -> Large, Frame -> None,
StreamPoints -> {Table[{x,
0}, {{x,
Min[x /. zeros] - 0.2*(Max[x /. zeros] - Min[x /. zeros]),
Max[x /. zeros] +
0.2*(Max[x /. zeros] - Min[x /. zeros]), (Max[x /. zeros] -
Min[x /. zeros])/M}}]},
Epilog ->
Table[{{Red, Disk[{x /. zeros[[i]], 0.}, {0.1, 0.05}]},
Text[Style[x /. zeros[[i]], Medium], {x /. zeros[[i]],
0.15}]}, {i, 1, Length[zeros]}]],
(*xeactly one fixed point*)
StreamPlot[
f, {x, (x /. zeros[[1]]) - 1., (x /. zeros[[1]]) + 1.}, {y, -0.05,
0.05}, AspectRatio -> 0.1, ImageSize -> Large, Frame -> None,
StreamPoints -> {Table[{x,
0}, {{x, (x /. zeros[[1]]) - 1., (x /. zeros[[1]]) + 1.,
2./M}}]},
Epilog ->
Table[{{Red, Disk[{x /. zeros[[i]], 0.}, {0.04, 0.03}]},
Text[Style[x /. zeros[[i]], Medium], {x /. zeros[[i]],
0.06}]}, {i, 1, Length[zeros]}]]]]
The problem is that in that version we have to adapt the plot range on the y-axis and also slighty change the size of the red dots every time we run it. It is easy to fix, but the code should show the idea. A typical output figure looks like this:
M.