1
$\begingroup$

I need to compute the following integral with three indicator functions, $I(x)$, $I_1(x_1)$ and $I_2(x_2)$,

$$ \int_0^1\int_0^1I(x)\left( \ I_1(x_1)\,x_{1} + I_2(x_2)\,x_{2}-1 \right) dx_1 dx_2 $$

where

$$ I(x)= \begin{cases} 1 & \text{if } I_1(x_1)x_1 + I_2(x_2)x_2 \geq s \\ 0 & \text{otherwise}% \end{cases} $$

$$ I_i(x_i)=% \begin{cases} 1 & \text{if } x_i \geq t_i \\ 0 & \text{otherwise} \end{cases} \qquad i=1,2 $$

I try to write it as

Integrate[
(x1 + x2 - 1)*(Boole[x1 + x2 >= s && x1 >= t1 && x2 >= t2]),{x1,0,1},{x2,0,1}]

It does generate some superficially long output, which makes me further suspect the syntax.

I found at this place a similar problem about multiple indicator functions was also discussed , however, it did not include the above "compound" indicator case.

PS: The original integral is with $n+1$ indicator functions. I simplified it to the above $2+1$ indicator functions with $\textit{U}(0,1)$ case.

$\endgroup$
  • $\begingroup$ You could write your indicator functions in terms of UnitStep[x-t] $\endgroup$ – mikado Jun 22 '16 at 19:35
  • $\begingroup$ @mikado Thanks for the input. But writing asIntegrate[ (x1 + x2 - 1)*(Boole[x1 + x2 >= s)UnitStep[x1 - t1]UnitStep[x1 - t2],{x1,0,1},{x2,0,1}] generate exact the same output. However, if changing to Integrate[ (x1 + x2 - 1)UnitStep[x1 + x2 -s]UnitStep[x1 - t1]UnitStep[x1 - t2],{x1,0,1},{x2,0,1}], it seems not working, and I am not sure the reason for the later. $\endgroup$ – Yun Jun 22 '16 at 20:56
3
$\begingroup$

How about adding some assumptions (I think the following is reasonable):

res = Integrate[(x1 + x2 - 1)*(Boole[
      x1 + x2 >= s && x1 >= t1 && x2 >= t2]), {x1, 0, 1}, {x2, 0, 1}];

FullSimplify[res, 0 < s < 1 && 0 < t1 <= t2 < 1]

$$\begin{cases} \frac{1}{2} (\text{t1}-1) (\text{t2}-1) (\text{t1}+\text{t2}) & s\leq \text{t1}\lor s\leq \text{t1}+\text{t2} \\ \frac{1}{6} \left(-2 s^3+3 s^2 (\text{t1}+\text{t2}+1)\\\qquad -6 s (\text{t1}+\text{t2})-\text{t1}^3+3 (\text{t1}+\text{t2})-\text{t2}^3\right) & \text{True} \end{cases}$$

A faster approach (if you already know what constraints to assume) is this:

res = Assuming[0 < s < 1 && 0 < t1 <= t2 < 1, 
  FullSimplify@
   Integrate[(x1 + x2 - 1)*(Boole[
       x1 + x2 >= s && x1 >= t1 && x2 >= t2]), {x1, 0, 1}, {x2, 0, 1}]]

which gives the same result.

$\endgroup$
  • $\begingroup$ Thank you for the suggestion. (0,1)for all three indicators are very reasonable assumptions; however, I cannot say t1 <= t2 given the original setting. Also, I guess I can somewhat simplify the problem, but the reason I raised the question here is because I am wandering whether the original syntax is the correct /optimal approach to handle multiple indicators. $\endgroup$ – Yun Jun 22 '16 at 23:53
  • $\begingroup$ One might also want to perform a preliminary canonicalization with PiecewiseExpand[]. $\endgroup$ – J. M. is away Jun 23 '16 at 0:53

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.