# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# `@@`, `_fnest`

Iterate a function

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```f @@ n
_fnest(`f`, `n`)
```

## Description

`f@@n` represents the `n`-fold iterate `x -> f(f(...(f(x))...))` of the function `f`.

The statement `f@@n` is equivalent to the call ```_fnest(f, n)```.

For positive `n`, `f@@n` is also equivalent to `_fconcat(f \$ n)`.

`f@@0` returns the identity map `id`.

If `f` is a function environment with the slot `"inverse"` set, `n` can also be negative. Cf. Example 2.

Iteration is only reasonable for functions that accept their own return values as input. Note that `fp::fixargs` is a handy tool for converting functions with parameters to univariate functions which may be suitable for iteration. Cf. Example 3.

## Examples

### Example 1

For a nonnegative integer `n`, `f@@n` is equivalent to an `_fconcat` call:

`f@@4, (f@@4)(x)`

`@@` simplifies the composition of symbolic iterates:

`(f@@n)@@m`

The iterate may be called like any other MuPAD® function. If `f` evaluates to a procedure and `n` to an integer, a corresponding value is computed:

`f := x -> x^2: (f@@n)(x) \$ n = 0..10`

`delete f:`

### Example 2

For functions with a known inverse function, `n` may be negative. The function `f` must have been declared as a function environment with the `"inverse"` slot. Examples of such functions include the trigonometric functions which are implemented as function environments in MuPAD:

`sin::"inverse", sin@@-3, (sin@@(-3))(x)`

### Example 3

`@@` can only be used for functions that accept their own output domain as an input, i.e., for some set M. If you want to use `@@` with a function which needs additional parameters, `fp::fixargs` is a handy tool to generate a corresponding univariate function. In the following call, the function `f: x -> g(x, p)` is iterated:

`g := (x, y) -> x^2 + y: f := fp::fixargs(g, 1, p): (f@@4)(x)`

`delete g, f:`

## Parameters

 `f` `n` An integer or a symbolic name

Function