mathematica: evaluation order in numerical integration
<p>Hi i have a problem concerning a numerical integration in mathematica. Here is my test function</p>

<pre><code>Table[NIntegrate[
Boole[Sqrt[1 - cosk^2]*Sqrt[1 - cosk2^2] &gt; Abs[a - cosk*cosk2]]/
Sqrt[(1 - cosk^2)*(1 - cosk2^2) - (a - cosk*cosk2)^2],
{cosk, -1,1}, {cosk2, -1, 1}, Method -&gt; "GlobalAdaptive"], {a, -.9, .9, .1}]
</code></pre>

<p>The integration yields complex values although due to the boolean function in the integrand the argument in the sqrt should be always positive and hence only result in real values. Is it possible to first evaluate the boole function and only if it is true then start to numerically integrate? </p>

<p>If i calculate the same integral using a monte carlo integration strategy</p>

<pre><code>Table[NIntegrate[
Boole[Sqrt[1 - cosk^2]*Sqrt[1 - cosk2^2] &gt; Abs[a - cosk*cosk2]]/
Sqrt[(1 - cosk^2)*(1 - cosk2^2) - (a - cosk*cosk2)^2], {cosk, -1, 
1}, {cosk2, -1, 1}, Method -&gt; {"MonteCarlo", "MaxPoints" -&gt; 10^8, 
"SymbolicProcessing" -&gt; None}], {a, -.9, .9, .1}]
</code></pre>

<p>how can I find out if it sums up a lot of zeroes due to the boolean function? I think the evaluation can save a lot of computation time if it first evaluates the boolean function for each sample point of the monte carlo grid. If i replace "MonteCarlo" by "AdaptiveMonteCarlo" the result goes totally wrong.</p>