2. Find all functions $f: \mathbf{R} \rightarrow \mathbf{R}$, such that for each pair of real numbers $(x, y)$, we have
$$
f\left(x+y^{2}\right)=f(x)+|y f(y)| .
$$
2. First, prove that $f$ is non-decreasing.

Let any real numbers $r, s$ satisfy $r \geqslant s, t=\sqrt{r-s}$. Then $f(r)=f\left(s+t^{2}\right)=f(s)+|t f(t)| \geqslant f(s)$.
In the original equation, let $x=0$. Then
$$
f\left(y^{2}\right)-f(0)=|y f(y)| \text {. }
$$

For any real number $a$, define $g(a)=f(a)-f(0)$, then for any real number $y$, we have
$$
g\left(y^{2}\right)=|y f(y)| .
$$

From $f\left(x+y^{2}\right)-f(x)=g\left(x+y^{2}\right)-g(x)$, we know $g\left(x+y^{2}\right)-g(x)=|y f(y)|=g\left(y^{2}\right)$.
Therefore, for any non-negative real numbers $z, t$, we have
$$
g(z+t)=g(z)+g(t) \text {. }
$$

Thus, $g$ satisfies the Cauchy functional equation for non-negative real numbers.

Since the function $f$ is non-decreasing, the function $g$ is also non-decreasing.

Therefore, for non-negative real numbers $x, g(x)$ is linear, i.e., there exists $c \geqslant 0$, such that for all $x \geqslant 0$, we have
$$
g(x)=c x \text {. }
$$

Therefore, for all $x \geqslant 0$, we have
$$
f(x)=c x+f(0) \text {. }
$$

Substituting this into equation (1) gives
$$
c y^{2}=\left|c y^{2}+f(0) y\right| \text {. }
$$

Let $y=1$, we get
$$
c=|c+f(0)| \text {; }
$$

Let $y=2$, and divide both sides of the equation by 4, we get
$$
c=\left|c+\frac{f(0)}{2}\right| \text {. }
$$

From $|c+f(0)|=\left|c+\frac{f(0)}{2}\right|$, we know
$$
f(0)=\frac{f(0)}{2} \text { or } c+f(0)=-\left(c+\frac{f(0)}{2}\right) \text {, }
$$

i.e., $f(0)=0$ or $2 c+\frac{3 f(0)}{2}=0$.
Thus, $f(0)=0$ or $-\frac{4}{3} c$.
Substituting $f(0)=-\frac{4}{3} c$ into equation (2) gives
$$
c=\left|c-\frac{4}{3} c\right| \Rightarrow c=0 \Rightarrow f(0)=0 .
$$

Therefore, in both cases, we get $f(0)=0$, and for all $x \geqslant 0$, we have $f(x)=c x$.
Next, prove that for all real numbers $y, f(y)=c y$.
Since $f(0)=0$, we have
$$
f\left(y^{2}\right)=|y f(y)| \text {, }
$$

where $y$ is any real number.
For any $y<0$, we have
$$
c y^{2}=f\left(y^{2}\right)=|y f(y)| \text {. }
$$

This indicates that $c \geqslant 0,|f(y)|=-c y$.
Thus, $f(y)=c y$ or $-c y$.
If $f(y)=c y$, the conclusion holds.
If there exists $y<0$ such that $f(y)=-c y$, then
$$
-c y=f(y) \leqslant f(0)=0 \leqslant-c y \text {. }
$$

Thus, $0=-c y$, i.e., $c=0$.
Therefore, $f(y)=0$.
Thus, for all real numbers $y$, we have $f(y)=c y$.
For any $c \geqslant 0$, we have
$$
f\left(x+y^{2}\right)=c x+c y^{2}=f(x)+|y f(y)| \text {. }
$$

Therefore, the solution to the original equation is $f(x)=c x$, where $c$ is any non-negative real number.