Skip to Main Content Skip to Search
Product Documentation

plot::Iterationplotting iterated functions

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

→ Examples

Call:

plot::Iteration(f, x0, <n>, x = `x_{min}` .. `x_{max}`, <a = amin .. amax>, Options)

Parameters:

f

the iteration function: an arithmetical expression in the independent variable x and the animation parameter a. Alternatively, a MuPAD 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.

`x_{min}` .. `x_{max}`

the plot range: `x_{min}`, `x_{max}` must be numerical real values or expressions in the animation parameter a
`x_{min}` .. `x_{max}` is equivalent to the attributes XRange, XMin, XMax.

See Also:

plot, plot::copy, plot::Lsys

Details:

Example 1

We consider the logistic map for the parameter value 3, i.e., the parabola f(x) = 3*x*(1 - x) for x in [0, 1]. We iterate the starting point x[0] = 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)

MuPAD graphics

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)

MuPAD graphics

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)

MuPAD graphicsimage

delete f, g, it:

Example 2

We consider the logistic map f(x) = a*x*(1 - x) for x in [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 x[0] = 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)

MuPAD graphicsimage

We define an additional iteration starting at x[0] = 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)

MuPAD graphicsimage

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 x[0] = 0.2 by the logistic map f(x) = x*(x - 1) with the plot range x in [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)

MuPAD graphics

We see that only one step of the iteration is plotted. The reason is that the point x[1] = f(x[0]) 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)

MuPAD graphics

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)

MuPAD graphicsimage

delete f, g, it:

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS