({{, (RefLink[MaxRecursion, paclet:ref/MaxRecursion])
is an option for functions like (RefLink[NIntegrate, paclet:ref/NIntegrate]) and (RefLink[Plot, paclet:ref/Plot]) that specifies how many recursive subdivisions can be made. }})

OpenersNotesSection(Spacer1)Details

(RefLink[MaxRecursion, paclet:ref/MaxRecursion])->n specifies that up to n levels of recursion should be done.

Recursive subdivision is done only in those places where more samples seem to be needed in order to achieve results with a certain level of quality.

In d dimensions, each recursive subdivision increases the number of samples taken by a factor that increases roughly exponentially with d.

(RefLink[MaxRecursion, paclet:ref/MaxRecursion])->(RefLink[Infinity, paclet:ref/Infinity]) specifies no limit on the number of recursive subdivisions.

In cases such as functions with discontinuities or with infinitely rapid oscillations there may be no convergence even after an infinite number of subdivisions.

OpenersPrimaryExamplesSection(Spacer1)Examples  (4)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Get a very high-quality plot of a sharp feature:

Plot3D[x y Exp[-10 (x^2+y^2-1)^2],{x,-2,2},{y,-2,2},PlotRange->All,Mesh->False,MaxRecursion->5]

Allow more adaptive recursion to resolve the integral of a rapidly varying function:

NIntegrate[Exp[-10^8 x^2],{x,-1,1},WorkingPrecision->20,MaxRecursion->20]

OpenersExampleSection1(Spacer1)Scope  (2)

Use (RefLink[MaxRecursion, paclet:ref/MaxRecursion]) to control adaptive subdivision:

Table[Plot[Sin[x^2],{x,0,10},PlotPoints->5,MaxRecursion->mr],{mr,{0,2,4,6}}]

Table[Plot3D[Sin[x y],{x,0,4},{y,0,4},PlotPoints->5,MaxRecursion->mr,Mesh->None],{mr,{0,1,2,4}}]

Use (RefLink[MaxRecursion, paclet:ref/MaxRecursion]) to improve results when singularities affect numerical integration:

NIntegrate[1/Sqrt[Sin[x]],{x,0,10},MaxRecursion->100]

With the default setting, the result is not as good:

NIntegrate[1/Sqrt[Sin[x]],{x,0,10}]

Specifying the singularity locations is even more efficient:

NIntegrate[1/Sqrt[Sin[x]],{x,0,π,2 π,3 π,10}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[$RecursionLimit, paclet:ref/$RecursionLimit])  ▪  (RefLink[EvaluationMonitor, paclet:ref/EvaluationMonitor])  ▪  (RefLink[Plot, paclet:ref/Plot])  ▪  (RefLink[NIntegrate, paclet:ref/NIntegrate])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Numerical Integration, paclet:tutorial/NumericalIntegration])}, {▪(RefLinkPlain[Options for Graphics, paclet:tutorial/Options])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Plotting Options, paclet:guide/PlottingOptions])}})}})