Group Abstract Group Abstract

Message Boards Message Boards

Suggestions for speeding up this plot?

Posted 10 years ago
POSTED BY: Bryan Lettner
7 Replies

You should consider the following: what takes longer - rendering the figure or computing the points? If computing the points is a significant time waste then consider separating it from plotting function and use Compile with options potential CompilationTarget -> "C" and Parallelization -> True. If this is for a poster, perhaps you do not want to render in front end and then export. Use Export right away and better to a vector format such as SVG or PDF. Not sure if all this is useful, just a train of thoughts.

POSTED BY: Vitaliy Kaurov

You also get it a bit faster by wrapping the inner bit into an Evaluate:

myHairyStarfish[a_, plotpts_, thickness_, imagesize_] := 
 ParametricPlot[
  Evaluate[{Sum[(2/3)^k Sin[(3/2)^k t], {k, 0, a}], 
    Sum[(-(2/3))^k Cos[(3/2)^k t], {k, 0, a}]}], {t, 0, 2^(a + 1) Pi},
   MaxRecursion -> 5, Axes -> False, PlotPoints -> plotpts, 
  PlotStyle -> {Thickness[thickness], Black}, 
  PlotRange -> {{-2.5, 2.5}, {-2.5, 2.5}}, 
  ImageSize -> {imagesize, Automatic}]

AbsoluteTiming[myHairyStarfish[11, 15000, 0.00004, 500]]

On my computer it goes from 5.75 secs to 2.94 secs.

Cheers,

Marco

POSTED BY: Marco Thiel

You may try ListPlot with ParallelTable, after you have estimated a reasonable increment for t that does not make you lose too much detail.

POSTED BY: Gianluca Gorni

Using compilation and machine real numbers may be tricky here. You are going to calculate Sin and Cos of numbers that are of the order of 10^12. Can you trust the results?

POSTED BY: Gianluca Gorni
Posted 10 years ago
POSTED BY: Bryan Lettner
Posted 10 years ago

No Errors. The code just displayed as text instead of code for some reason. Fixed.

POSTED BY: Bryan Lettner

Your function definition contains errors and, probably, it must be

HairyStarfish[a_, plotpts_, thickness_, imagesize_] := 
 ParametricPlot[{Sum[(2/3)^k Sin[(3/2)^k t], {k, 0, a}], 
   Sum[(-(2/3))^k Cos[(3/2)^k t], {k, 0, a}]}, {t, 0, 2^(a + 1) Pi}, 
  MaxRecursion -> 5, Axes -> False, PlotPoints -> plotpts, 
  PlotStyle -> {Thickness[thickness], Black}, 
  PlotRange -> {{-2.5, 2.5}, {-2.5, 2.5}}, 
  ImageSize -> {imagesize, Automatic}]

Am I right?

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard