Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: Slow plotting of reflected parametric "butterflies"

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124536] Re: Slow plotting of reflected parametric "butterflies"
  • From: Chris Young <cy56 at comcast.net>
  • Date: Mon, 23 Jan 2012 02:58:02 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jf8ql4$3pl$1@smc.vnet.net> <jfe3io$a0v$1@smc.vnet.net>

Thanks very much for the good advice. I've rewritten my functions to
avoid the problems.

On 2012-01-21 10:21:12 +0000, Bill Rowe said:

> A few comments:
>
> In most cases, Mathematica is able to get the result you want
> using C etc as localized variables. But, this is still bad
> coding in my opinion for several reasons.
>
> It makes your code harder to understand.
>
> Clearly, when you overload built-in parameters Mathematica must
> do more to select the correct form. That must have some
> performance impact.
>
> Finally, it makes your code more fragile. Any program with the
> complexity of Mathematica will always have some bugs or
> unintended side effects. These are far more likely to be a
> problem for code with potential conflicts such as using C for a
> local variable.
>
> Best practice is simply don not use a single uppercase letter as
> a variable. Then you are guaranteed no conflicts.
>
> As for your code, you are using FullSimplify every time in the
> function CurvedButterfly is called. FullSimply is generally an
> expensive function to use in terms of cpu time. But, it looks
> like you are supplying machine precision numbers for the values
> of A,B,C,D etc. If so, FullSimplify won't do anything. By
> default, Mathematica will evaluate your expression to a machine
> precision value whenever all values are numeric and at least one
> is machine precision. So, if I've understood your code, you will
> be feeding FullSimplify a machine number and there is nothing to simplify.
>
> Also, expr//Flatten[#,1]& does exactly the same thing as
> expr//Flatten using expr//Flatten will be faster. That is:
>
> In[7]:= d = RandomReal[1, {500, 500, 500}];
>
> In[8]:= Timing[d // Flatten[#, 1] &;]
>
> Out[8]= {0.640754,Null}
>
> In[9]:= Timing[d // Flatten;]
>
> Out[9]= {0.449603,Null}
>
> As a general rule of thumb, using simpler forms is faster.





  • Prev by Date: Re: DynamicModule to set locations of 3D points from 2D LocatorPane?
  • Next by Date: Re: Derivatives Output as TraditionalForm
  • Previous by thread: Re: Slow plotting of reflected parametric "butterflies"
  • Next by thread: Re: Slow plotting of reflected parametric "butterflies"