# Volume within parameter space

Imagine a parameter space with variable 0<p<1, 0<e1<1/2 and 0<e2<1/2.

There are certain conditions on the parameters in some situations. For example p<e1 or (p)(e1)/((p)(e1)+(1-p)(1-e2))<e1/e2

How can I determine the volume of the parameter space which satisfies these (and other) conditions?

I would like to determine them algebraically, and not via a numerical simulation of plotting points within parameter space. I also do not want to solve any complex equations myself. I simply want a function which gives me the result easily. Does this exist?

Update: The suggestion below works very well in many cases, however, I seem to have hit a problem.

Try to evaluate: NIntegrate[Boole[0<p<1&&0<e1<1/2&&0<e2<1/2&&e1<e2&&0<e3<1/2&&0<(e3-e2 e3-e1 p-e3 p+e1 e3 p+e2 e3 p)/((1-e1-2 e3+e1 e3+e2 e3) (-1+p))<1&&0<(-e1+e1 e3+e2 e3)/(1-e1-2 e3+e1 e3+e2 e3)<1&&40/100<(((e3-e2 e3-e1 p-e3 p+e1 e3 p+e2 e3 p)/((1-e1-2 e3+e1 e3+e2 e3) (-1+p)))(e3+p-2 e3 p)+(1-((e3-e2 e3-e1 p-e3 p+e1 e3 p+e2 e3 p)/((1-e1-2 e3+e1 e3+e2 e3) (-1+p))))(1-e3))],{p,0,1},{e1,0,1/2},{e2,0,1/2},{e3,0,1/2},WorkingPrecision->20]

This gives something like 0.036.

Try now to weaken the condition by lowering 50/100 to 40/100. The results becomes 0....

-

You could integrate over the region, using Boole:

Integrate[
Boole[0 < p < 1 && 0 < e1 < 1/2 && 0 < e2 < 1/2 &&
(p < e1 || (p) (e1)/((p) (e1) + (1 - p) (1 - e2)) < e1/e2)],
{p, 0, 1}, {e1, 0, 1/2}, {e2, 0, 1/2}]

(* 1/16 (5 - 6 Log[2] + 2 Log[4]) *)

-
It would be good to stress that this is the standard way to input these types of problems in Mathematica and that it is also supported by NIntegrate. What I mean is that NIntegrate does actually know what Boole is and won't sample points outside of that region if avoidable. It doesn't treat it as a numerical black box. – Szabolcs Nov 23 '13 at 19:36
It might also be worth stressing that success in a particular case depends on the success of Integrate/NIntegrate in handling that case. – Michael E2 Nov 23 '13 at 19:48
Simple and effective. Thank you. – LBogaardt Nov 25 '13 at 12:02
Hi again, I seem to have run into some trouble. NIntegrate[Boole[0<p<1&&0<e1<1/2&&0<e2<1/2&&e1<e2&&0<e3<1/2&&0<(e3-e2 e3-e1 p-e3 p+e1 e3 p+e2 e3 p)/((1-e1-2 e3+e1 e3+e2 e3) (-1+p))<1&&0<(-e1+e1 e3+e2 e3)/(1-e1-2 e3+e1 e3+e2 e3)<1&&50/100<(((e3-e2 e3-e1 p-e3 p+e1 e3 p+e2 e3 p)/((1-e1-2 e3+e1 e3+e2 e3) (-1+p)))(e3+p-2 e3 p)+(1-((e3-e2 e3-e1 p-e3 p+e1 e3 p+e2 e3 p)/((1-e1-2 e3+e1 e3+e2 e3) (-1+p))))(1-e3))],{p,0,1},{e1,0,1/2},{e2,0,1/2},{e3,0,1/2},WorkingPrecision->20]‌​ Try lowering the 50/100 and see what happens... Output is now 0 for a weaker condition... – LBogaardt Nov 27 '13 at 16:50
General tip: When an integral seems hard for Mathematica, first try making it easier. For instance, leave WorkingPrecision at MachinePrecision; instead set AccuracyGoal -> 6 and PrecisionGoal -> 6 or some such lower value. At least if it doesn't work (it doesn't), it should take less time. Second, try red = Reduce[expr, {p, e1, e2, e3}, Reals] and NIntegrate[red,...]. It works, but Reduce takes 90 sec. on my machine. Third, you might try Integrate[expr,...] /. Integrate -> NIntegrate. It takes about 48 sec. Of course, sometimes the solution is to increase precision. – Michael E2 Nov 27 '13 at 18:32