MathGroup Archive 2008

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

Search the Archive

Re: Dynamic Show in Manipulate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg94087] Re: Dynamic Show in Manipulate
  • From: Szabolcs Horvát <szhorvat at gmail.com>
  • Date: Thu, 4 Dec 2008 07:17:12 -0500 (EST)
  • Organization: University of Bergen
  • References: <gh5nps$oda$1@smc.vnet.net>

Michael Hsieh wrote:
> Hello!
> 
> I have a seemingly simple problem here, but somehow can't figure out a
> solution:
> 
> I compute a Plot of a Differential Equation, with variable x-ranges,
> and want to show the graphic with a VectorFieldPlot as background.
> 
> Unfortunately, within Manipulate, the static VectorFieldPlot and the
> whole Differential Equation are reevaluated anytime I move the slide bar.
> This makes the whole movie very very slow. Is there a way to
> "tell" Show that the VectorFieldPlot is just a background and doesn't need
> to be reevaluated every time? 

The VectorFieldPlot function is not re-evaluated.  It is 
showing/displaying the graphics that takes so long.  I, too, would 
really like to have a solution to this problem.

The strange thing is that once a Mathematica 6 (or 7) graphic has been shown in 
the Front End, resizing it is very fast.  So it is not exactly the 
rendering that takes so long.

It appears as if Mathematica were spending its time converting a 
symbolic Graphics[ ... ] expression to some renderable internal form. 
Once this conversion is done, rendering the graphics at a different size 
is very fast.  But I may be completely wrong with this hypothesis.

Still, the sad thing is that some graphics that would appear 
instantaneously in Mathematica <= 5.2 take a long time to display in 
Mathematica >= 6, even antialiasing turned off.

Here's an example:

First define

rotate90[{x_, y_}] := {-y, x}

koch[p1_, p2_, n_] := {koch[p1, p1 + (p2 - p1)/3, n - 1],
   koch[p1 + (p2 - p1)/3, (p1 + p2)/2 + Sqrt[3]/6 rotate90[p2 - p1],
    n - 1], koch[(p1 + p2)/2 + Sqrt[3]/6 rotate90[p2 - p1],
    p2 - (p2 - p1)/3, n - 1], koch[p2 - (p2 - p1)/3, p2, n - 1]}

koch[p1_, p2_, 0] := Line[{p1, p2}]

Now try

Style[Graphics[koch[{0, 0}, {1, 0}, 7]], Antialiasing -> False]

in versions with the new graphics system and

Graphics[koch[{0, 0}, {1, 0}, 7], AspectRatio -> Automatic] // Show

in an old version with the PostScript based graphics system.

Note that it is not generating the Graphics[] expression that takes so 
awfully long, so this cannot be benchmarked with either Timing or 
AbsoluteTiming.  It isn't rendering the graphic that's slow, either, 
because resizing it is quite fast.

With an old fashioned stopwatch timing method I get ~3 s in the old 
version and ~18 s in the new version.  That's a huge slowdown.

Is there an inherent limitation in the design of the new graphics system 
that makes it impossible to eliminate these delays?


  • Prev by Date: RE: Dynamic Show in Manipulate
  • Next by Date: Re: Strange behaviour of Fourier[] in Mathematica 7 (Follow up)
  • Previous by thread: RE: Dynamic Show in Manipulate
  • Next by thread: Re: Dynamic Show in Manipulate