MathGroup Archive 2001

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

Search the Archive

Re: Cobweb Plot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27537] Re: [mg27494] Cobweb Plot
  • From: Tomas Garza <tgarza01 at prodigy.net.mx>
  • Date: Sat, 3 Mar 2001 03:40:20 -0500 (EST)
  • References: <200103010853.DAA19795@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

A possibility, very much along the functional approach of Mathematica's, is
as follows. First, define the function whose convergence you want to study,
say g[x] (notice the square brackets). I propose, as an example,

In[1]:=
g[x_] = 2 x^2 - 1;

since the one you mention, 2x * (1- x), doesn't exhibit the "cobweb"
appearance you'd like to see. Then use the following function, which has as
arguments "start", the starting point, and "n", the number of iterations of
g (I would rather use FixedPointList, but NestList will do):

In[2]:=
cobweb[start_, n_] :=
  Module[{s = NestList[g, start, n], pointsOnGraph, pointsOnDiagonal},
    pointsOnGraph = Drop[{Drop[s, -1], Rest[s]} // Transpose, -1];
    pointsOnDiagonal =
      Prepend[Partition[Drop[Rest[Flatten[pointsOnGraph]], -1], 2], {start,
          start}];
    Show[Graphics[
        Line @@ {Partition[
              Flatten[Transpose[{pointsOnDiagonal, pointsOnGraph}]], 2]}],
      Epilog -> {{Hue[1], PointSize[0.02], Point[{start, start}]},
          Line[{{Min[s], Min[s]}, {Max[s], Max[s]}}]}, Axes -> True,
      AxesOrigin -> {0, 0},
      PlotRange -> {{If[Min[s]<0,Min[s],0], Max[s]}, {If[Min[s]<0,Min[s],0],
Max[s]}}]]

Try, for example, 0.321 as starting point, with n = 20. The starting point
appears in red on the diagonal (0.321, 0.321).

Tomas Garza
Mexico City

----- Original Message -----
From: "Jon Joseph" <pokemon at tds.net>
To: mathgroup at smc.vnet.net
Subject: [mg27537] [mg27494] Cobweb Plot


> 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
>
>



  • References:
  • Prev by Date: Re: Sound file -> CD burner??
  • Next by Date: real-time graphics editing
  • Previous by thread: Cobweb Plot
  • Next by thread: Re: Cobweb Plot