MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Cobweb Plot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27518] Re: Cobweb Plot
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Sat, 3 Mar 2001 03:40:00 -0500 (EST)
  • References: <97l3cs$jfm@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Jon,
Here is a first attempt: the key is the function NestList the rest is mostly
manipulating this to get the points and then displaying.

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
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"Jon Joseph" <pokemon at tds.net> wrote in message
news:97l3cs$jfm at smc.vnet.net...
> I have been experimenting with chaotic systems and have been trying to
> produce a "Cobweb Plot".  A description of this type of plot, taken from
> "CHAOS An Introduction to Dynamical Systems" by Alligood, Sauer, Yorke, is
>
> "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
> jjoseph at nicoletbiomedical.com
>
>




  • Prev by Date: NSolve problem
  • Next by Date: Re: Integrate a matrix-function
  • Previous by thread: Re: Cobweb Plot
  • Next by thread: RE: Cobweb Plot