FixedPointList

FixedPointList[f,expr]

generates a list giving the results of applying f repeatedly, starting with expr, until the results no longer change.

Details and Options

  • FixedPointList[f,expr] gives expr as the first element of the list it produces.
  • The last two elements in the list produced by FixedPointList are always the same.
  • FixedPointList[f,expr,n] stops after at most n steps.
  • FixedPointList[f,expr] applies SameQ to successive pairs of results to determine whether a fixed point has been reached.
  • FixedPointList[f,expr,,SameTest->s] applies s to successive pairs of results.

Examples

open allclose all

Basic Examples  (2)

Find the sequence of values leading to a fixed point:

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

Generalizations & Extensions  (1)

Stop after at most 5 steps:

Options  (1)

SameTest  (1)

Stop as soon as successive iterations differ by less than :

Applications  (6)

Show convergence to in Newtons method:

Find the fixed point of an integer sequence:

Matrix convergence:

Evaluate combinators:

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

Repeated differentiation:

Properties & Relations  (4)

FixedPoint gives the last element of FixedPointList:

NestList goes for a fixed number of steps:

Apply rules repeatedly until the result no longer changes:

FixedPointList is equivalent to a particular choice of arguments of NestWhileList:

Possible Issues  (3)

Calculations may not converge in a finite number of steps:

Providing a maximum number of iterations will guarantee termination:

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

Convergence may fail in machine-precision computations due to oscillations in the final digits. Use a test function with a larger tolerance than SameQ to resolve this:

When finding a fixed point, numerical precision may increase:

Neat Examples  (1)

The depth of intermediate expressions in a combinator evaluation [more info]:

Introduced in 1991
 (2.0)
 |
Updated in 1996
 (3.0)