0

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.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Eckhard
  • 83
  • 4

1 Answers1

1

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 
Eckhard
  • 83
  • 4