6
$\begingroup$

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?

$\endgroup$
5
  • $\begingroup$ Note that NIntegrate[1, {x, y} \[Element] Triangle[{{0, 0}, {1, 2}, {2, 1}}], Method -> {"MonteCarlo"}] returns unevaluated, too. $\endgroup$
    – Michael E2
    May 10, 2015 at 21:45
  • $\begingroup$ I believe that mma regards {"MonteCarlo"} as "MonteCarlo",but it doesn't. $\endgroup$
    – WateSoyan
    May 11, 2015 at 1:12
  • 3
    $\begingroup$ I think they should be equivalent. I think there must be some sort of bug. When I try to Trace with TraceInternal -> True, it gobbles up memory and I have to kill it. $\endgroup$
    – Michael E2
    May 11, 2015 at 1:40
  • 5
    $\begingroup$ Bug report filed, thanks for reporting this issue! $\endgroup$
    – ilian
    May 13, 2015 at 11:31
  • 1
    $\begingroup$ Fixed in version 10.2. $\endgroup$
    – ilian
    Jul 14, 2015 at 17:34

2 Answers 2

7
$\begingroup$

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}]
$\endgroup$
1
$\begingroup$

As mentioned in the comments, this bug has been fixed as of Mathematica 10.2.

NIntegrate[1, {x, y} ∈ Triangle[{{0, 0}, {1, 2}, {2, 1}}],     
         Method -> {"MonteCarlo", "MaxPoints" -> 10^5}]                         

(* 1.49258 *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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