• Home
  • Royal Holloway, University of London
  • From Euclid to Mandelbrot
  • Iterative Functions and Cobweb Diagrams

Iterative Functions and Cobweb Diagrams

Iteration To define a function, and draw a time series plot: f [x_] := 1.05 x - 100 points = Table [{t, Nest [f, 1900, t]}, {t, 0, 20}] ListPlot [points, Joined -> True, Mesh -> All] This gives the following output: {{0, 1900}, {1, 1895.}, {2, 1889.75}, {3, 1884.24}, {4, 1878.45}, {5, 1872.37}, {6, 1865.99}, {7, 1859.29}, {8, 1852.25}, {9, 1844.87}, {10, 1837.11}, {11, 1828.97}, {12, 1820.41}, {13, 1811.44}, {14, 1802.01}, {15, 1792.11}, {16, 1781.71}, {17, 1770.8}, {18, 1759.34}, {19, 1747.3}, {20, 1734.67}} 1900 1850 1800 1750 0 -0 5 10 15 20 If you don't want to print the list of points, end the second line (the one defining points) with a semicolon (";"). The following function has 5 fixed points at 0, 0.25, 0.5, 0.75 and 1 (approximately). 1 1.0 0.8 0.6 0.4 0.2 0.0 0.0 0.2 0.4 0.6 0.8 1.0 Mathematica code for cobweb diagrams: Cobweb [fn_, highx_, startx_, n_] : = Block [{web = {}}, For [x = startx; i = 1, i < n, ++i; x = fn [x], web = Join [Bounce [fn, x] , web]] ; Show [Plot [{fn [p], p}, {p, 0, highx}, PlotStyle -> {RGBColor [1, 0, 0], RGBColor [0, 0, 0]}, DisplayFunction -> Identity] , Graphics [{PointSize [0.02], {Line [{{startx, 0}, {startx, fn[startx] }}], Point [{startx, fn [startx] }]}, web}], AspectRatio -> Automatic, PlotRange -> {0, highx}, Axes -> Automatic, DisplayFunction -> $DisplayFunction]] Bounce [fn_, a_] := {Line[{{a, fn[a]}, {fn[a], fn[a]}, {fn [a] , fn[fn[a]]}}], Point [{fn [a] , fn [fn [a] ] }]} You can cut and paste this text from the electronic version of this document, or download the Mathematica notebook, from the MT1100 Moodle page. 2 This code is adapted from Frank Wattenberg's web page http://www.math. montana.edu/frankw/ccp/calculus/discdynm/cobweb/learn.htm Once the above code is run, you can draw a cobweb diagram for the function f, plotting x in the range 0 to 1000, starting with value x0 = 100, computing 15 iterations, by using the following code: f [x_] := 3.4 (1 - . 001 x) x Cobweb[f, 1000.0, 100, 15] This gives the following output: 1000 ! 800 600 400 200 200 400 600 800 1000 This function has a stable limit cycle (475,875) (approximately) of period 2. The function f(x) = ax+(1-a) has a fixed point u = 1. It is stable when |a| < 1 and unstable when |a| > 1. Cobweb diagrams below show iterates starting at 0.5 when a = - 1.1, a = - 0.8, a = 0.8 and a = 1.1 respectively. 3