Task 5. Find all functions $f: \mathbb{R} \rightarrow \mathbb{R}$ that satisfy

$$
f(x + x y + f(y)) = \left(f(x) + \frac{1}{2}\right)\left(f(y) + \frac{1}{2}\right)
$$

for all $x, y \in \mathbb{R}$.
Solution. Substitute $y=-1$, then we have:

$$
f(f(-1))=\left(f(x)+\frac{1}{2}\right)\left(f(-1)+\frac{1}{2}\right).
$$

If $f(-1) \neq-\frac{1}{2}$, then we can divide by $f(-1)+\frac{1}{2}$ and get

$$
f(x)+\frac{1}{2}=\frac{f(f(-1))}{f(-1)+\frac{1}{2}},
$$

which means that $f$ is constant. Then there is a $c \in \mathbb{R}$ such that $f(x)=c$ for all $x \in \mathbb{R}$. Now the functional equation reads:

$$
c=\left(c+\frac{1}{2}\right)\left(c+\frac{1}{2}\right),
$$

which we can rewrite as $0=c^{2}+\frac{1}{4}$, but this has no real solution in $c$. Therefore, $f$ cannot be constant.

The only possibility is thus that $f(-1)=-\frac{1}{2}$. This also means that $f(f(-1))=0$, so $f\left(-\frac{1}{2}\right)=0$. Substitute $x=0$ and $y=-\frac{1}{2}$, which gives:

$$
f\left(f\left(-\frac{1}{2}\right)\right)=\left(f(0)+\frac{1}{2}\right)\left(f\left(-\frac{1}{2}\right)+\frac{1}{2}\right),
$$

and thus

$$
f(0)=\left(f(0)+\frac{1}{2}\right) \cdot \frac{1}{2},
$$

from which it follows that $f(0)=\frac{1}{2}$.

Suppose there is an $a \neq-1$ such that $f(a)=-\frac{1}{2}$. Substitute $y=a$:

$$
f\left(x(1+a)-\frac{1}{2}\right)=0.
$$

Since $1+a \neq 0$, $x(1+a)-\frac{1}{2}$ can take all values in $\mathbb{R}$ as $x$ varies over $\mathbb{R}$. Therefore, it follows that $f$ is constantly 0, but we have already seen that $f$ cannot be constant. We conclude that there is no $a \neq-1$ such that $f(a)=-\frac{1}{2}$. Thus, there is only one $x$ for which $f(x)=-\frac{1}{2}$, and that is $x=-1$.

Consider any $b$ such that $f(b)=0$. Substitute $x=b-\frac{1}{2}$ and $y=0$:

$$
f\left(b-\frac{1}{2}+\frac{1}{2}\right)=\left(f\left(b-\frac{1}{2}\right)+\frac{1}{2}\right)\left(\frac{1}{2}+\frac{1}{2}\right),
$$

or equivalently

$$
f(b)=\left(f\left(b-\frac{1}{2}\right)+\frac{1}{2}\right).
$$

Since $f(b)=0$, it follows that $f\left(b-\frac{1}{2}\right)=-\frac{1}{2}$. We have seen that this implies $b-\frac{1}{2}=-1$, so $b=-\frac{1}{2}$.

Thus, there is only one $x$ for which $f(x)=0$, and that is $x=-\frac{1}{2}$. Substitute $x=-1$:

$$
f(-1-y+f(y))=0
$$

From this, it follows that $-1-y+f(y)=-\frac{1}{2}$, so $f(y)=y+\frac{1}{2}$. The only candidate function is thus the function given by $f(x)=x+\frac{1}{2}$ for all $x \in \mathbb{R}$.

We check this function. On the left side of the functional equation, we get: $x+x y+y+1$. On the right side, we get $(x+1)(y+1)$, which is equal to $x y+x+y+1$. The function satisfies the equation. We conclude that there is exactly one solution: $f(x)=x+\frac{1}{2}$ for all $x \in \mathbb{R}$.