({{, (RefLink[MaxIterations, paclet:ref/MaxIterations]) 
is an option that specifies the maximum number of iterations that should be tried in various built-in functions and algorithms.}})

OpenersNotesSection(Spacer1)Details

(RefLink[MaxIterations, paclet:ref/MaxIterations])->(RefLink[Infinity, paclet:ref/Infinity]) specifies that there should be no limit.

OpenersPrimaryExamplesSection(Spacer1)Examples  (5)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

ReplaceRepeated[x,x->x+1,MaxIterations->10]

Limit the number of iterations attempted in numerical minimization:

FindMinimum[x^3,x,MaxIterations->10]

OpenersExampleSection1(Spacer1)Scope  (2)

(RefLink[MaxIterations, paclet:ref/MaxIterations]) can be infinite:

TimeConstrained[ReplaceRepeated[x,x->x+1,MaxIterations->Infinity],1]

Limit or increase the number of steps taken with (RefLink[MaxIterations, paclet:ref/MaxIterations]):

FindRoot[Exp[1/(x^2-1)]-10^-8,{x,.1},MaxIterations->10]

The default number of iterations for (RefLink[FindRoot, paclet:ref/FindRoot]) is 100:

FindRoot[Exp[1/(x^2-1)],{x,.1}]

Eventually the algorithm stalls out since this mollifier function has all derivatives 0 at x=1:

FindRoot[Exp[1/(x^2-1)],{x,.1},MaxIterations->1000]

OpenersExampleSection3(Spacer1)Applications  (1)

Use a limited number of iterations to select candidates for a global minimum:

f[x_,y_] = Exp[Sin[50x]]+Sin[60Exp[y]]+Sin[70Sin[x]]+Sin[Sin[80y]]-Sin[10(x+y)]+(1/4)((x^2)+(y^2));

{b,bxy}= Quiet[First[Sort[MapThread[FindMinimum[f[x,y],{{x,#1},{y,#2}},MaxIterations->10]&,RandomReal[{-1,1},{2,250}]]]]]

Find the minimum to 10 digits using arbitrary-precision arithmetic:

FindMinimum[f[x,y],{{x,x /.bxy},{y,y /. bxy}}, WorkingPrecision->20]

This can be done automatically with (RefLink[NMinimize, paclet:ref/NMinimize]):

NMinimize[f[x,y],{x,y},Method->{"RandomSearch","SearchPoints"->250},WorkingPrecision->20]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ReplaceRepeated, paclet:ref/ReplaceRepeated])  ▪  (RefLink[FindFit, paclet:ref/FindFit])  ▪  (RefLink[FindMaximum, paclet:ref/FindMaximum])  ▪  (RefLink[FindMinimum, paclet:ref/FindMinimum])  ▪  (RefLink[FindRoot, paclet:ref/FindRoot])  ▪  (RefLink[NMaximize, paclet:ref/NMaximize])  ▪  (RefLink[NMinimize, paclet:ref/NMinimize])  ▪  (RefLink[MaxSteps, paclet:ref/MaxSteps])}})}})