Use a ProgressIndicator to check an integration?

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

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…

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.

pew, many Thanks of course!

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

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

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.

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

unless MaxRecursion ->0, no

no, parallelisation might help though.