FINAL EDIT: The "curious behavior" is, as explained by user21, due to the fact that ImplicitRegion
decides the RegionDimension
according to the form of the input. If you are interested in a workaround for the issue, see also the post of M. Stern. Mathematica support agrees that the questions surrounding this behavior have been answered by the contributors to this post. Thanks to all!
Can anyone explain the following curious behavior? I first integrate over a disk, and get the expected answer:
NIntegrate[1, {x, y} ∈ Disk[]]
3.14159
Now I construct a numerical region and recalculate:
Needs["NDSolve`FEM`"]
inDisk[x_?NumericQ, y_?NumericQ] := x^2 + y^2 <= 1
nrDisk =
ToNumericalRegion[ImplicitRegion[inDisk[x, y] == True, {{x, -1, 1}, {y, -1, 1}}]];
NIntegrate[1, {x, y} ∈ nrDisk]
6.28054
The answer is approximately twice what it should be. Any ideas?
Bonus points: If I define the disk another way, why does NIntegrate
just spit it back?
r2Disk[x_?NumericQ, y_?NumericQ] := x^2 + y^2
nrDisk =
ToNumericalRegion[ImplicitRegion[r2Disk[x, y] <= 1, {{x, -1, 1}, {y, -1, 1}}]];
NIntegrate[1, {x, y} ∈ nrDisk]
NIntegrate[1, {x, y} ∈ nrDisk]
ImplicitRegion[]
is unable to handle pure Boolean-valued functions like yourinDisk[]
. $\endgroup$ConstantRegionQ[ImplicitRegion[x^2 + y^2 <= 1, {{x, -1, 1}, {y, -1, 1}}]]
returns True. What is the technical difference between the expressionx^2 + y^2 <= 1
and a pure Boolean-valued function? $\endgroup$