# Integrating a function with Max function

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.

• Try Integrate[1, {x, 0, 1}, {y, 0, 1 - x}, {z, 0, Max[x, y]}]. – JimB Oct 8 '19 at 14:37

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

• Wonderful. I knew there must be a simple solution I was overlooking. – JonHales Oct 8 '19 at 14:53

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

with

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


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