MathGroup Archive 2011

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

Search the Archive

Re: Very stange behaviour of Manipulate. Revaluating expression twice when once is expected.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118937] Re: Very stange behaviour of Manipulate. Revaluating expression twice when once is expected.
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Tue, 17 May 2011 07:45:21 -0400 (EDT)

It helps if you use RuleDelayed (:>) instead of Rule as documented  in the TrackedSymbols section of the documentation.

Cheers -- Sjoerd

Mathematica questions quickly answered on StackOverflow
http://stackoverflow.com/questions/tagged/mathematica


On Monday, May 16, 2011 9:35:09 AM UTC+2, Nasser M. Abbasi wrote:
> Version 8.0.01, on Windows.
> 
> May be an expert here can explain, in simple terms, why
> they think Manipulate acts this way, because I can't figure
> it out and it seems not logical to me.
> 
> I have Manipulate with one control variable.
> 
> When I change the control variable by using
> the little open windows and type something in there,
> and hit return, then Manipulate will reevaluate the
> expression ONCE, as is expected.
> 
> But when I do the same update, but now using the
> little '+' button in the open dialog (using Appearance->"Open")
> now Manipulate will evaluate the same expression TWICE !
> 
> In this example below, the expression just prints
> a random number. To allow one to more easily
> see the update happening twice, I put a PAUSE
> statement in the expression. But this can be removed
> if needed.
> 
> Here is the code:
> 
> -------------------------
> Manipulate[
> (
>    Pause[0.5];
> 
>    If[True,ListPlot[{0,1}]];
> 
>    Text[Random[]]
> ),
> 
> {{t,1,"t"},.1,2,.1,Appearance->"Open"},
> 
> TrackedSymbols->{t}
> ]
> -------------------------
> 
> If you run the above, you'll notice Manipulate updates
> expression 2 times if you use '+', but will update
> one time when you type new value for 't' in the little
> window and hit RETURN.
> 
> This behavior only shows up with I have that ListPlot[]
> command in there. If I remove the ListPlot[], then
> Manipulate no longer update the expression twice, but
> only once as expected.
> 
> I know the ListPlot[] there is doing nothing, but the above
> is just an example to illustrate the problem, from a larger
> code.
> 
> Any one knows, why Manipulate behaves different like this?
> 
> I always thought changing the control variable using '+' or '-'
> or by keyboard are equivalent things and Manipulate should
> behave the same exact way !
> 
> Thanks
> --Nasser



  • Prev by Date: Re: Get["file.mx"] doesn't work
  • Next by Date: Re: Maintaining the order of terms when adding symbolic expressions
  • Previous by thread: Very stange behaviour of Manipulate. Revaluating expression twice when once is expected.
  • Next by thread: Get["file.mx"] doesn't work