"A cobweb plot illustrates convergence to an attracting fixed point of
g(x)=2x(1-x). Let x0=0.1 be the initial condition. Then the first iterate is
x1=g(x0)=0.18. Note that the point (x0,x1) lies on the function graph, and
(x1,x1) lies on the diagonal line. Connect these points with a horizontal
dotted line to make a path. Then find x2=g(x1)=0.2952, and continue the
path with a vertical dotted line to (x1, x2) and with a horizontal dotted
line to (x2, x2). An entire orbit can be mapped out this way."
I can create the data in a procedural program and then plot the list that
results. Can anyone think of a more elegant, Mathematica oriented,
approach? Thanks in advance
Dr. Jon Joseph
VP of Advanced Technology
Nicolet Biomedical
5225 Verona Road
Madison WI 53711
jjo...@nicoletbiomedical.com
CobwebPlot[expr_,x_,a_,n_]:=
Block[{(f,nl, pts, min,max)},
f= Function[x,expr];
nl = NestList[f,a,n];
pts=Transpose[{Drop[#,-1],Rest[#]}&@Flatten[Transpose[{#,#}&@nl]]];
min= Min[nl];
max= Max[nl];
Plot[f[x],{x, min,max},
Epilog -> {
{Hue[0],Line[pts]}, {Hue[.7],Line[{{min,min},{max,max}}]}},
PlotRange->{min,max},
Frame->True
]
]
Test
CobwebPlot[2x (1-x),x, 0.15, 30]
--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
h...@haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565
"Jon Joseph" <pok...@tds.net> wrote in message
news:97l3cs$j...@smc.vnet.net...
There is a nice discussion about how to do this is Theo Gray and Jerry
Glynn's book on Exploring Mathematics with Mathematica. Here is a
variation on their method for 1-D maps:
g[x_] := x + 3 - Exp[.6 x]
GraphIterate[x0_, y_, n_] :=
Module[{iterate},
iterate =
Map[{Line[{{#, #}, {#, y[#]}}], Line[{{#, y[#]}, {y[#], y[#]}}]}
&,
NestList[y, x0, n]]]
Plot[g[x], {x, 0, 6}, AxesOrigin -> {0, 0}, PlotRange -> {{0, 6}, {0,
4}},
Epilog -> {Line[{{0, 0}, {8, 8}}], GraphIterate[2.6, g, 10]}]
Cheers,
Brian
something like this ?
http://www.mathconsult.ch/showroom/pubs/MathProg/htmls/p2-1.htm
Buy the book by Romand Maeder
http://www.amazon.com/exec/obidos/ASIN/0124649920/mathconsdrrmder/107-1760968-0378115
Regards
Jens
Please remove parentheses from
Block[{(f,nl, pts, min,max)}
to get
Block[{f,nl, pts, min,max}
Thanks to Reza Malek-Madani for pointing our this slip up.
--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
h...@haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565
"Allan Hayes" <h...@haystack.demon.co.uk> wrote in message
news:97qb14$n...@smc.vnet.net...