2
$\begingroup$

I'm trying to evaluate the triple integral $$\int_{0}^{1} \int_{0}^{1-x} \int_{0}^{1-\max(x,y)}1 dzdydx$$

in Mathematica. The code I'm using is simply

Integrate[Integrate[Integrate[1,{z,0,Max[x,y]}],{y,0,1-x}],{x,0,1}]

Mathematica thinks for a second and then gives as an output

$$\int_{0}^{1} \int_{0}^{1-x}1-\max(x,y)dydx.$$

I thought that Mathematica would be able to handle this type of integral because when I evaluate this in wolfram alpha, I get the correct answer of $\frac{1}{4}$.

I don't need to get the exact value of the integral, just correct to a few decimal places would be nice. Eventually, I'm hoping to integrate a few slightly more complicated functions that have maximums and minimums of the variables in them.

$\endgroup$
  • 3
    $\begingroup$ Try Integrate[1, {x, 0, 1}, {y, 0, 1 - x}, {z, 0, Max[x, y]}]. $\endgroup$ – JimB Oct 8 at 14:37
5
$\begingroup$

Use the multiple integral syntax instead of nesting Integrate:

Integrate[1, {x, 0, 1}, {y, 0, 1-x}, {z, 0, Max[x, y]}]

1/4

$\endgroup$
  • $\begingroup$ Wonderful. I knew there must be a simple solution I was overlooking. $\endgroup$ – JonHales Oct 8 at 14:53
1
$\begingroup$

Another way is as follows.

Integrate[Integrate[Integrate[1,{z, 0, Max[x, y]},Assumptions -> x >= 0&&x<= 1 && y >= 0 && y <= 1],
 {y, 0, 1 - x}, Assumptions -> x >= 0&& x <= 1 && y >= 0 && y <= 1], {x, 0, 1}]

1/4

Compare

Integrate[Integrate[1, {z, 0, Max[x, y]}, 
 Assumptions -> x >= 0 && x <= 1 && y >= 0 && y <= 1], {y, 0, 1 - x},
Assumptions -> x >= 0 && x <= 1 && y >= 0 && y <= 1]

$$\begin{cases} \frac{1}{2} (1-2 x) & x=0 \\ -(x-1) x & \frac{1}{2}\leq x<1 \\ \frac{1}{2} \left(2 x^2-2 x+1\right) & 0<x<\frac{1}{2} \end{cases} $$

with

Integrate[Integrate[1, {z, 0, Max[x, y]}], {y, 0, 1 - x}]

$\int_0^{1-x} \max (x,y) \, dy .$

$\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.