There is no a
in your definition of the function w[]
, so it's no wonder that you can't get it to work.
You could try the following, but you would hit the same Overflow
problems as in your previous question.
w[a_] := Take[NestList[f[a], 0, 1000], 100]
I would suggest an alternative approach using NestWhile
:
w[a_] := NestWhile[f[a], 0, Abs[#] < 1000. &, 1, 100]
You will only get the "last" element in the iteration, defined either as the 100th iteration - it will have converged by then if it was going to - or the last iteration before the absolute value of the result broke through 1000 (i.e. it was diverging). That way, you break out before the iteration overflows.
You can then get your list of results using the Table
function (notice I've also preserved the values of $a$, which I've labeled $i$ for the purpose of defining the iteration in the table, so the values of the $a$ parameter are shown correctly in the subsequent plot:
result=Table[{i, w[i]}, {i, -0.2, 1.8, 0.01}];
And plot using ListLinePlot
:
ListLinePlot[result, PlotRange -> All, Frame -> True, AxesOrigin -> {0, 0}]
One thing I would mention is that it's not clear whether you should focus on a single starting point. You could instead define:
ff[a_, x0_] := NestWhile[#^2 + a &, x0, Abs[#] < 100. &, 1, 100]
And construct your results as:
result = Table[{i, ff[i, 0.1]}, {i, -0.2, 1.8, 0.01}];
You could then even have a two dimensional table:
result2 = Flatten[
Table[{i, j, ff[i, j]}, {i, -0.2, 1.8, 0.01}, {j, -0.2, 0.9, 0.1}], 1];
Which you could visualise using ListDensityPlot
:
ListDensityPlot[result2]