4. Determine the maximum value of the difference $x-y$ if

$$
2\left(x^{2}+y^{2}\right)=x+y
$$
Solution. Let $a=x-y$, hence $x=a+y$. If we substitute in (1), we get

$$
2(y+a)^{2}+2 y^{2}=a+2 y
$$

which simplifies to

$$
4 y^{2}+2(2 a-1) y+2 a^{2}-a=0
$$

The last equation is satisfied for $a=a_{\max}$. It has at least one real root $y$ if and only if

$$
D=(2 a-1)^{2}-4\left(2 a^{2}-a\right) \geq 0
$$

which simplifies to

$$
4 a^{2}-1 \leq 0
$$

This is true only if $a \in\left[-\frac{1}{2}, \frac{1}{2}\right]$. Thus, $a_{\max }=\frac{1}{2}$.

## III year