Re: FixedPoint vs. FixedPointList

*To*: mathgroup at smc.vnet.net*Subject*: [mg24428] Re: [mg24384] FixedPoint vs. FixedPointList*From*: BobHanlon at aol.com*Date*: Tue, 18 Jul 2000 00:58:26 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

In a message dated 7/12/2000 11:43:32 PM, linsuain+ at andrew.cmu.edu writes: >Hi all. I need to know the fixed point of a function (to a certain >accuracy) starting from a certain value of the arguement, say: > > x = FixedPoint[ f, x, SameTest -> ( #2-#1 < somesmallnumber &) ] > > I do not care about the intermediate results, but I would like to know >how many iterations it takes for the process to converge. FixedPointList >will do, for example: > > {n,x}={Length[#],Last[#]}& @ FixedPointList[....] > > However I believe this would cause problems. The reason is that x is >really a very long list (FixedPoint works for lists too), and it could >take many iterations for this to settle. Mathematica, I believe, stores >only a maximum of two values at any given moment when executing >FixedPoint, but it stores all intermediate values for FixedPointList, >and most certainly would run out of memory. > > Could any think of how to trick Mathematica to count the iteration >without trying to store all the results? > poly[x_] := x^5 - x^4 + 2 x^3 - x^2 + 3; n = 1; FixedPoint[(n++; # - poly[#]/poly'[#]) &, 2.] -0.8574417862415682 n 23 Length[FixedPointList[(n++; # - poly[#]/poly'[#]) &, 2.]] 23 Bob Hanlon