Example 2. Solve the equation $\frac{d y}{d x}=\frac{1}{x \cos y+\sin 2 y}$.
Solution. The given equation is linear if we consider $x$ as a function of $y$:

$$
\frac{d x}{d y}-x \cos y=\sin 2 y
$$

We apply the method of variation of arbitrary constants. First, we solve the corresponding homogeneous equation

$$
\frac{d x}{d y}-x \cos y=0
$$

which is a separable variable equation. Its general solution is

$$
x=C e^{\sin y}, \quad C=\text { const. }
$$

We seek the general solution of equation (4) in the form

$$
x=C(y) e^{\sin y}
$$

where $C(y)$ is an unknown function of $y$. Substituting (5) into (4), we get

$$
C^{\prime}(y) e^{\sin y}+C(y) e^{\sin y} \cos y-C(y) e^{\sin y} \cos y=\sin 2 y
$$

or

$$
C^{\prime}(y)=e^{-\sin y} \sin 2 y
$$

From this, integrating by parts, we have

$$
\begin{aligned}
& C(y)=\int e^{-\sin y} \sin 2 y d y=2 \int e^{-\sin y} \cos y \sin y d y= \\
& =2 \int \sin y d\left(-e^{-\sin y}\right)=2\left(-\sin y e^{-\sin y}+\int e^{-\sin y} \cos y d y\right)= \\
& =2\left(-\sin y e^{-\sin y}-e^{-\sin y}\right)+C
\end{aligned}
$$

Thus,

$$
C(y)=-2 e^{-\sin y}(1+\sin y)+C .
$$

Substituting (6) into (5), we obtain the general solution of equation (4), and hence of the given equation:

$$
x=C e^{\sin y}-2(1+\sin y) . \quad \Delta
$$

Equation (1) can also be integrated as follows. We assume

$$
y=u(x) v(x)
$$

where $u(x)$ and $v(x)$ are unknown functions of $x$, one of which, for example $v(x)$, can be chosen arbitrarily. Substituting (7) into (1), after transformation we get

$$
v u^{\prime}+\left(p v+v^{\prime}\right) u=q(x) .
$$

Defining $v(x)$ from the condition $v^{\prime}+p v=0$, we then find from (8) the function $u(x)$, and consequently, the solution $y=u v$ of equation (1). As $v(x)$, we can take any particular solution of the equation $v^{\prime}+p v=0, v \not \equiv$.