Bug introduced in 10.0 and fixed in 10.2.0
It's no surprise that the "MonteCarlo" Method works well:
NIntegrate[1, {x, y} ∈ Triangle[{{0, 0}, {1, 2}, {2, 1}}],
Method -> "MonteCarlo"]
(*1.50189*)
But when I try to change "MaxPoints", NIntegrate directly refuses me.
NIntegrate[1, {x, y} ∈ Triangle[{{0, 0}, {1, 2}, {2, 1}}],
Method -> {"MonteCarlo", "MaxPoints" -> 10^5}]
So sad! What's the story?
Answer
I wonder if this is a bug that appears when using regions and {"MonteCarlo"} as a method. It hangs my machine. This might be a possible workaround:
NIntegrate[1, {x, y} \[Element] Triangle[{{0,0},{1,2},{2,1}}],
Method-> "MonteCarlo", MaxPoints -> 10^5}]
There isn't mention of the new arbitrary region functionality with the "MaxPoints" option or "MonteCarloRule" option in the documentation. You could also convert an arbitrary region with Boole[RegionMember[...]] and specify some ranges for x and y. This works on my machine:
NIntegrate[Boole[RegionMember[
Triangle[{{0, 0}, {1, 2}, {2, 1}}],{x, y}]],
{x,-10,10}, {y,-10,10}, Method -> {"MonteCarlo", "MaxPoints" -> 10^5}]
Comments
Post a Comment