**Problem 3** Find all functions $f: \mathbf{R} \rightarrow \mathbf{R}$, such that for all $x, y \in \mathbf{R}$, we have
$$
f(1+x y)-f(x+y)=f(x) f(y),
$$

and $f(-1) \neq 0$.
Let $x=0$, we get
$f(1)-f(y)=f(0) f(y)$;
Let $x=1$, we get
$f(1+y)-f(1+y)=f(1) f(y)$.
Thus, $f(1)=0$ (the case $f(y)=0$ is discarded). Then $f(0)=-1$.
Let $y=-1$, we get
$$
f(1-x)-f(x-1)=f(-1) f(x) \text{.}
$$

Substitute $1-x$ for $x$ in equation (1) to get
$$
f(x)-f(-x)=f(-1) f(1-x) .
$$

Substitute $-x$ for $x$ in equation (2) to get
$$
f(-x)-f(x)=f(-1) f(1+x) \text{.}
$$
(2) + (3) gives $f(1-x)+f(1+x)=0$.

Let $x=1$, combined with $f(0)=-1$, we get $f(2)=1$.
Substitute $y=2$ into the original equation to get
$$
\begin{array}{l}
f(1+2 x)=f(2+x)+f(x) \\
=-f(-x)+f(x)=-f(-1) f(1+x) .
\end{array}
$$

Consider the system of equations
$$
\begin{array}{l}
\left\{\begin{array}{l}
f(1+x y)-f(x+y)=f(x) f(y), \\
f(1-x y)-f(x-y)=f(x) f(-y) .
\end{array}\right. \\
\Rightarrow f(x)(f(y)+f(-y))+f(x+y)+f(x-y)=0 .
\end{array}
$$

Consider the terms $f(x+y)$ and $f(x-y)$ in the above equation.
Let $x=y+1$, we get
$$
\begin{array}{l}
f(x-y)=f(1)=0, \\
f(x+y)=f(2 x-1) \\
=f(1+2(x-1))=-f(-1) f(x) .
\end{array}
$$

Thus, $f(x)(f(y)+f(-y)-f(-1))=0$.
(1) $f(x)=0$ for some real numbers $x \neq 1$.

Let $y=x-1$, we get $f(2 x-1)=0$.
By mathematical induction, we get
$$
\begin{array}{l}
f(1+k(x-1))=0(k \in \mathbf{Z}) . \\
\text{Also, by } f(x+y)+f(x-y)=0, \\
x=1+k(x-1)(k \in \mathbf{Z}),
\end{array}
$$

we know that $f$ is a periodic function, with period $d$.
Then $f(d)=f(0)=-1$.
In the original equation, let $y=d$, we get
$$
\begin{array}{l}
f(1+d x)=f(x)+f(x) f(0)=0 \\
\Rightarrow f \equiv 0,
\end{array}
$$

which contradicts $f(-1) \neq 0$.
$$
\text{(2) } f(x)+f(-x)=f(-1)(x \in \mathbf{R}) \text{.}
$$

Then $f(x+y)+f(x-y)+f(-1) f(x)=0$.
Let $y=0$, we get $f(-1)=-2$.
$$
\begin{array}{l}
\text{Thus, } f(x+y)-f(x)=f(x)-f(x-y) \\
\Rightarrow f(x+y)-f(x)=f(y)-f(0)=f(y)+1 \\
\Rightarrow f(x+y)=f(x)+f(y)+1 .
\end{array}
$$

Substitute into the original equation to get
$$
\begin{array}{l}
f(1)+f(x y)+1-f(x)-f(y)-1=f(x) f(y) \\
\Rightarrow f(x y)+1=(f(x)+1)(f(y)+1) .
\end{array}
$$

Let $g(x)=f(x)+1$. Then
$$
\begin{array}{l}
g(x+y)=g(x)+g(y), g(x y)=g(x) g(y) \\
\Rightarrow g(x)=x \Rightarrow f(x)=x-1 .
\end{array}
$$

Upon verification, $f(x)=x-1$ satisfies the requirements.