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.

Details

• 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.

Examples

open allclose all

Basic Examples(3)

Monitor steps taken for a numerical minimization with FindMinimum:

Count steps:

Use Reap and Sow to collect step data:

Show steps on a plot of the function:

Scope(4)

Monitor the solution progress when solving the sine-Gordon PDE:

Monitor steps taken to numerically solve a system of equations:

Show steps on a surface plot of the functions:

Steps in parameter space for a nonlinear fit:

Sequence of plots showing the evolution of the model over the steps:

Plot the spatial (x) solution for time (t) steps used numerically solving a PDE with NDSolve:

Show the steps with a surface plot of the solution:

Applications(4)

Show how precision is adapted for high-precision root finding:

The quadratic convergence of Newton's method allows eventual precision doubling at each step:

Investigate steps and evaluations for a numerical minimization:

Show evaluations in red, steps in yellow, and the final point in green:

Get step sizes for the numerical solution of an ODE with NDSolve:

Show the solution and step size as a function of t:

Compare steps, evaluations, and timing for different ODE integration methods in NDSolve:

Wolfram Research (2003), StepMonitor, Wolfram Language function, https://reference.wolfram.com/language/ref/StepMonitor.html.

Text

Wolfram Research (2003), StepMonitor, Wolfram Language function, https://reference.wolfram.com/language/ref/StepMonitor.html.

CMS

Wolfram Language. 2003. "StepMonitor." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/StepMonitor.html.

APA

Wolfram Language. (2003). StepMonitor. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/StepMonitor.html

BibTeX

@misc{reference.wolfram_2022_stepmonitor, author="Wolfram Research", title="{StepMonitor}", year="2003", howpublished="\url{https://reference.wolfram.com/language/ref/StepMonitor.html}", note=[Accessed: 30-May-2023 ]}

BibLaTeX

@online{reference.wolfram_2022_stepmonitor, organization={Wolfram Research}, title={StepMonitor}, year={2003}, url={https://reference.wolfram.com/language/ref/StepMonitor.html}, note=[Accessed: 30-May-2023 ]}