is an option to functions like NDSolve that specifies the maximum size of a single step used in generating a result.
MaxStepSize
is an option to functions like NDSolve that specifies the maximum size of a single step used in generating a result.
Details
- MaxStepSize->Infinity allows an unlimited step size.
Examples
open all close allBasic Examples (1)
Keep the largest step taken by NDSolve to be 0.01:
NDSolve[{x''[t] + x[t] == Exp[-1000(t - π) ^ 2], x[0] == x'[0] == 0}, x, {t, 0, 20}, MaxStepSize -> 0.01]Plot[Evaluate[First[x[t] /. %]], {t, 0, 20}]Applications (2)
The default step control may miss a suddenly varying feature:
Plot[Evaluate[(y[x] /. NDSolve[{y''[x] + (1 + Sech[1000 (x - Pi)]) y[x] == 0, y[0] == 1, y'[0] == 0}, y, {x, 0, 10}]) - Cos[x]], {x, 0, 10}]A smaller MaxStepSize setting ensures that NDSolve catches the feature:
Plot[Evaluate[(y[x] /. NDSolve[{y''[x] + (1 + Sech[1000 (x - Pi)]) y[x] == 0, y[0] == 1, y'[0] == 0}, y, {x, 0, 10}, MaxStepSize -> 0.01]) - Cos[x]], {x, 0, 10}]Attempting to compute the number of positive integers less than
misses several events:
Block[{n = 0}, NDSolve[{y'[t] == y[t], y[-1] == E^-1}, y, {t, 5}, Method -> {"EventLocator", "Event" -> Sin[π y[t]], "EventAction" :> n++}];n]Setting a small enough MaxStepSize ensures that none of the events are missed:
Block[{n = 0}, NDSolve[{y'[t] == y[t], y[-1] == E^-1}, y, {t, 5},
MaxStepSize -> 0.001, Method -> {"EventLocator", "Event" -> Sin[π y[t]], "EventAction" :> n++}];n]Properties & Relations (1)
For a length l, MaxStepFraction->f is equivalent to MaxStepSize->(f l):
msf = NDSolve[{y''[x] + (1 + Sech[1000 (x - Pi)]) y[x] == 0, y[0] == 1, y'[0] == 0}, y, {x, 0, 10}, MaxStepFraction -> 1 / 1000]mss = NDSolve[{y''[x] + (1 + Sech[1000 (x - Pi)]) y[x] == 0, y[0] == 1, y'[0] == 0}, y, {x, 0, 10}, MaxStepSize -> 10 1 / 1000]msf === mssSee Also
History
Introduced in 1996 (3.0)
Text
Wolfram Research (1996), MaxStepSize, Wolfram Language function, https://reference.wolfram.com/language/ref/MaxStepSize.html.
CMS
Wolfram Language. 1996. "MaxStepSize." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/MaxStepSize.html.
APA
Wolfram Language. (1996). MaxStepSize. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MaxStepSize.html
BibTeX
@misc{reference.wolfram_2026_maxstepsize, author="Wolfram Research", title="{MaxStepSize}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/MaxStepSize.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_maxstepsize, organization={Wolfram Research}, title={MaxStepSize}, year={1996}, url={https://reference.wolfram.com/language/ref/MaxStepSize.html}, note=[Accessed: 12-June-2026]}