When I evaluate
NIntegrate[a(x - y)^2, {x, 0, 1}, {y, 0, 1}, AccuracyGoal -> 8]
Mathematica returns 0
without giving a non-numerical value error, despite that fact that there is an undefined a
in the integrand. If I get rid of the AccuracyGoal specification then the expected error is raised. It is also raised if I multiply a
by pretty much any function other than (x-y)^2
.
I'm wondering why, in the particular instance describe above, NIntegrate does not warn me that I'm using incorrect syntax.
EDIT: Using evaluation monitor
Reap[NIntegrate[a (x - y)^2, {x, -1, 1}, {y, -1, 1}, AccuracyGoal -> 8, EvaluationMonitor :> Sow[{x, y}]]]
results in
{0., {{{0., 0.}, {0.948683, 0.948683}, {-0.948683, -0.948683}, {-0.688247, -0.688247}, {0.688247, 0.688247}}}}
.
This explains why no error was given: NIntegrate evaluates the integrand only at points where it evaluates to the nonsymbolic value zero. I suppose my remaining question is why NIntegrate only evaluated the integrand at those points? If I do the same with an explicit value for a
(say 1
) I find
Reap[NIntegrate[1 (x - y)^2, {x, -1, 1}, {y, -1, 1}, AccuracyGoal -> 8, EvaluationMonitor :> Sow[{x, y}]]]
{2.66667, {{{0., 0.}, {0.358569, 0.}, {-0.358569, 0.}, {0.948683, 0.}, {-0.948683, 0.}, {0., 0.358569}, {0., -0.358569}, {0., 0.948683}, {0., -0.948683}, {0.948683, 0.948683}, {0.948683, -0.948683}, {-0.948683, -0.948683},{-0.948683, 0.948683}, {-0.688247, -0.688247}, {-0.688247,0.688247}, {0.688247, -0.688247}, {0.688247, 0.688247}}}}
in disagreement with the case where a
is symbolic.
AccuracyGoal
is less then infinite. $\endgroup$NIntegrate
's advanced documentation. See, for example, "Examples of Pathological Behavior". $\endgroup$ag = -Log10[$MinMachineNumber/2^52] + Log10[2]
, a double-precision floating-point limit. $\endgroup$NIntegrate
treats nonnumeric results as singularities and they are discarded. If there are numeric function values, it assumes that the singularities will be handled in the course of refinement. In this case because of the symmetry, the error estimate is0.
and the integration stops. Tryii[x_?NumericQ, y_?NumericQ] := (Sow[{x, y}, "xy"]; a (x - y)^2); NIntegrate[ii[x, y], {x, 0, 1}, {y, 0, 1}, AccuracyGoal -> 8] // Reap
to see the integrand is actually evaluated throughout the domain. $\endgroup$0.
andAccuracy[0.]
is almost324
. IgnoringPrecisionGoal
for now, if you setAccuracyGoal
higher thanAccuracy[error]
,NIntegrate
will subdivide the region with the largest error (which at the first step is the whole domain). As subdivision goes on, not all of the new regions will be symmetric with respect to the integrand and two things can happen: The error is no longer zero on a subregion, or the integrand is nonnumeric on the entire subregion. In the first case you get more subdivision. In the second, you get an error. $\endgroup$