Example 4. Integrate the equation

$$
x(x+2 y) d x+\left(x^{2}-y^{2}\right) d y=0
$$
Solution. In this case

$$
P(x, y)=x(x+2 y), Q(x, y)=x^{2}-y^{2}
$$

from which

$$
\frac{\partial P}{\partial y}=2 x, \frac{\partial Q}{\partial x}=2 x
$$

Condition (9.34) is satisfied, so the given equation is an equation in total differentials. Therefore,

$$
\frac{\partial u}{\partial x}=x^{2}+2 y x, \frac{\partial u}{\partial y}=x^{2}-y^{2}
$$

From the first equality, we obtain

$$
u(x, y)=\int\left(x^{2}+2 x y\right) d x
$$

or

$$
u(x, y)=\frac{x^{3}}{3}+x^{2} y+\varphi(y)
$$

Differentiating the function $u(x, y)$ with respect to $y$, we find

$$
\frac{\partial u}{\partial y}=x^{2}+\varphi^{\prime}(y)
$$

Since

$$
\frac{\partial u}{\partial y}=x^{2}-y^{2}
$$

then

$$
x^{2}+\varphi^{\prime}(y)=x^{2}-y^{2}
$$

from which

$$
\varphi^{\prime}(y)=-y^{2}
$$

and

$$
\varphi(y)=-\int y^{2} d y=-\frac{y^{3}}{3}+C_{1}
$$

Substituting the found expression for $\varphi(y)$ into the formula for $u(x, y)$, we get

$$
u(x, y)=\frac{x^{3}}{3}+x^{2} y-\frac{y^{3}}{3}+C_{1}=C_{2}
$$

or

$$
\frac{x^{3}}{3}+x^{2} y-\frac{y^{3}}{3}=C_{3}
$$

Thus, the general integral can be written in the form

$$
x^{3}+3 x^{2} y-y^{3}=C, \text { where } C=3 C_{3}
$$