Example 1. Find the general solution of the linear differential equation

$$
y^{\prime}+y-k x=0
$$
Solution. The given equation is of the form (9.20), where $p(x)=1, q(x)=k x$. Let $y=u v$, then $y^{\prime}=u^{\prime} v+u v^{\prime}$. Substituting these expressions into the original equation, we get

$$
u^{\prime} v+u v^{\prime}+u v-k x=0 \text { or } u\left(v^{\prime}+v\right)+u^{\prime} v-k x=0
$$

We choose $v$ as one of the functions satisfying the equation

$$
v^{\prime}+v=0 \text { or } \frac{d v}{d x}+v=0
$$

Integrating this equation, we get

$$
\ln y=-x, y \equiv e^{-x}
$$

Rewriting equation (A) with (B) taken into account, we have:

$$
u^{\prime} v-k x=0 \text { or } \frac{d u}{d x} v-k x=0
$$

Substituting the value $v=e^{-x}$ here, we get

$$
d u-k x e^{x} d x=0
$$

Integrating the obtained equation, we find

$$
\begin{gathered}
u=\int k x e^{x} d x=k \int x d\left(e^{x}\right)=k\left[x e^{x}-\int e^{x} d x\right]= \\
=k x e^{x}-k e^{x}+C=k e^{x}(x-1)+C
\end{gathered}
$$

Substituting the expressions for $u, v$ into the formula $y=v u$.

$$
y=u v=e^{-x}\left[k e^{x}(x-1)+C\right]=k(x-1)+C e^{-x}
$$

Therefore, the general solution of the given differential equation is:

$$
y=k(x-1)+C e^{-x}
$$