WOLFRAM

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)Summary of the most common use cases

Monitor steps taken for a numerical minimization with FindMinimum:

Out[1]=1

Count steps:

Out[1]=1

Use Reap and Sow to collect step data:

Out[1]=1

Show steps on a plot of the function:

Out[2]=2

Scope  (4)Survey of the scope of standard use cases

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

Out[1]=1

Monitor steps taken to numerically solve a system of equations:

Out[1]=1

Show steps on a surface plot of the functions:

Out[3]=3

Steps in parameter space for a nonlinear fit:

Out[3]=3

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

Out[4]=4

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

Out[2]=2

Show the steps with a surface plot of the solution:

Out[3]=3

Applications  (4)Sample problems that can be solved with this function

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

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

Out[3]=3

Investigate steps and evaluations for a numerical minimization:

Out[1]=1

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

Out[2]=2

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

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

Out[2]=2

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

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.

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

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

BibTeX

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

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

BibLaTeX

@online{reference.wolfram_2025_stepmonitor, organization={Wolfram Research}, title={StepMonitor}, year={2003}, url={https://reference.wolfram.com/language/ref/StepMonitor.html}, note=[Accessed: 11-March-2025 ]}

@online{reference.wolfram_2025_stepmonitor, organization={Wolfram Research}, title={StepMonitor}, year={2003}, url={https://reference.wolfram.com/language/ref/StepMonitor.html}, note=[Accessed: 11-March-2025 ]}