# Can you use “MaxErrorIncreases” when numerically integrating over a region?

How do you pass the option "MaxErrorIncreases" to NIntegrate[] when integrating over a region?

Taking a simple ;) example from Problems with NIntegrate, errors NIntegrate::slwcon and NIntegrate::inumri:

Ω = ImplicitRegion[
0 <= x <= 34 && -18 <= y <= 0 && ! ((12 < x < 15 && -12 < y) ||
(15 < x < 20 && -3 < y) || (20 < x < 23 && -7 < y) ||
(23 < x <= 34 && -3 < y)), {x, y}];
fi = NDSolve[{
Derivative[0, 2][φ][x, y] + Derivative[2, 0][φ][x, y] == NeumannValue[0,
x == 0 && -18 < y < 0 || 0 < x < 34 && y == -18 ||
x == 34 && -18 < y < -3 || x == 23 && -7 < y < -3 ||
20 < x < 23 && y == -7 || x == 20 && -7 < y < -3 ||
15 < x < 20 && y == -3 || x == 15 && -12 < y < -3 ||
12 < x < 15 && y == -12 || x == 12 && -12 < y < 0],
DirichletCondition[φ[x, y] == 1.5, 0 <= x <= 12 && y == 0],
DirichletCondition[φ[x, y] == 0.4, 23 <= x <= 34 && y == -3]},
φ, {x, y} ∈ Ω,
"ExtrapolationHandler" -> {0 &, "WarningMessage" -> False}];


Then on this integral we get a warning that suggests raising "MaxErrorIncreases":

ClearAll[ff];
dxφ = Derivative[1, 0][φ] /. First[fi];
ff[x_?NumericQ, y_?NumericQ] := Quiet@Check[dxφ[x, y], 0.];
NIntegrate[ff[x, y], {x, y} ∈ Ω]


NIntegrate::eincr: The global error of the strategy GlobalAdaptive has increased more than 2000 times....Increasing the value of the GlobalAdaptive option MaxErrorIncreases might lead to a convergent numerical integration....

However, using the usual Method setting results in an error:

NIntegrate[ff[x, y], {x, y} ∈ Ω, Method -> {"GlobalAdaptive", "MaxErrorIncreases" -> 5000}]


NIntegrate::regm: Method GlobalAdaptive is not applicable for a region domain. Continuing with method Automatic.

Is it possible to use "MaxErrorIncreases" with NIntegrate[] over a region?

• There is a method called "FiniteElement" that works for regions. It is not the same as the automatic method chosen in this case. (It gives a slightly different result and takes two to three times longer.) – Michael E2 Jan 7 '17 at 15:00
• Oddly enough, trying NIntegrate[ff[x, y], {x, y} ∈ Ω, Method -> {Automatic, "MaxErrorIncreases" -> 10000}] throws an error saying only the sub-option "SymbolicProcessing" is supported. Hmm... – J. M. is in limbo Jan 7 '17 at 15:02
• @J.M.willbebacksoon It is a feature. :) – Anton Antonov Nov 18 '19 at 12:26

I found the strategy, "SymbolicDomainDecomposition":

NIntegrate[ff[x, y], {x, y} ∈ Ω,
Method -> {"SymbolicDomainDecomposition",
Method -> {"GlobalAdaptive", "MaxErrorIncreases" -> 5000}}]


NIntegrate::eincr: The global error of the strategy GlobalAdaptive has increased more than 5000 times....

(*  -6.0019  *)


It turns out not to be good way to integrate this function. Even with a setting of "MaxErrorIncreases" -> 100000, the result still has a large error. There are better methods for the example integral in the OP, which may be found in the linked question.