({{, (RefLink[FixedPointList, paclet:ref/FixedPointList])[f,expr]
generates a list giving the results of applying f repeatedly, starting with expr, until the results no longer change. }})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[FixedPointList, paclet:ref/FixedPointList])[f,expr] gives expr as the first element of the list it produces.

The last two elements in the list produced by (RefLink[FixedPointList, paclet:ref/FixedPointList]) are always the same.

(RefLink[FixedPointList, paclet:ref/FixedPointList])[f,expr,n] stops after at most n steps.

(RefLink[FixedPointList, paclet:ref/FixedPointList])[f,expr] applies (RefLink[SameQ, paclet:ref/SameQ]) to successive pairs of results to determine whether a fixed point has been reached.

(RefLink[FixedPointList, paclet:ref/FixedPointList])[f,expr,…,(RefLink[SameTest, paclet:ref/SameTest])->s] applies s to successive pairs of results.

OpenersPrimaryExamplesSection(Spacer1)Examples  (18)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Find the sequence of values leading to a fixed point:

FixedPointList[1+Floor[#/2]&,1000]

1+Floor[Last[%]/2]

Repeated application of a rule until the result no longer changes:

FixedPointList[#/.{a_,b_}/;b≠0->{b,Mod[a,b]}&,{28,21}]

GCD[28,21]

OpenersExampleSection1(Spacer1)Generalizations & Extensions  (1)

Stop after at most 5 steps:

FixedPointList[1+Floor[#/2]&,1000,5]

FixedPointList[1+Floor[#/2]&,1000]

OpenersExampleSection2(Spacer1)Options  (1)

OpenersExampleSubsection0(Spacer1)SameTest  (1)

Stop as soon as successive iterations differ by less than (10^(-10)):

FixedPointList[(# + 2/# )/2&,1`20,SameTest->(Abs[#1-#2]<1*^-10&)]

FixedPointList[(# + 2/# )/2&,1,SameTest->(Abs[#1-#2]<1*^-10&)]//TableForm

OpenersExampleSection3(Spacer1)Applications  (6)

Show convergence to (Sqrt[2]) in Newton’s method:

FixedPointList[(# + 2/# )/2&,1.0]

Find the fixed point of an integer sequence:

FixedPointList[11PrimePi[#]+1&,2]

Matrix convergence:

MatrixForm/@FixedPointList[{{0.51,0.49},{0.49,0.51}}.#&,{{1,0},{0,1}}]

Evaluate combinators:

FixedPointList[#/.{s[x_][y_][z_]->x[z][y[z]],k[x_][y_]->x}&,s[s[s]][s][k][k]]

Go up a directory tree to its root (the result will depend on computer system):

FixedPointList[ParentDirectory,$UserBaseDirectory]

Repeated differentiation:

FixedPointList[D[#,x]&,x^10]

OpenersExampleSection4(Spacer1)Properties & Relations  (4)

(RefLink[FixedPoint, paclet:ref/FixedPoint]) gives the last element of (RefLink[FixedPointList, paclet:ref/FixedPointList]):

FixedPointList[Function[x,(x+2/x)/2],1.0]

FixedPoint[Function[x,(x+2/x)/2],1.0]

(RefLink[NestList, paclet:ref/NestList]) goes for a fixed number of steps:

NestList[(# + 2/# )/2&,1.0,8]

FixedPointList[(# + 2/# )/2&,1.0]

Apply rules repeatedly until the result no longer changes:

FixedPointList[#/.{a->b,b->c,c->d}&,a^2+c^3]

a^2+c^3//.{a->b,b->c,c->d}

(RefLink[FixedPointList, paclet:ref/FixedPointList]) is equivalent to a particular choice of arguments of (RefLink[NestWhileList, paclet:ref/NestWhileList]):

NestWhileList[Function[x,(x+2/x)/2],1.0,UnsameQ,2]

OpenersExampleSection5(Spacer1)Possible Issues  (3)

Calculations may not converge in a finite number of steps:

TimeConstrained[FixedPointList[#/3+1/4&,Interval[{0,1}]],1]

Providing a maximum number of iterations will guarantee termination:

FixedPointList[#/3+1/4&,Interval[{0,1}],10]

Using a numerical test for convergence works in this case as well:

Take[FixedPointList[#/3+1/4&,Interval[{0,1}],SameTest->(SameQ[N[#1],N[#2]]&)],-3]

Convergence may fail in machine-precision computations due to oscillations in the final digits. Use a test function with a larger tolerance than (RefLink[SameQ, paclet:ref/SameQ]) to resolve this:

FixedPointList[Cos,0.5,SameTest->Equal]

When finding a fixed point, numerical precision may increase:

FixedPointList[InverseErf,0.5`10,10]//TableForm

OpenersExampleSection6(Spacer1)Neat Examples  (1)

The depth of intermediate expressions in a combinator evaluation [(WebLink[more info, http://www.wolframscience.com/nksonline/page-1122a-text ])]:

Depth/@FixedPointList[#/.{s[x_][y_][z_]->x[z][y[z]],k[x_][y_]->x}&,s[s[s[s][s]]][s][s][k]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[FixedPoint, paclet:ref/FixedPoint])  ▪  (RefLink[NestWhileList, paclet:ref/NestWhileList])  ▪  (RefLink[NestList, paclet:ref/NestList])  ▪  (RefLink[ComposeList, paclet:ref/ComposeList])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Applying Functions Repeatedly, paclet:tutorial/ApplyingFunctionsRepeatedly])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Functional Iteration, paclet:guide/FunctionalIteration])}, {▪(RefLinkPlain[Functional Programming, paclet:guide/FunctionalProgramming])}, {▪(RefLinkPlain[Constructing Lists, paclet:guide/ConstructingLists])}, {▪(RefLinkPlain[Iterated Maps & Fractals, paclet:guide/IteratedMapsAndFractals])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/27-applying-functions-repeatedly.html])(WebLink[: Applying Functions Repeatedly, https://www.wolfram.com/language/elementary-introduction/27-applying-functions-repeatedly.html])}, {(WebLink[DocumentationFooterIconsRelatedLinks-NKS.png(Spacer1)NKS|Online, http://www.wolframscience.com/nksonline/index/search.cgi?SearchIndex=FixedPointList]) ((WebLink[A New Kind of Science, http://www.wolframscience.com/nksonline/]))}})}})