[Date Index]
[Thread Index]
[Author Index]
Monitoring/collecting evaluations
*To*: mathgroup at smc.vnet.net
*Subject*: [mg91609] Monitoring/collecting evaluations
*From*: vasil michev <michev at gmail.com>
*Date*: Fri, 29 Aug 2008 04:10:23 -0400 (EDT)
Is there a way (built-in function) to monitor the steps taken in
evaluation or collect sample points without doubling the evaluation
time? Tried using EvaluationMonitor with/without Sow/Reap and the
results are almost the same, and not using it takes twice less time.
here are some code samples:
(a fairly common function in physics, with few secs evaluation time)
f[m_]:=NIntegrate[UnitStep[3-m-Cos[x]-Cos[y]-Cos[z]],{x,-\[Pi],\[Pi]},
{y,-\[Pi],\[Pi]},{z,-\[Pi],\[Pi]},MaxPoints->1000000,Method-
>"LocalAdaptive"]/8/\[Pi]^3
(just the plot)
AbsoluteTiming[Plot[f[x],{x,0,1},PlotPoints->10,MaxRecursion->1]]
35.8700000
(simple monitoring)
AbsoluteTiming[values={};
Monitor[Plot[f[x],{x,0,1},PlotPoints->10,MaxRecursion-
>1,EvaluationMonitor:>AppendTo[values,{x,f[x]}]],ListPlot[values]]]
69.2440000 -> double time, as f[x] is evaluaed twice
(Sow/Reap)
AbsoluteTiming[evals={};
{plot,evals}=Reap[Plot[f[x],{x,0,1}, PlotRange->All,PlotPoints-
>10,MaxRecursion->1,EvaluationMonitor:>Sow[{x,f[x]}]]];Show[plot]]
69.5930000 -> same
(Monitoring with Sow/Reap)
AbsoluteTiming[evals={};
{plot,evals}=Reap[Monitor[Plot[f[x],{x,0,1}, PlotRange->All,PlotPoints-
>10,MaxRecursion-
>1,EvaluationMonitor:>AppendTo[evals,Sow[{x,f[x]}]]],ListPlot[evals]]];
Show[plot]]
69.8420000 -> same
So, does anyone know how to achieve that? Im usualy dealing with
ContourPlot3D's of similar integrals, each of which takes a minute to
evaluate, and I do it for a lot of points, there's quite a difference
between calculation running for a week or 2 weeks. I know it takes
just a few lines of code to do this, but im looking for something
applicable to a broader range of functions
Prev by Date:
**How to parse equations**
Next by Date:
**"matched" Set[]**
Previous by thread:
**Re: How to parse equations**
Next by thread:
**"matched" Set[]**
| |