This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Built-in Functions / Programming / Functional Programming  /
Nest

  • Nest[ f , expr , n ] gives an expression with f applied n times to expr.
  • Example: Nest[f, x, 3].
  • You can use Throw to exit from Nest before it is finished.
  • See the Mathematica book: Section 2.2.2.
  • See also: Fold, Function, FixedPoint, Do.

    Further Examples

    This nests the function f four times starting with initial value x.

    In[1]:=

    Out[1]=

    This iteration provides evidence that the sine function approaches its fixed point at zero very slowly.

    In[2]:=

    Out[2]=

    See the Further Examples for NestList.