is an option for various functions that specifies the maximum time to spend doing a particular operation.
TimeConstraint
is an option for various functions that specifies the maximum time to spend doing a particular operation.
Details
- TimeConstraint->t specifies that a maximum of t seconds of CPU time should be spent doing a particular operation, or trying a particular transformation or part of an algorithm.
- TimeConstraint->Infinity specifies that there should be no limit on the CPU time allowed.
- In functions such as Simplify and FullSimplify, settings for TimeConstraint give only the maximum time to be spent doing a particular transformation on a particular subpart; the total time spent processing the whole expression may be considerably larger.
- Changing the setting for TimeConstraint will never affect the validity of a result obtained from functions like Simplify or FullSimplify, but smaller settings may prevent the simplest possible form from being found.
- Since different computer systems run at different speeds, the same setting for TimeConstraint can lead to different results on different systems.
Examples
open all close allBasic Examples (2)
This takes a long time, due to trigonometric expansion, but does not yield a simplification:
Simplify[2Sin[10x + 11y + 12z]Cos[10x + 10y + 10t]]//TimingTimeConstraint limits the time spent on any single transformation:
Simplify[2Sin[10x + 11y + 12z]Cos[10x + 10y + 10t], TimeConstraint -> 1]//TimingA similar example, where the transformation yields a simplification:
Simplify[2Sin[10x + 11y + 12z]Cos[10x + 10y + 10z]]//TimingIn this case, setting TimeConstraint prevents some simplification:
Simplify[2Sin[10x + 11y + 12z]Cos[10x + 10y + 10z], TimeConstraint -> 1]//TimingScope (2)
Checking whether a condition follows from assumptions may take a long time:
Refine[Sqrt[(x ^ 6 + y ^ 6 + z ^ 6 - x y z) ^ 2], (x - 1) ^ 2 + (y - 1) ^ 2 + (z - 1) ^ 2 ≤ 1 / 4]//TimingIf a condition does not follow from assumptions, checking this may still take a long time:
Refine[Sqrt[(x ^ 6 + y ^ 6 + z ^ 6 - x y z) ^ 2], (x - 1) ^ 2 + (y - 1) ^ 2 + (z - 1) ^ 2 ≤ 1 / 2]//TimingThe time spent on a single condition check is restricted by the value of TimeConstraint:
ClearSystemCache[]Refine[Sqrt[(x ^ 6 + y ^ 6 + z ^ 6 - x y z) ^ 2], (x - 1) ^ 2 + (y - 1) ^ 2 + (z - 1) ^ 2 ≤ 1 / 2, TimeConstraint -> 1]//TimingWith a time constraint of one second, Refine cannot prove that
:
Refine[Sqrt[(x ^ 6 + y ^ 6 + z ^ 6 - x y z) ^ 2], (x - 1) ^ 2 + (y - 1) ^ 2 + (z - 1) ^ 2 ≤ 1 / 4, TimeConstraint -> 1]//TimingRun a remote batch job with a given maximum runtime:
RemoteBatchSubmit[FactorInteger[2 ^ 1023 - 7], TimeConstraint -> Quantity[10, "Hours"]]Tech Notes
Related Links
History
Introduced in 1996 (3.0)
Text
Wolfram Research (1996), TimeConstraint, Wolfram Language function, https://reference.wolfram.com/language/ref/TimeConstraint.html.
CMS
Wolfram Language. 1996. "TimeConstraint." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TimeConstraint.html.
APA
Wolfram Language. (1996). TimeConstraint. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TimeConstraint.html
BibTeX
@misc{reference.wolfram_2026_timeconstraint, author="Wolfram Research", title="{TimeConstraint}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/TimeConstraint.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_timeconstraint, organization={Wolfram Research}, title={TimeConstraint}, year={1996}, url={https://reference.wolfram.com/language/ref/TimeConstraint.html}, note=[Accessed: 12-June-2026]}