Skip to content

FixedPoint ​

Iterates f from x until the result no longer changes.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageFixedPoint✓
FixedPoint(f, x, maxIterations?)iterates ff starting from xx until two successive values are equal, or for at most maxIterationsmaxIterations steps.
Typed signatures
TypePackageApplies
(function, initial: any, maxIterations: integer?) -> unknowncombinatoricsreplaces compute-enginealways
(function, initial: any, maxIterations: integer?) -> unknowncompute-enginealways

Domain: Collections

Details
  • compute-engine's own FixedPointFixedPoint does the iterating. Two successive values are the same when they are structurally identical or, for a float, agree to the working precision. It stays unevaluated when the iteration cannot converge: a value that nests the previous one, an exact number that gains digits at every step, or the default iteration limit reached without settling. A given maxIterations returns the last value instead, as Wolfram's does.
  • An inexact iteration runs with ten guard digits past the engine's precision and the answer is rounded back to it, so every printed digit is right: the last step of a convergent iteration is off by a few times the stopping gap, which at the engine's own precision would reach the last digit or two.
  • Newton's method for 2\sqrt{2} on an exact rational start gains digits at every step, so it never settles and the call stays unevaluated (Wolfram aborts there too). The two exact-rational examples show the call coming back unevaluated.

Examples

Basic #

Halving and flooring until nothing changes

live ↗
InFixedPoint(_1⁡↦⌊_1⁡2⌋,100)\mathrm{FixedPoint}(\operatorname{\_1}↦\lfloor\frac{\operatorname{\_1}}{2}\rfloor, 100)Out00

The Dottie number, the fixed point of cos

live ↗
InFixedPoint(cos⁡,0.5)\mathrm{FixedPoint}(\cos, 0.5)Out0.739 085 133 215 160 641 6550.739\,085\,133\,215\,160\,641\,655

Known value · mpmath 1.3.0 at 40 digits (cos iterated to its fixed point)

Iterating n↦1+⌊n/2⌋n \mapsto 1 + \lfloor n/2 \rfloor from 10001000 settles at 22

live ↗
InFixedPoint(_1⁡↦1+⌊_1⁡2⌋,1 000)\mathrm{FixedPoint}(\operatorname{\_1}↦1+\lfloor\frac{\operatorname{\_1}}{2}\rfloor, 1\,000)Out22
live ↗
InFixedPoint(_1⁡↦_1⁡+2_1⁡2,1)\mathrm{FixedPoint}(\operatorname{\_1}↦\frac{\operatorname{\_1}+\frac{2}{\operatorname{\_1}}}{2}, 1)OutFixedPoint(_1⁡↦_1⁡+2_1⁡2,1)\mathrm{FixedPoint}(\operatorname{\_1}↦\frac{\operatorname{\_1}+\frac{2}{\operatorname{\_1}}}{2}, 1)
Scope #

A start a thousand times larger lands on the same fixed point in a few more steps

live ↗
InFixedPoint(_1⁡↦1+⌊_1⁡2⌋,106)\mathrm{FixedPoint}(\operatorname{\_1}↦1+\lfloor\frac{\operatorname{\_1}}{2}\rfloor, 10^6)Out22

No step is taken when the start is already fixed

live ↗
InFixedPoint(_1⁡↦⌊_1⁡2⌋,0)\mathrm{FixedPoint}(\operatorname{\_1}↦\lfloor\frac{\operatorname{\_1}}{2}\rfloor, 0)Out00
Applications #

Newton's method for 2\sqrt{2}, run to this engine's default precision

live ↗
InFixedPoint(_1⁡↦_1⁡+2_1⁡2,1.5)\mathrm{FixedPoint}(\operatorname{\_1}↦\frac{\operatorname{\_1}+\frac{2}{\operatorname{\_1}}}{2}, 1.5)Out1.414 213 562 373 095 048 81.414\,213\,562\,373\,095\,048\,8

Known value · mpmath 1.3.0 at 40 digits (sqrt(2))

Differentiating x10x^{10} repeatedly bottoms out at 00, the derivative's fixed point

live ↗
InFixedPoint(_1⁡↦d_1⁡dx,x10)\mathrm{FixedPoint}(\operatorname{\_1}↦\frac{\mathrm{d}\operatorname{\_1}}{\mathrm{d}x}, x^{10})Out00
Properties #
live ↗
InFixedPoint(x↦x+2x2,1)\mathrm{FixedPoint}(x↦\frac{x+\frac{2}{x}}{2}, 1)OutFixedPoint(x↦x+2x2,1)\mathrm{FixedPoint}(x↦\frac{x+\frac{2}{x}}{2}, 1)
live ↗
InFixedPoint(_1⁡↦ReplaceAll(_1⁡,[Rule(a,b),Rule(b,c),Rule(c,d)]),a2+c3)\mathrm{FixedPoint}(\operatorname{\_1}↦\mathrm{ReplaceAll}(\operatorname{\_1}, \bigl\lbrack\mathrm{Rule}(a, b), \mathrm{Rule}(b, c), \mathrm{Rule}(c, d)\bigr\rbrack), a^2+c^3)Outd3+d2d^3+d^2
About
Examples10
Checked againstWolfram Language 8 agree2 error
CrosswalkWolfram Language

See also: Nest, NestList