Message Boards Message Boards

Use a ProgressIndicator to check an integration?

Posted 8 years ago

Hello everbody,

I want to calculate sth. for my thesis, but it takes very long. In order to enhance my productivity I want to know about the progress. Fortunatly there is sth called ProgressIndicator but it doesn`t work correctly. It reloads very often so I dont get any information about the progress itself.

Plot[20/Pi*
  Integrate[((x + Sin[20 x])^2 + Cos[5 x])*Sin[20 x], {x, z - Pi/20, 
    z + Pi/20}], {z, 0, 20}]

ProgressIndicator[Dynamic[z], {0, 20}]

Hope you can help me with that.

regards, Jon

POSTED BY: Jon Ha
8 Replies
Posted 8 years ago

Is there a possibility to get Mathematica faster. Like a special setting in preferences?

POSTED BY: Jon Ha

no, parallelisation might help though.

POSTED BY: Sander Huisman
Posted 8 years ago

like MaxRecursion and Plotpoints - is there a possibility to get to know how far mathematica is with the calculation actually:

z =. x =. core = Pi/5* Integrate[(Abs[(Sin[5 x] + x)^2 - 15 (Sin[5 x] + x)] - 5 (Sin[5 x] + x) + 140) (Sin[5 x]), {x, z - Pi/5, z + Pi/5}] Plot[core, {z, 0, 20}, PlotPoints -> 400]

it takes again many time - and I want to know how long it will take.

POSTED BY: Jon Ha

unless MaxRecursion ->0, no

POSTED BY: Sander Huisman
Posted 8 years ago

pew, many Thanks of course!

really different, then I expected - now I need to get used to the new functions.

POSTED BY: Jon Ha

Which new function? Plot,ListPlot,Integrate,PlotPoints have been around since v1.0 I think!

POSTED BY: Sander Huisman

In hindsight, your Integral can be evaluated analytically:

z=.
x=.
core=20/Pi*Integrate[((x+Sin[20 x])^2+Cos[5 x])*Sin[20 x],{x,z-Pi/20,z+Pi/20}]
Plot[core,{z,0,20},PlotPoints->400]

So the majority of time is used to calculate the integral, but once done, the plotting is nearly instant.

POSTED BY: Sander Huisman

That is because Plot first calculate PlotPoints number of points, and then refines the plot in between at most MaxRecursion times. This makes it jump 'back and forth'. It can be solved like this:

Plot[20/Pi*Integrate[((x+Sin[20 x])^2+Cos[5 x])*Sin[20 x],{x,z-Pi/20,z+Pi/20}],{z,0,20},MaxRecursion->0,PlotPoints->20]

But you lose the adaptive refining used by plot.

Another possibility is something like:

\[Beta] = {};

Dynamic[ListPlot[{#, 1} & /@ \[Beta], PlotRange -> {{0, 20}, {0, 2}}]]

Plot[(\[Beta] = DeleteDuplicates[Append[\[Beta], z]]; 
  20/Pi*Integrate[((x + Sin[20 x])^2 + Cos[5 x])*Sin[20 x], {x, 
     z - Pi/20, z + Pi/20}]), {z, 0, 20}, MaxRecursion -> 1, 
 PlotPoints -> 30]

So you can see what points it is sampling...

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

Group Abstract Group Abstract