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

$$
f(x y-1)+f(x) f(y)=2 x y-1
$$

for all $x, y \in \mathbb{R}$.
Solution. If $f$ is constant, the left side is always the same, while the right side can vary, leading to a contradiction. Therefore, $f$ is not constant. Now, substitute $x=0$: $f(-1)+f(0) f(y)=-1$, so $f(0) f(y)$ takes the same value for all $y \in \mathbb{R}$. Since $f$ is not constant, this gives $f(0)=0$. We can then immediately conclude that $f(-1)=-1$. Now, substitute $x=y=1$: $f(0)+f(1)^{2}=1$, so $f(1)=1$ or $f(1)=-1$.

Substituting $y=1+\frac{1}{x}$ with $x \neq 0$ gives $f(x+1-1)+f(x) f\left(1+\frac{1}{x}\right)=2 x+2-1$, so

$$
f(x) f\left(1+\frac{1}{x}\right)=2 x+1-f(x) \quad \text { for all } x \neq 0 \text {. }
$$

Substituting $y=\frac{1}{x}$ with $x \neq 0$ gives $f(1-1)+f(x) f\left(\frac{1}{x}\right)=2-1$, so

$$
f(x) f\left(\frac{1}{x}\right)=1 \quad \text { for all } x \neq 0 \text {. }
$$

Substituting $y=1, x=z+1$ gives $f(z+1-1)+f(z+1) f(1)=2 z+2-1$, so

$$
f(z)+f(z+1) f(1)=2 z+1 \quad \text { for all } z \text {. }
$$

We now choose $z=\frac{1}{x}$ with $x \neq 0$ in this equation and multiply the whole by $f(x)$:

$$
f(x) f\left(\frac{1}{x}\right)+f\left(\frac{1}{x}+1\right) f(1) f(x)=\frac{2}{x} f(x)+f(x) \quad \text { for all } x \neq 0 \text {. }
$$

We rewrite the first and second terms using (2) and (1) respectively, so we get:

$$
1+2 x f(1)+f(1)-f(x) f(1)=\frac{2}{x} f(x)+f(x) \quad \text { for all } x \neq 0 \text {. }
$$

This can be rewritten as

$$
f(x) \cdot\left(\frac{2}{x}+1+f(1)\right)=1+2 x f(1)+f(1) \quad \text { for all } x \neq 0 \text {. }
$$

If the second factor on the left is not 0, we can divide by it, so:

$$
f(x)=\frac{1+2 x f(1)+f(1)}{\frac{2}{x}+1+f(1)} \quad \text { if } x \neq 0 \text { and } \frac{2}{x}+1+f(1) \neq 0
$$

We had two possible values for $f(1)$. First, let $f(1)=1$. Then we have

$$
f(x)=\frac{2+2 x}{\frac{2}{x}+2}=x \quad \text { if } x \neq 0 \text { and } \frac{2}{x}+2 \neq 0 .
$$

$\frac{2}{x}+2=0$ only if $x=-1$, but we already knew that $f(-1)=-1$. Also, we already had $f(0)=0$. We see that $f(x)=x$ for all $x$. We check this function: in the original functional equation, we get $x y-1+x y=2 x y-1$, so it is correct.

On the other hand, let $f(1)=-1$. Then we have

$$
f(x)=\frac{-2 x}{\frac{2}{x}}=-x^{2} \quad \text { if } x \neq 0 \text { and } \frac{2}{x} \neq 0
$$

Since $\frac{2}{x}=0$ cannot occur, we conclude that $f(x)=-x^{2}$ for all $x \neq 0$. Also, $f(0)=0$ satisfies this formula. We check the function $f(x)=-x^{2}$ for all $x$: in the original functional equation, we get $-x^{2} y^{2}-1+2 x y+x^{2} y^{2}=2 x y-1$, so it is correct.

We conclude that there are two solutions, namely $f(x)=x$ for all $x$ and $f(x)=-x^{2}$ for all $x$.