Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

newbie: can't Manipulate ListPlot of recurrence

105 views
Skip to first unread message

Tom Roche

unread,
Feb 24, 2009, 5:45:20 AM2/24/09
to
summary: I'm trying to Manipulate the logistic map. I can ListPlot it,
but when I try to Manipulate, the UI behaves weirdly.

details:

As advertised by the Subject:, I'm new to Mathematica (specifically
7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any
lapses in terminology. I'd also appreciate pointers to specific docs
rather than just an RTFM.

I'm trying to model the logistic map y=a y (1-y):

http://en.wikipedia.org/wiki/Logistic_map
http://mathworld.wolfram.com/LogisticMap.html
http://www.phy.duke.edu/~palmer/notebooks/LogisticMap.nb

To start with I just tried to plot it, which works:

Clear[a, y];
a=3.5;
y=0.4;
ListPlot[Table[y=a y (1-y),{50}],Joined->True]

I'd like to Manipulate a and y, but when I try to

Clear[a, y];
Manipulate[
ListPlot[Table[y=a y (1-y),{50}],Joined->True], {{a, 3.5}, 0, 4},
{{y, 0.4}, 0, 1}]

I get weird behavior:

1 initially the y slider oscillates

2 initially the plot displays but flashes (apparently between two
phases) until I click one of the sliders

3 the y slider will not move

4 the a slider can be dragged, but to no effect (i.e. the plot does
not change)

5 there are no error messages

What am I doing wrong? and how can I Manipulate this map?

TIA, Tom Roche <Tom_...@pobox.com>

Jens-Peer Kuska

unread,
Feb 25, 2009, 3:59:42 AM2/25/09
to
Hi,

you doing almost everything wrong. You mean

Manipulate[
ListPlot[ NestList[a # (1 - #) &, y, 50]], {{a, 3.5},


0, 4}, {{y, 0.4}, 0, 1}]

Atleast the assigment y=a y (1-y) in the ListPlot[] command
will change you y value on and on and so it is no wonder
that the slider is unmovable and moves unexpected.

Regards
Jens

Tom Roche

unread,
Feb 25, 2009, 4:00:04 AM2/25/09
to
Tom Roche Feb 24, 5:45 am

>> summary: I'm trying to Manipulate the logistic map. I can ListPlot
>> it, but when I try to Manipulate, the UI behaves weirdly.

Daniel H Tue, Feb 24, 2009 at 6:58 AM
> you can not use y for two things, table-generator and
> Manupulate-variable. Here is the corrected version:

> Manipulate[
> ListPlot[(y = y0; Table[y = a y (1 - y), {50}]),
> Joined -> True], {{a, 3.5}, 0, 4}, {{y0, 0.4}, 0, 1}]

Thanks! that works.

Pillsy

unread,
Feb 25, 2009, 4:02:56 AM2/25/09
to
On Feb 24, 5:45 am, Tom Roche <tlro...@gmail.com> wrote:
[...]

> Clear[a, y];
> a=3.5;
> y=0.4;
> ListPlot[Table[y=a y (1-y),{50}],Joined->True]
[...]

Clear[a, y];
Manipulate[
ListPlot[Table[y=a y (1-y),{50}],Joined->True], {{a, 3.5}, 0, 4},
{{y, 0.4}, 0, 1}]
> What am I doing wrong? and how can I Manipulate this map?

What you're doing wrong is changing the values of the variable y while you
compute the successive values of your logistic map. Manipulate wants to reflect
the current value of y in its position along the control slider, and y
bounces back and forth. Now, there are quite a few ways to get around this, but
instead of a workaround, I think you're better off using the kernel function that's intended to be used with iterated maps like this one: NestList.

Rest@NestList[a*#*(1-#)&, y, 50]

will produce the same list of values as your Table expression, but y will not have its value modified. NestList will put the initial value (with 0 function applications) as the first element in the returned list, and Rest will get rid of it.

If you stick that in your Mainpulate, it should just work.

Cheers,
Pillsy

congruenti...@yahoo.com

unread,
Feb 25, 2009, 4:04:01 AM2/25/09
to
There seem to be several...maybe you could start from one of these:
http://demonstrations.wolfram.com/search.html?query=logistic

HTH.

Roger Williams
Franklin Laboratory

On Feb 24, 2:45 am, Tom Roche <tlro...@gmail.com> wrote:
> summary: I'm trying to Manipulate the logistic map. I can ListPlot it,
> but when I try to Manipulate, the UI behaves weirdly.
>
> details:
>
> As advertised by the Subject:, I'm new to Mathematica (specifically
> 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any
> lapses in terminology. I'd also appreciate pointers to specific docs
> rather than just an RTFM.
>
> I'm trying to model the logistic map y=a y (1-y):
>

> http://en.wikipedia.org/wiki/Logistic_maphttp://mathworld.wolfram.com/Log=
isticMap.htmlhttp://www.phy.duke.edu/~palmer/notebooks/LogisticMap.nb


>
> To start with I just tried to plot it, which works:
>
> Clear[a, y];
> a=3.5;
> y=0.4;
> ListPlot[Table[y=a y (1-y),{50}],Joined->True]
>
> I'd like to Manipulate a and y, but when I try to
>
> Clear[a, y];
> Manipulate[

> ListPlot[Table[y=a y (1-y),{50}],Joined->True], {{a, 3.5}, 0, 4}=


,
> {{y, 0.4}, 0, 1}]
>
> I get weird behavior:
>
> 1 initially the y slider oscillates
>
> 2 initially the plot displays but flashes (apparently between two
> phases) until I click one of the sliders
>
> 3 the y slider will not move
>
> 4 the a slider can be dragged, but to no effect (i.e. the plot does
> not change)
>
> 5 there are no error messages
>
> What am I doing wrong? and how can I Manipulate this map?
>

> TIA, Tom Roche <Tom_Ro...@pobox.com>


Sjoerd C. de Vries

unread,
Feb 25, 2009, 4:05:17 AM2/25/09
to
The problem is that each change in y (being one of the tracked
variables) is a trigger for another round of calculations, which again
changes y and triggers again, ad infinitum.

One solution would be the use of RecurrenceTable instead of Table
which enables you to use y as the initial condition only and to
specify the map using a different variable. Now y itself is not
changed due to the calculation and no additional trigger occurs:

Clear[a, y];
Manipulate[
ListPlot[RecurrenceTable[{yy[n + 1] == a yy[n] (1 - yy[n]),
yy[0] == y}, yy, {n, 50}], Joined -> True], {{a, 3.5}, 0,


4}, {{y, 0.4}, 0, 1}]

Cheers -- Sjoerd

On Feb 24, 12:45 pm, Tom Roche <tlro...@gmail.com> wrote:
> summary: I'm trying to Manipulate the logistic map. I can ListPlot it,
> but when I try to Manipulate, the UI behaves weirdly.
>
> details:
>
> As advertised by the Subject:, I'm new to Mathematica (specifically
> 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any
> lapses in terminology. I'd also appreciate pointers to specific docs
> rather than just an RTFM.
>
> I'm trying to model the logistic map y=a y (1-y):
>

> http://en.wikipedia.org/wiki/Logistic_maphttp://mathworld.wolfram.com/Log=
isticMap.htmlhttp://www.phy.duke.edu/~palmer/notebooks/LogisticMap.nb


>
> To start with I just tried to plot it, which works:
>
> Clear[a, y];
> a=3.5;
> y=0.4;
> ListPlot[Table[y=a y (1-y),{50}],Joined->True]
>
> I'd like to Manipulate a and y, but when I try to
>
> Clear[a, y];
> Manipulate[

> ListPlot[Table[y=a y (1-y),{50}],Joined->True], {{a, 3.5}, 0, 4}=


,
> {{y, 0.4}, 0, 1}]
>
> I get weird behavior:
>
> 1 initially the y slider oscillates
>
> 2 initially the plot displays but flashes (apparently between two
> phases) until I click one of the sliders
>
> 3 the y slider will not move
>
> 4 the a slider can be dragged, but to no effect (i.e. the plot does
> not change)
>
> 5 there are no error messages
>
> What am I doing wrong? and how can I Manipulate this map?
>

> TIA, Tom Roche <Tom_Ro...@pobox.com>


Albert Retey

unread,
Feb 25, 2009, 4:06:42 AM2/25/09
to

all these come from the fact that you are asigning to y which is one of
the variables that you want to manipulate, which is almost never a good
idea...

> 5 there are no error messages


> What am I doing wrong? and how can I Manipulate this map?

I think this does what you want:

Clear[a, y];
Manipulate[
ListPlot[

Block[{x = y},
Table[x = a x (1 - x), {50}]
],
Joined -> True, PlotRange -> {0, 1}


],
{{a, 3.5}, 0, 4},
{{y, 0.4}, 0, 1}
]

hth,

albert

dh

unread,
Feb 25, 2009, 4:07:39 AM2/25/09
to

Hi Tom,

you can not use y for two things, table-generator and

Manupulate-variable. Here is the corrected version:

Manipulate[

ListPlot[(y = y0; Table[y = a y (1 - y), {50}]),

Joined -> True], {{a, 3.5}, 0, 4}, {{y0, 0.4}, 0, 1}]

Daniel

0 new messages