# Pure function in Nest

I can't figure out what I'm doing wrong here:

Table[Nest[# + 0.1 * -i *  #^2 &, 2, 1] , {i, 0, 0.5, 0.1}]
(* {2., 1.96, 1.92, 1.88, 1.84, 1.8} *)


The problem is that it keeps using 2 in the argument instead of the last result. Normally the first parameter is the starting point, when using the pure function.

The output should be something like

(* {2., 1.96, 1.883, 1.777, 1.651, 1.514} *)

-

Mathematica does do the right thing. For your purpose, Fold or FoldList should be used.

FoldList[#1 + 0.1*-#2*#1^2 &, 2.0, Range[0.1, 0.5, 0.1]]


Mathematica gives

{2.,1.96,1.88317,1.77678,1.6505,1.51429}


Exactly what you want.

-
Okay thanks. I thought i was possible to use Nest(List) here, because if you nest 3 or 4 times fx you use the last result each time. But im still a rookie it appears :) – Punchline Dec 17 '13 at 9:45