5. Consider all pairs $(x, y)$ of real numbers such that $0 \leq x \leq$ $y \leq 1$. Let $M(x, y)$ be the maximum value of the set

$$
A=\{x y, x y-x-y+1, x+y-2 x y\}
$$

Find the minimum value that $M(x, y)$ can take for all these pairs $(x, y)$.
Solution 1. Making the change of variables $x y=p$, and $x+y=s$ and writing the three elements of the set $A$ in terms of $s$ and $p$, we have

$$
a=x y=p, \quad b=x y-x-y+1=(1-x)(1-y)=s-1+p, \quad c=s-2 p
$$

verifying that $a+b+c=1$. Observe that $s^{2}-4 p=(x-y)^{2} \geq 0$.

Now consider the following cases:

- If $0 \leq x \leq y \leq \frac{1}{3} \Rightarrow p=x y \leq \frac{1}{9} \Leftrightarrow b=(1-x)(1-y) \geq \frac{4}{9}$.
- If $c=s-2 p \leq \frac{4}{9} \Rightarrow 0 \leq s^{2}-4 p=\left(2 p+\frac{4}{9}\right)^{2}-4 p=4\left(p-\frac{1}{9}\right)\left(p-\frac{4}{9}\right)$, from which it follows that $p \leq \frac{1}{9}$ or $p \geq \frac{4}{9}$. If $a=p \leq \frac{1}{9} \Rightarrow b \geq \frac{4}{9}, c=$ $s-2 p \leq \frac{4}{9}$ and if $a=p \geq \frac{4}{9} \Rightarrow b \leq \frac{1}{9}, c \leq \frac{4}{9}$. Therefore, in any
case

$$
\text { max } A \geq \frac{4}{9}
$$

To find the minimum $\frac{4}{9}$, the inequalities must be equalities and we have:

- $p=\frac{1}{9}, s-2 p=\frac{4}{9} \Rightarrow s=\frac{2}{3} \Rightarrow x=y=\frac{1}{3}$,
- $p=\frac{4}{9}, s-2 p=\frac{4}{9} \Rightarrow s=\frac{4}{3} \Rightarrow x=y=\frac{2}{3}$.

Solution 2. First, observe that $x y+(x y-x-y+1)+(x+$ $y-2 x y)=1$. Thus, if one of the three elements of $A$ is $\frac{1}{9}$ or less, then the other two sum to $\frac{8}{9}$ or more, so if the smallest value of $A$ is $\frac{1}{9}$ or less, the largest value of $A$ is $\frac{4}{9}$ or more.

Suppose that $x y \geq x+y-2 x y$. Then, by the inequality between the arithmetic and geometric means, we have

$$
3 x y \geq x+y \geq 2 \sqrt{x y}, \quad \sqrt{x y} \geq \frac{2}{3}
$$

and the largest value of $A$ is at least $x y \geq \frac{4}{9}$ in this case.

Suppose that $x y-x-y+1 \geq x+y-2 x y$. Again by the inequality between the arithmetic and geometric means, we have

$$
3 x y+1 \geq 2(x+y) \geq 4 \sqrt{x y} \Leftrightarrow(3 \sqrt{x y}-1)(\sqrt{x y}-1) \geq 0
$$

The last inequality holds when $\sqrt{x y} \geq 1$, in which case the largest value of $A$ would be at least $x y \geq 1$, or when $\sqrt{x y} \leq \frac{1}{3}$, for $x y \leq \frac{1}{9}$, and by the initial observation, the largest value of $A$ would be $\frac{4}{9}$ or more.

In any other case, $x+y-2 x y$ is the largest value of $A$, and suppose it is less than $\frac{4}{9}$. That is, $x+y-2 x yx+y \geq 2 \sqrt{x y} \Leftrightarrow\left(\sqrt{x y}-\frac{1}{2}\right)^{2}>\frac{1}{36}=\left(\frac{1}{6}\right)^{2}
$$

If $\sqrt{x y}-\frac{1}{2}>\frac{1}{6}$, then $\sqrt{x y}>\frac{2}{3}$ and the largest value of $A$ is at least $x y>\frac{4}{9}$, a contradiction. If $\frac{1}{2}-\sqrt{x y}>\frac{1}{6}$, then $\sqrt{x y}<\frac{1}{3}$, so $x y<\frac{1}{9}$, and by the initial observation, the largest value of $A$ is more than $\frac{4}{9}$, a contradiction.

Thus, the largest value of $A$ can never be less than $\frac{4}{9}$, and this value is indeed the minimum that the maximum of $A$ takes, as $A=\left\{\frac{4}{9}, \frac{1}{9}, \frac{4}{9}\right\}$ can be obtained by taking $x=y=\frac{2}{3}$, or $A=\left\{\frac{1}{9}, \frac{4}{9}, \frac{4}{9}\right\}$ by taking $x=y=\frac{1}{3}$. Looking at the conditions for equality in the first two cases analyzed, we also have that these are all the possible pairs of values $(x, y)$ for which the largest value of $A$ takes this minimum value.