Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm trying to plot this:

i = 0.01;

ListLinePlot[Table[Cos[x]^p, {x, 0, π/2, i}, {p, 0, 1, i}], 
             ImageSize -> 400, PlotRange -> {{0, 100}, {0, 1}}]


ListLinePlot[Table[Cos[p x], {x, 0, π/2, i}, {p, 0, 1, i}], 
             ImageSize -> 400,   PlotRange -> {{0, 100}, {0, 1}}]

When i = 0.001, it takes a lot of time to render and my computer become unusable. Is there something I can do for rendering it faster or at least making the process slower so I can use my computer normally?

I have a Nvidia GTX460 video board and I know about the CUDA link, but if it's not asking too much, I'd like to get advice from someone who has more experience than me at such matters.

share|improve this question
    
With i=.001 it takes about one minute on my Mac, no freeze or slowdown. What are you times? –  A.G. Dec 31 '13 at 5:40
3  
` i = 0.001;ListLinePlot[Table[Cos[x]^p, {x, 0, \[Pi]/2, i}, {p, 0, 1, i}], ImageSize -> 400, PlotRange -> {{0, 100}, {0, 1}}, MaxPlotPoints -> 100] :D –  belisarius Dec 31 '13 at 6:00
3  
Replacing Table by ToPackedArray@Table more than doubles the speed. (using Needs["Developer"]`) –  A.G. Dec 31 '13 at 6:13
1  
btw. I think an answer explaining this would be useful. I've heard several people complain that MMA renders their computers unusable when it's computing, but this has never happened to me. But I have never seen an answer that talks about why this happen: Is it the OS that doesn't reserve enough of something? (I use OS X), is it the memory that runs out? The processor only has one kernel? MMA on some OSs uses several processor kernels automatically? It would be useful to be able to explain this to people, not only suggest a workaround. –  Pickett Dec 31 '13 at 12:03
1  
@Anon The point about a time consuming f was to point out that during the map thread operation, the peak memory usage might be high enough that if f is slow, you're not going to free up that resource until the computation is finished (or you get a chance to repack it). Also see Are there guidelines for avoiding the unpacking of a packed array? –  rm -rf Dec 31 '13 at 18:27

1 Answer 1

Not sure if this is avoiding the basic question, but for small i you are plottting an excessive number of p points, this is a good bit faster (for small i)

i = .001
Show[MapIndexed[
        ParametricPlot[{p/i, Cos[#]^p} , {p, 0, 1}, 
        AspectRatio -> 1/GoldenRatio, 
        PlotStyle -> ColorData["Rainbow", (First@#2)/(Pi/2/i)]] &, 
        Table[x, {x, 0, Pi/2, i}]], PlotRange -> {0, 1}] 

(note this construct proves to be a bit faster than ParametricPlot[Table[ , {x,..} ] , {p,0,1}] )

It looks nicer to specify the colors as well.. useColorData[1, .. ] to reproduce the default scheme.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.