ga35bet
(Jon Ha)
October 13, 2016, 2:47pm
1
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
sghuisman
(Sander Huisman)
October 13, 2016, 3:58pm
2
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…
sghuisman
(Sander Huisman)
October 13, 2016, 4:01pm
3
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.
ga35bet
(Jon Ha)
October 14, 2016, 5:00pm
4
pew, many Thanks of course!
really different, then I expected - now I need to get used to the new functions.
sghuisman
(Sander Huisman)
October 14, 2016, 5:02pm
5
Which new function? Plot,ListPlot,Integrate,PlotPoints have been around since v1.0 I think!
ga35bet
(Jon Ha)
October 14, 2016, 5:23pm
6
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.
ga35bet
(Jon Ha)
October 14, 2016, 5:56pm
7
Is there a possibility to get Mathematica faster. Like a special setting in preferences?
sghuisman
(Sander Huisman)
October 14, 2016, 10:08pm
8
unless MaxRecursion ->0, no
sghuisman
(Sander Huisman)
October 14, 2016, 10:08pm
9
no, parallelisation might help though.