7
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ 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.) $\endgroup$ – Michael E2 Jan 7 '17 at 15:00
  • $\begingroup$ 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... $\endgroup$ – J. M. will be back soon Jan 7 '17 at 15:02
6
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.