Example 4.24. Find the general solution of the equation

$$
y^{\prime \prime}+4 y=12 \cos 2 x
$$
Solution. 1. First, let's find $\bar{y}$. The characteristic equation $r^{2}+4=0$ has roots $r_{1,2}= \pm 2 i$. Therefore,

$$
\bar{y}=C_{1} \cos 2 x+C_{2} \sin 2 x
$$

2. Now, we proceed to finding $y^{*}$. Here, the right-hand side $f(x)$ has the form (4): $a=12, b=0, \lambda= \pm 2 i$. Since the numbers $\pm 2 i$ are roots of the characteristic equation, the particular solution should be sought in the form

$$
y^{*}=x(A \cos 2 x+B \sin 2 x)
$$

where $A$ and $B$ are undetermined coefficients. We have

$$
\begin{gathered}
y^{*}=A \cos 2 x+B \sin 2 x+x(-2 A \sin 2 x+2 B \cos 2 x), \\
y^{*}=-2 A \sin 2 x+2 B \cos 2 x+(-2 A \sin 2 x+2 B \cos 2 x)+ \\
+x(-4 A \cos 2 x-4 B \sin 2 x)
\end{gathered}
$$

Substituting $y^{* \prime}$ and $y^{*^{\prime \prime}}$ into the given equation and combining like terms, we get

$$
4 B \cos 2 x-4 A \sin 2 x=12 \cos 2 x
$$

from which

$$
\begin{aligned}
4 B & =12, \\
-4 A & =0
\end{aligned}
$$

i.e., $A=0, B=3$. Therefore,

$$
y^{*}=3 x \sin 2 x
$$

Thus, the general solution is

$$
y=\bar{y}+y^{*}=C_{1} \cos 2 x+C_{2} \sin 2 x+3 x \sin 2 x
$$