0
$\begingroup$

I am trying to compute the integral

$Assumptions = {0 < x[3] < 1, 0 < x[4] < 1, 0 < x[5] < 1};
Integrate[
  x[2] Boole[2 (x[2] + x[3]) + x[4] < 1 &&  
             2 x[2] + x[3] + x[4] + 2 x[5] > 1 && 
             x[2] + x[5] < x[3] + x[4]],
  {x[2], 0, 1}]

but for some reason it takes forever. However, if I manually simplify the integrand

Boole[2 (x[2] + x[3]) + x[4] < 1 && 
      2 x[2] + x[3] + x[4] + 2 x[5] > 1 && 
      x[2] + x[5] < x[3] + x[4]] ==
Boole[(1 - x[3] - x[4])/2 - x[5] < x[2] < 
      Min[(1 - x[4])/2 - x[3], x[3] + x[4] - x[5]]] // PiecewiseExpand // Simplify

(* True *)

the integral is easily computed as

Integrate[Boole[a < x[2] < b] x[2], {x[2], 0, 1}] /.
  a -> (1 - x[3] - x[4])/2 - x[5] /. 
  b -> Min[(1 - x[4])/2 - x[3], x[3] + x[4] - x[5]] // PiecewiseExpand // Simplify

I'd appreciate any hints as to how I can compute the integral more quickly without manual intervention.

$\endgroup$
0
$\begingroup$

The following works for me: it uses the undocumented function Simplify`PWToUnitStep that I learned about here.

f = x[2] Boole[2 (x[2] + x[3]) + x[4] < 1 && 2 x[2] + x[3] + x[4] + 2 x[5] > 1 && x[2] + x[5] < x[3] + x[4]];
Integrate[#, {x[2], 0, 1}]&/@Expand@Simplify`PWToUnitStep@PiecewiseExpand@f 
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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