Example 1. Solve the differential equation

$$
(\sin x y+x y \cos x y) d x+x^{2} \cos x y d y=0
$$
Solution. Let's check that the given equation is an equation in total differentials:

$$
\begin{aligned}
\frac{\partial M}{\partial y} & =\frac{\partial}{\partial y}(\sin x y+x y \cos x y)= \\
& =x \cos x y+x \cos x y-x^{2} y \sin x y=2 x \cos x y-x^{2} y \sin x y \\
\frac{\partial N}{\partial x} & =\frac{\partial}{\partial x}\left(x^{2} \cos x y\right)=2 x \cos x y-x^{2} y \sin x y
\end{aligned}
$$

so that

$$
\frac{\partial M}{\partial y} \equiv \frac{\partial N}{\partial x}
$$

i.e., condition (2) is satisfied. Thus, the given equation is an equation in total differentials and

$$
M=\frac{\partial u}{\partial x}=\sin x y+x y \cos x y, \quad N=\frac{\partial u}{\partial y}=x^{2} \cos x y
$$

therefore

$$
u(x, y)=\int(\sin x y+x y \cos x y) d x+\varphi(y)
$$

where $\varphi(y)$ is an as yet undetermined function.

Integrating, we get

$$
u(x, y)=x \sin x y+\varphi(y)
$$

The partial derivative $\frac{\partial u}{\partial y}$ of the found function $u(x, y)$ should equal $x^{2} \cos x y$, which gives

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

from which $\varphi^{\prime}(y)=0$, so $\varphi(y)=C$. Thus

$$
u(x, y)=x \sin x y+C
$$

The general integral of the original differential equation is

$$
x \sin x y=C
$$

When integrating some differential equations, the terms can be grouped in such a way that easily integrable combinations are obtained.