Example 4. Solve the equation $y^{\prime \prime}+9 y=e^{-x}(-\cos 3 x+$ $+(x+2) \sin 3 x)$.
Solution. $k^{2}+9=0, k= \pm 3 i$. Compare the right-hand side of the equation with $f(x)$ from Theorem 8. We have $P_{n}(x)=-1, n=0, Q_{m}(x)=x+2, m=1$, $s=\max (0,1)=1$, the numbers $\gamma \pm i \delta=-1 \pm 3 i$ are not roots of the characteristic equation. According to Theorem 4, point 1, we will have (when differentiating, similar terms are combined):

9: $y_{4}=(A x+B) e^{-x} \cos 3 x+(C x+D) e^{-x} \sin 3 x$;

0: $y_{4}^{\prime}=A e^{-x} \cos 3 x-(A x+B) e^{-x} \cos 3 x-3(A x+B) e^{-x} \sin 3 x+$ $+C e^{-x} \sin 3 x-(C x+D) e^{-x} \sin 3 x+3(C x+D) e^{-x} \cos 3 x$

1: $y_{4}^{\prime \prime}=-2 A e^{-x} \cos 3 x-6 A e^{-x} \sin 3 x-8(A x+B) e^{-x} \cos 3 x+$ $+6(A x+B) e^{-x} \sin 3 x-2 C e^{-x} \sin 3 x+6 C e^{-x} \cos 3 x-8(C x+$ $+D) e^{-x} \sin 3 x-6(C x+D) e^{-x} \cos 3 x$.

Below, at the beginning of each line, the similarity sign of the compared terms is recorded.

$$
\begin{gathered}
\left\{\begin{array} { l } 
{ x \operatorname { c o s } 3 x : 9 A - 8 A - 6 C = 0 , } \\
{ x \operatorname { s i n } 3 x : 9 C + 6 A - 8 C = 1 }
\end{array} \Rightarrow \left\{\begin{array} { l } 
{ A - 6 C = 0 , } \\
{ 6 A + C = 1 }
\end{array} \Rightarrow \left\{\begin{array}{l}
A=\frac{6}{37} \\
C=\frac{1}{37}
\end{array}\right.\right.\right. \\
\left\{\begin{array} { l } 
{ \operatorname { c o s } 3 x : 9 B - 2 A - 8 B + 6 C - 6 D = - 1 } \\
{ \operatorname { s i n } 3 x : 9 D - 6 A + 6 B - 2 C - 8 D = 2 }
\end{array} \Rightarrow \left\{\begin{array}{c}
B=\frac{641}{1369} \\
D=\frac{298}{1369}
\end{array}\right.\right.
\end{gathered}
$$

Answer. $y_{\text {p }}=C_{1} \cos 3 x+C_{2} \sin 3 x+$

$$
+\left[\left(\frac{6}{37} x+\frac{641}{1369}\right) \cos 3 x+\left(\frac{1}{37} x+\frac{298}{1369}\right) \sin 3 x\right] e^{-x}
$$