MathGroup Archive 2000

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

Search the Archive

Re: Q: PlotPoints has dramatic timing effect (and not trivialy)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23239] Re: Q: PlotPoints has dramatic timing effect (and not trivialy)
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sat, 29 Apr 2000 22:04:47 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <8e0n9k$f4g@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

you draw the sphere twice with  t in [0,2Pi] and u in [0,2Pi]
t must run between [0, Pi]. 

Thats all -- for an even number of plot points the polygons
for the polygons for t+dt and t+Pi+dt are identical. Since Mathematica
uses a painter algorthim to draw the polygons, it must split
the two identical polygons for t and t+Pi, the splitting procedure
typical slow down a painter algorithm form n*Log[n] to n^2 for
n polygons. 

For an odd number of plot points the polygons are not exactly
the same and a smaller number of splits is needed to order the
polygons.

Hope that helps
  Jens

Gozo Zaar wrote:
> 
> Hello all,
> 
> Look at this: (I've edited it some for readability)
> This is just a parametric plot of a sphere:
> 
> In[2]:=
> $Version
> Out[2]=
> "Microsoft Windows 3.0 (October 6, 1996)"
> 
> In[3]:=Timing[ParametricPlot3D[{Cos[u]Sin[t],Sin[u]Sin[t],Cos[t]},
>         ,PlotPoints->16]]
> 
> Out[3]={15.1 Second,Graphics3D}
> 
> In[4]:=Timing[ParametricPlot3D[{Cos[u]Sin[t],Sin[u]Sin[t],Cos[t]},
>         {t,0,2\[Pi]},{u,0,2\[Pi]},PlotPoints->17]]
> 
> Out[4]={2.08 Second,Graphics3D}
> 
> In[5]:=Timing[ParametricPlot3D[{Cos[u]Sin[t],Sin[u]Sin[t],Cos[t]},
>          {t,0,2\[Pi]},{u,0,2\[Pi]},PlotPoints->18]]
> 
> Out[5]={22.41 Second,Graphics3D}
> 
> As you can see, the number of PlotPoints has dramatic effect on timing.
> There seems to be some optimal number (17 in this case) which is much more
> efficient (than 16 or 18). Moreover, this behavior is even more dramatic at
> larger numbers:
> 
> In[4]:=Timing[ParametricPlot3D[{Cos[u]Sin[t],Sin[u]Sin[t],Cos[t]},
>         {t,0,2\[Pi]},{u,0,2\[Pi]},PlotPoints->33]]
> 
> Out[4]={5.82 Second,Graphics3D}
> 
> In[5]:=Timing[ParametricPlot3D[{Cos[u]Sin[t],Sin[u]Sin[t],Cos[t]},
>         {t,0,2\[Pi]},{u,0,2\[Pi]},PlotPoints->32]]
> 
> Out[5]={173.4 Second,Graphics3D}
> 
> Now clearly I don't really care if I have 33 or 32 PlotPoints in my plot
> (they really look very much the same. In this case anyway). But I do care
> for my plot to take 6 seconds rather then 173 (Note: 33 Points is better
> even than 16 !!!). So here are my questions:
> 
> 1. Why is this happening? (Sure it has to do with internal implementation
> but how and why so strongly)
> 2. Can we make good use out of it and know in advance which PlotPoints are
> good for us? (In other words; what is magical about 17 and 33 in this case
> and what will happens on different cases)
> 
> Knowing the answer to 2 is much desired for the general complicated case.
> 
> Anyway, when dealing with {t,0,2\[Pi]},{u,0,2\[Pi]}, I will, from now on,
> use either 17 or 33....
> 
> Thank you all for your attention,


  • Prev by Date: Re: Re: how to rank a list of elements?
  • Next by Date: Re: Re: Demonstrate that 1==-1
  • Previous by thread: more on vector unions
  • Next by thread: Interpolation bugs (feature?) - work arounds & efficiency for large n?