# 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.

# `plot`::`Iteration`

Plotting iterated functions

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

## Syntax

```plot::Iteration(`f`, `x0`, <`n`>, `x = xmin .. xmax`, <`a = amin .. amax`>, `options`)
```

## Description

`plot::Iteration`(f, `x0`, n, x = ``x_{min}` .. `x_{max}``) is a graphical object visualizing the iteration xi = f(xi - 1) (i = 1, …, n) of the given starting point x0.

The iteration is visualized by connecting the points (x0, 0) and (x0, x1) by a vertical line. For any step of the iteration, a horizontal line is drawn from the point (xi - 1, xi) (on the graph of f) to the point (xi, xi) on the main diagonal. From there, a vertical line is drawn to the next pair (xi, xi + 1) of the iteration.

The iteration object neither includes the graph of the function y = f(x) nor the main diagonal y = x. You need to plot them separately if you wish the function and/or the diagonal to be in your picture! See the examples.

The iteration is stopped prematurely when the iterated point leaves the plot range ``x_{min}`..`x_{max}``. Cf. Example 3.

Despite the fact that the number of iterations `n` represents an integer, it can be animated! Cf. Example 4

The default color used for the iteration plot is `RGB``::Grey50`. It can be modified by setting the attribute `Color` or `LineColor`. Cf. Example 1.

The default line style is solid. It can be modified by setting the attribute `LineStyle`.

## Attributes

AttributePurposeDefault Value
`AffectViewingBox`influence of objects on the `ViewingBox` of a scene`TRUE`
`AntiAliased`antialiased lines and points?`FALSE`
`Color`the main color`RGB::Grey50`
`Frames`the number of frames in an animation`50`
`Function`function expression or procedure
`Iterations`number of iterations in plot::Iteration`10`
`Legend`makes a legend entry
`LegendText`short explanatory text for legend
`LegendEntry`add this object to the legend?`FALSE`
`LineColor`color of lines`RGB::Grey50`
`LineWidth`width of lines`0.35`
`LineStyle`solid, dashed or dotted lines?`Solid`
`Name`the name of a plot object (for browser and legend)
`ParameterEnd`end value of the animation parameter
`ParameterName`name of the animation parameter
`ParameterBegin`initial value of the animation parameter
`ParameterRange`range of the animation parameter
`StartingPoint`starting point of the iteration
`TimeEnd`end time of the animation`10.0`
`TimeBegin`start time of the animation`0.0`
`TimeRange`the real time span of an animation`0.0` .. `10.0`
`Title`object title
`TitleFont`font of object titles[`" sans-serif "`, `11`]
`TitlePosition`position of object titles
`TitleAlignment`horizontal alignment of titles w.r.t. their coordinates`Center`
`TitlePositionX`position of object titles, x component
`TitlePositionY`position of object titles, y component
`Visible`visibility`TRUE`
`VisibleAfter`object visible after this time value
`VisibleBefore`object visible until this time value
`VisibleFromTo`object visible during this time range
`VisibleAfterEnd`object visible after its animation time ended?`TRUE`
`VisibleBeforeBegin`object visible before its animation time starts?`TRUE`
`XMax`final value of parameter “x”
`XMin`initial value of parameter “x”
`XName`name of parameter “x”
`XRange`range of parameter “x”

## Examples

### Example 1

We consider the logistic map for the parameter value 3, i.e., the parabola f(x) = 3 x (1 - x) for x ∈ [0, 1]. We iterate the starting point x0 = 0.5:

```f := plot::Function2d(3*x*(1 - x), x = 0..1, Color = RGB::Blue): x0 := 0.5:```

We plot the iteration (without specifying the number of iterations), the parabola f and the diagonal line g(x) = x:

```g := plot::Function2d(x, x = 0..1, Color = RGB::Red): it := plot::Iteration(3*x*(1 - x), x0, x = 0..1): plot(f, g, it)```

We increase the number of iterations to 50 and change the color of the lines to `RGB::Black`:

```it::Iterations := 50: it::Color := RGB::Black: plot(f, g, it)```

Finally, we animate the number of steps, allowing to follow the course of the iteration:

```it := plot::Iteration(3*x*(1 - x), x0, n, x = 0..1, n = 1..50, Color = RGB::Black): plot(f, g, it)```

`delete f, g, it:`

### Example 2

We consider the logistic map f(x) = ax (1 - x) for x ∈ [0, 1] and the animation parameter a running from a = 2 to a = 4:

```f := plot::Function2d(a*x*(1 - x), x = 0..1, a = 2..4, Color = RGB::Black):```

We define the iteration of the starting point x0 = 0.2 by f and plot it together with the function graph of f(x) and the diagonal line g(x) = x:

```g := plot::Function2d(x, x = 0..1, Color = RGB::Black): it1 := plot::Iteration(a*x*(1 - x), 0.2, 30, x = 0..1, a = 2..4, Color = RGB::Red): plot(f, g, it1)```

We define an additional iteration starting at x0 = 0.21 and add it to the plot:

```it2 := plot::Iteration(a*x*(1 - x), 0.21, 30, x = 0..1, a = 2..4, Color = RGB::Blue): plot(f, g, it1, it2)```

For small values of a, the two iterations converge to the same fixed point. When a approaches the value 4, the iterations drift into chaos.

`delete f, g, it1, it2:`

### Example 3

Consider the iteration of the starting point x0 = 0.2 by the logistic map f(x) = x (x - 1) with the plot range x ∈ [0, 1]:

```f := plot::Function2d(x*(x - 1), x = 0..1): it := plot::Iteration(x*(x - 1), 0.2, x = 0..1): plot(f, it)```

We see that only one step of the iteration is plotted. The reason is that the point x1 = f(x0) is negative and, hence, not contained in the requested plot range ```x = 0..1```. We modifiy the plot range:

```f::XRange:= -0.5..1: it::XRange:= -0.5..1: plot(f, it)```

`delete f, it:`

### Example 4

We animate the parameter n that sets the number of iterations. We set the time range for the animation to 40 (seconds). Using `Frames`, the total number of frames is chosen such that approximately 10 frames are used to visualize the step from n to n + 1:

```f := plot::Function2d(4*x*(1 - x), x = 0..1): g := plot::Function2d(x, x = 0..1): it := plot::Iteration(4*x*(1 - x), 0.4, n, x = 0..1, LineStyle = Dashed, n = 0..40, Frames = 411, TimeRange = 0..40): plot(f, g, it)```

`delete f, g, it:`

## Parameters

 `f` The iteration function: an arithmetical expression in the independent variable `x` and the animation parameter `a`. Alternatively, a procedure that accepts 1 input parameter `x` or 2 input parameters `x`, `a` and returns a real numerical value when the input parameters are numerical. `f` is equivalent to the attribute `Function`. `x0` The starting point for the iteration: `x0` must be a numerical real value or an expression in the animation parameter `a`. `x0` is equivalent to the attribute `StartingPoint`. `n` The number of iterations: `n` must be a positive integer or an expression in the animation parameter `a`. `n` is equivalent to the attribute `Iterations`. `x` The independent variable: an identifier or an indexed identifier. `x` is equivalent to the attribute `XName`. `xmin .. xmax` The plot range: `xmin`, `xmax` must be numerical real values or expressions in the animation parameter a. `xmin` .. `xmax` is equivalent to the attributes `XRange`, `XMin`, `XMax`. `a` Animation parameter, specified as `a```` = amin..amax```, where `amin` is the initial parameter value, and `amax` is the final parameter value.