({{, (RefLink[TimeConstraint, paclet:ref/TimeConstraint])
is an option for various functions that specifies the maximum time to spend doing a particular operation. }})

OpenersNotesSection(Spacer1)Details

(RefLink[TimeConstraint, paclet:ref/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.

(RefLink[TimeConstraint, paclet:ref/TimeConstraint])->(RefLink[Infinity, paclet:ref/Infinity]) specifies that there should be no limit on the CPU time allowed.

In functions such as (RefLink[Simplify, paclet:ref/Simplify]) and (RefLink[FullSimplify, paclet:ref/FullSimplify]), settings for (RefLink[TimeConstraint, paclet:ref/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 (RefLink[TimeConstraint, paclet:ref/TimeConstraint]) will never affect the validity of a result obtained from functions like (RefLink[Simplify, paclet:ref/Simplify]) or (RefLink[FullSimplify, paclet:ref/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 (RefLink[TimeConstraint, paclet:ref/TimeConstraint]) can lead to different results on different systems.

OpenersPrimaryExamplesSection(Spacer1)Examples  (3)

OpenersExampleSection0(Spacer1)Basic 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]]//Timing

(RefLink[TimeConstraint, paclet:ref/TimeConstraint]) limits the time spent on any single transformation:

Simplify[2Sin[10x+11y+12z]Cos[10x+10y+10t],TimeConstraint->1]//Timing

A similar example, where the transformation yields a simplification:

Simplify[2Sin[10x+11y+12z]Cos[10x+10y+10z]]//Timing

In this case, setting (RefLink[TimeConstraint, paclet:ref/TimeConstraint]) prevents some simplification:

Simplify[2Sin[10x+11y+12z]Cos[10x+10y+10z],TimeConstraint->1]//Timing

OpenersExampleSection1(Spacer1)Scope  (1)

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]//Timing

If 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]//Timing

The time spent on a single condition check is restricted by the value of (RefLink[TimeConstraint, paclet:ref/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]//Timing

With a time constraint of one second, (RefLink[Refine, paclet:ref/Refine]) cannot prove that (x^6)-x y z+(y^6)+(z^6)≥0:

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]//Timing

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[TimeConstrained, paclet:ref/TimeConstrained])  ▪  (RefLink[TimeGoal, paclet:ref/TimeGoal])  ▪  (RefLink[PerformanceGoal, paclet:ref/PerformanceGoal])  ▪  (RefLink[AbsoluteTiming, paclet:ref/AbsoluteTiming])  ▪  (RefLink[ComplexityFunction, paclet:ref/ComplexityFunction])  ▪  (RefLink[ExcludedForms, paclet:ref/ExcludedForms])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Simplification, paclet:tutorial/Simplification])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Systematic Testing & Verification, paclet:guide/SystematicTestingAndVerification])}, {▪(RefLinkPlain[Wolfram|Alpha Integration, paclet:guide/WolframAlphaIntegration])}, {▪(RefLinkPlain[HTTP Requests & Responses, paclet:guide/HTTPRequestsAndResponses])}, {▪(RefLinkPlain[Algebraic Transformations, paclet:guide/AlgebraicTransformations])}, {▪(RefLinkPlain[Global Computation Settings & Parameters, paclet:guide/GlobalComputationSettingsAndParameters])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-NKS.png(Spacer1)NKS|Online, http://www.wolframscience.com/nksonline/index/search.cgi?SearchIndex=TimeConstraint]) ((WebLink[A New Kind of Science, http://www.wolframscience.com/nksonline/]))}})}})