Task 3. Find all triples of real numbers $(x, y, z)$ that satisfy

$$
x^{2}+y^{2}+z^{2}+1=x y+y z+z x+|x-2 y+z| .
$$
Solution I. We rewrite the given equation as

$$
\frac{1}{2} x^{2}-x y+\frac{1}{2} y^{2}+\frac{1}{2} y^{2}-y z+\frac{1}{2} z^{2}+\frac{1}{2} z^{2}-z x+\frac{1}{2} x^{2}+1=|x-2 y+z|,
$$

or equivalently as

$$
\frac{1}{2}(x-y)^{2}+\frac{1}{2}(y-z)^{2}+\frac{1}{2}(z-x)^{2}+1=|(x-y)+(z-y)|.
$$

Now substitute $a=x-y$ and $b=z-y$. Then $x-z=a-b$, so we get

$$
\frac{1}{2} a^{2}+\frac{1}{2} b^{2}+\frac{1}{2}(a-b)^{2}+1=|a+b|
$$

From $(a-b)^{2} \geq 0$ it follows that $a^{2}-2 a b+b^{2} \geq 0$, so $2 a^{2}+2 b^{2} \geq a^{2}+b^{2}+2 a b$, which means that $a^{2}+b^{2} \geq \frac{(a+b)^{2}}{2}$ with equality if and only if $a=b$. Of course, $(a-b)^{2} \geq 0$ also holds. Therefore,

$$
|a+b|=\frac{1}{2} a^{2}+\frac{1}{2} b^{2}+\frac{1}{2}(a-b)^{2}+1 \geq \frac{(a+b)^{2}}{4}+1
$$

Now write $c=|a+b|$, then we have

$$
c \geq \frac{c^{2}}{4}+1
$$

This can be rewritten as $c^{2}-4 c+4 \leq 0$, or $(c-2)^{2} \leq 0$. Since the left side is a square, equality must hold, so $c=2$. Furthermore, equality must also hold in our earlier estimate, so $a=b$. Substituting this into (2) gives $a^{2}+1=2$, so $a= \pm 1$. Thus, we find the triples $(y+1, y, y+1)$ and $(y-1, y, y-1)$ for any $y \in \mathbb{R}$. Substituting these triples into equation (1) (which is equivalent to the original equation) shows that these triples are indeed solutions for all $y \in \mathbb{R}$. Therefore, all solutions are given by $(y+1, y, y+1)$ and $(y-1, y, y-1)$ with $y \in \mathbb{R}$.