# Double Integral of Minimum Function

I was trying to solve the following integral: $$$$\int _0^{\alpha }\int _0^{\beta }\min (x,y)dydx \tag{1} \label{eq:1}$$$$ with $\alpha,\beta > 0$, (generally, $\alpha \ne \beta$).

I've found a question from MSE (how to solve double integral of a min function) where an user suggested the following equivalence: $$$$\int_0^{\beta } \min (x,y) \, dy =\int_0^x \min (x,y) \, dy+\int_x^{\beta } \min(x,y) \, dy \\ =\int_0^x y \, dy+\int_x^{\beta } x \, dy \tag{2} \label{eq:2}$$$$ The explanation is in link above and I also found it by myself. The issue is that the $(1)$ and the $(2)$ inserted in $(1)$: $$\int _0^{\alpha }\int _0^{\beta }\min (x,y)dydx \tag{1}$$ $$\int _0^{\alpha } \bigg( \int_0^x y \, dy+\int_x^{\beta } x \, dy \bigg) dx \tag{3}$$ are giving me different results. In fact, generally, through different cases of $\alpha$ and $\beta$ I set, it seems that, if $\beta \ge \alpha$, the $(1)$ and $(3)$ are equivalent, else they aren't. What am I missing? Have I to suppose some conditions for the $(2)$ is effective? Is there a problem of integral interchange?

• It might be useful to sketch pictures of the integration region for the cases (1) $\alpha>\beta$, (2) $\alpha<\beta$, and (3) $\alpha=\beta$. – Mark Viola Jul 4 '17 at 15:28
• Yes. I thought so. The area I consider is rectangular and I have to plot the function and see how $\alpha$ and $\beta$ are working. But, is there a way to do it without sketch? I know that $\min(x,y)=\frac{x+y-|y-x|}{2}$ and I solve the problem with that, but I want to know why the reasoning above is not working, if that is true or false and why. – Antonio Placentino Jul 4 '17 at 15:36

By definition

$$\min(x,y)=\begin{cases}x\le y\to x\\x\ge y\to y.\end{cases}$$

Then, assuming $\alpha\le\beta$ you can decompose the domain using

$$I=\int_{x=0}^\alpha\int_{y=0}^\beta\min(x,y)\,dy\,dx=\int_{x=0}^\alpha\int_{y=0}^x y\,dy\,dx+\int_{x=0}^\alpha\int_{y=x}^\beta x\,dy\,dx.$$

The condition is required because $y$ may not exceed $\beta$.

This gives

$$I=\int_0^\alpha\left(\frac{x^2}2+\beta x-x^2\right)dx=\frac{\alpha^2\beta}2-\frac{\alpha^3}6=\alpha^2\frac{3\beta-\alpha}6.$$

And by swapping $\alpha,\beta$, $$\alpha\ge\beta\to I=\beta^2\frac{3\alpha-\beta}6.$$

• That "The condition is required because $y$ may not exceed $β$." is what I was looking for, to complete my question. In fact, I haven't seen that, if $\alpha > \beta$, it is wrong to consider the $(2)$ from question box: $$\int_0^{\beta } \min (x,y) \, dy =\int_0^x y \, dy+\int_x^{\beta } x \, dy \tag{2}$$ because it says that $y$ goes from $0$ to $x$ and $x$ can go until $\alpha$ where $y$ is not condiderated ($0<y<\beta<\alpha$). Thanks for that! – Antonio Placentino Jul 4 '17 at 17:22
• Moral: Control always the domain, if the calculus bring to a wrong domain of integration, go back and find another way! :) Thank you for your willingness to help. – Antonio Placentino Jul 4 '17 at 17:27

If $\alpha<\beta$, we have

\begin{align} \int_0^\alpha \int_0^\beta \min(x,y)\,dy\,dx&=\int_0^\alpha \int_0^\alpha \min(x,y)\,dy\,dx+\int_0^\alpha \int_\alpha^\beta \min(x,y)\,dy\,dx\\\\ &=\int_0^\alpha \left(\int_0^x \min(x,y)\,dy\,dx+\int_x^\alpha \min(x,y)\,dy\,dx\right)+\int_0^\alpha \int_\alpha^\beta \min(x,y)\,dy\,dx\\\\ &=\int_0^\alpha \int_0^x y\,dy\,dx+\int_0^\alpha \int_x^\alpha x\,dy\,dx+\int_0^\alpha \int_\alpha^\beta x\,dy\,dx\\\\ &=\int_0^\alpha \int_0^x y\,dy\,dx+\int_0^\alpha \int_x^\beta x\,dy\,dx \end{align}

Can you finish now?

• Yes, it is. For $\beta > \alpha$, if we're following the $(3)$ from the question box, we get the expression you generously wrote. I also see that, if $\alpha > \beta$, I cannot do the same transformation of the internal integral from your expression above. Fortunally, thanks to your suggestion, I can find supposition for the interchange of integral and have this for $\alpha > \beta$: – Antonio Placentino Jul 4 '17 at 16:53
• $\int _0^{\alpha }\int _0^{\beta }\min (x,y)dydx=\int _0^{\beta }\int _0^{\alpha }\min (x,y)dxdy=\int _{\beta }^{\alpha }\int _0^{\beta }ydydx+\int _0^{\beta }\int _x^{\beta }xdydx+\int _0^{\beta }\int _0^xydydx$ – Antonio Placentino Jul 4 '17 at 16:54
• Fubini's Theorem permits the interchange of the order of integration. – Mark Viola Jul 4 '17 at 16:54
• Thanks very much for your patience and willingness. I get to the answer thanks to you (and Fubini's Theorem, obviously). Now, I'd like to know why I cannot do the same procedure for $\alpha > \beta$, as I do for $\beta > \alpha$, or why I have to interchange the integral for solving the double integral... I guess, I have to sketch anyway, but if I get a proof of what, it'd be great! – Antonio Placentino Jul 4 '17 at 17:00
• Without interchanging the order of integration, we have for $\alpha>\beta$ \begin{align} \int_0^\alpha \int_0^\beta \min(x,y)\,dy\,dx&=\int_0^\beta\int_0^\beta \min(x,y)\,dy\,dx+\int_\beta^\alpha \int_0^\beta \min(x,y)\,dy\,dx\\\\ &=\int_0^\beta \left(\int_0^x\min(x,y)\,dy+\int_x^\beta\min(x,y)\,dy\right)\,dx+\int_\beta^\alpha \int_0^\beta y\,dy\,dx\\\\ \end{align} – Mark Viola Jul 4 '17 at 17:05

Probabilistic approach

Without loss of generality assume $\alpha<\beta$. Let us define two independent random variables $X\sim \text{Unif}[0,\alpha]$ and $Y\sim\text{Unif}[0,\beta]$.

The integral you asked for is just: $\alpha\beta \mathbb{E}[\min\{X,Y \}]$

Define $Z=\min\{X,Y\}$. The density function of $Z$ can be obtained via straightforward calculation:

\begin{align} f_Z(z) = \begin{cases} \frac{1}{\alpha}+\frac{1}{\beta}-2\frac{z}{\alpha \beta} & \text{ for } z\in[0,\alpha] \\ 0 & \text{otherwise} \end{cases} \end{align} Thus: \begin{align} \mathbb{E}[\min\{X,Y\}]=\mathbb{E}[Z]=\int_0^\alpha z f_z(z) \mathrm d z = \int^\alpha_0 \frac{z}{\alpha} +\frac{z}{\beta} - \frac{2z^2}{\alpha \beta} \mathrm dz = \frac{\alpha}{2}-\frac{\alpha^2}{6\beta} \end{align} Finally,

\begin{align} \int^\alpha_0 \int^\beta_0 \min\{x,y\} \mathrm d y \mathrm dx = \alpha\beta \mathbb{E}[Z] = \frac{\alpha^2\beta}{2}-\frac{\alpha^3}{6} \end{align}

• Thanks for the patience and your willingness. I like that probabilistic approch, can I do the same procedure, if $\alpha > \beta$? – Antonio Placentino Jul 4 '17 at 17:02
• Yes, sure! There is no need to do the calculation for $\alpha>\beta$. Just take $\alpha$ to be $\beta$ and vice versa and obtain the result for $\alpha>\beta$. – Shashi Jul 4 '17 at 17:06
• Yes, I understand. In fact, the proof you give certainly prevents me from interchange values. This also solve the problem of consider cases of $\alpha > \beta$ and $\beta > \alpha$. Now, I only am trying to understand, why the approch of solving the integral in the question box is not correct for both cases. Thanks for your nice proof. – Antonio Placentino Jul 4 '17 at 17:12
• @AntonioPlacentino my answer was meant to show how the integral can be calculated with a different approach. I thought your main question was answered by Mark Viola, right? – Shashi Jul 4 '17 at 17:16
• Yes, half of problem. There only was a thing I cannot understand for the integral above and thanks to Yves Daoust, I found it too. I know your approch was different and very interesting and I did appreciate that. Thank you very much! – Antonio Placentino Jul 4 '17 at 17:33

When $\alpha\lt\beta$, we have

\begin{align} \int_0^\alpha\int_0^\beta\min(x,y)\,\mathrm{d}y\,\mathrm{d}x &=\overbrace{2\int_0^\alpha\int_0^xy\,\mathrm{d}y\,\mathrm{d}x}^\text{integral over square}+\overbrace{\int_\alpha^\beta\int_0^\alpha y\,\mathrm{d}y\,\mathrm{d}x}^\text{integral over rectangle}\\ &=\frac13\alpha^3+\frac12\alpha^2(\beta-\alpha)\tag{1} \end{align} Using $[\alpha\gt\beta]=\frac{\alpha-\beta+|\alpha-\beta|}{2(\alpha-\beta)}$ and $[\alpha\lt\beta]=\frac{\alpha-\beta-|\alpha-\beta|}{2(\alpha-\beta)}$ and $(1)$, we get $$\int_0^\alpha\int_0^\beta\min(x,y)\,\mathrm{d}y\,\mathrm{d}x =\frac1{12}\left(|\alpha-\beta|^3-(\alpha+\beta)\left(\alpha^2-4\alpha\beta+\beta^2\right)\right)\tag{2}$$

• Thanks! You give a graphical expression of my problem. $\min(x,y)$ can also be rewritten as you suggested. That's a good approach. Thank you for your willingness to help. – Antonio Placentino Jul 4 '17 at 20:07
• It is possible to rewrite $\min(x,y)=\frac{x+y-|x-y|}2$, but integrating absolute value expressions often involves many cases. It is usually easier to compute the entire expression assuming $\alpha\lt\beta$ and splice together the integrals using $[\alpha\lt\beta]$ and $[\alpha\gt\beta]$. – robjohn Jul 4 '17 at 20:14
• In fact, the approach of splitting integral is the fastest way. You and your colleagues also showed me others ways to approach the problem. Then, I found out I was considering areas out of my problem ($0<y<\beta$ and I was calculating an integral where $y>\beta$ which is out of domain). You all gave me ways of rewriting the integral and I appreciate that. Thanks to you all! – Antonio Placentino Jul 4 '17 at 20:23