Mathematica > Core Language > Tuning & Debugging >

StepMonitor

StepMonitor
is an option for iterative numerical computation functions that gives an expression to evaluate whenever a step is taken by the numerical method used.
  • The option setting is normally given as StepMonitor:>expr.
  • The :> is used instead of -> to avoid expr being immediately evaluated.
  • Whenever expr is evaluated, all variables in the numerical computation are assigned their current values.
  • Block[{var1=val1, ...}, expr] is effectively used.
Monitor steps taken for a numerical minimization with FindMinimum:
 
Count steps:
In[1]:=
Click for copyable input
Out[1]=
 
Use Reap and Sow to collect step data:
In[1]:=
Click for copyable input
Out[1]=
Show steps on a plot of the function:
In[2]:=
Click for copyable input
Out[2]=
New in 5
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team