This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Plotting iterated functions

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

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


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


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.


AttributePurposeDefault Value
AffectViewingBoxinfluence of objects on the ViewingBox of a sceneTRUE
AntiAliasedantialiased lines and points?FALSE
Colorthe main colorRGB::Grey50
Framesthe number of frames in an animation50
Functionfunction expression or procedure 
Iterationsnumber of iterations in plot::Iteration10
Legendmakes a legend entry 
LegendTextshort explanatory text for legend 
LegendEntryadd this object to the legend?FALSE
LineColorcolor of linesRGB::Grey50
LineWidthwidth of lines0.35
LineStylesolid, dashed or dotted lines?Solid
Namethe name of a plot object (for browser and legend) 
ParameterEndend value of the animation parameter 
ParameterNamename of the animation parameter 
ParameterBegininitial value of the animation parameter 
ParameterRangerange of the animation parameter 
StartingPointstarting point of the iteration 
TimeEndend time of the animation10.0
TimeBeginstart time of the animation0.0
TimeRangethe real time span of an animation0.0 .. 10.0
Titleobject title 
TitleFontfont of object titles[" sans-serif ", 11]
TitlePositionposition of object titles 
TitleAlignmenthorizontal alignment of titles w.r.t. their coordinatesCenter
TitlePositionXposition of object titles, x component 
TitlePositionYposition of object titles, y component 
VisibleAfterobject visible after this time value 
VisibleBeforeobject visible until this time value 
VisibleFromToobject visible during this time range 
VisibleAfterEndobject visible after its animation time ended?TRUE
VisibleBeforeBeginobject visible before its animation time starts?TRUE
XMaxfinal value of parameter "x" 
XMininitial value of parameter "x" 
XNamename of parameter "x" 
XRangerange of parameter "x" 


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:



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.


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.


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.


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.


Animation parameter, specified as a = amin..amax, where amin is the initial parameter value, and amax is the final parameter value.

See Also

MuPAD Functions

MuPAD Graphical Primitives

Was this topic helpful?