Example 2. Find the general solution of the equation

$$
y^{\prime \prime}-y^{\prime}-2 y=e^{2 x}
$$
Solution. The characteristic equation

$$
k^{2}-k-2=0
$$

has roots $k_{1}=2, k_{2}=-1$, so the general solution of the homogeneous equation

$$
y^{\prime \prime}-y^{\prime}-2 y=0
$$

is given by the formula $y_{0}=C_{1} e^{2 x}+C_{2} e^{-x}$.

The function $f(x)=e^{2 x}$ is obtained from formula (10.23) when $a=1$, $m=2$. Since $m=2$ is a simple root of the characteristic equation, according to formula (10.25), we look for a particular solution in the form

$$
\bar{y}=A x e^{2 x} .
$$

Substituting into the original equation the expressions for $\bar{y}, \bar{y}^{\prime}, \bar{y}^{\prime \prime}$, where

$$
\bar{y}^{\prime}=A e^{2 x}+2 A x e^{2 x}, \bar{y}^{\prime \prime}=4 A e^{2 x}+4 A x e^{2 x}
$$

we get

$$
\left(4 A e^{2 x}+4 A x e^{2 x}\right)-\left(A e^{2 x}+2 A x e^{2 x}\right)-2 A x e^{2 x} \equiv e^{2 x}, 3 A e^{2 x} \equiv e^{2 x}
$$

from which $3 A=1, A=\frac{1}{3}$. Therefore, $\bar{y}=\frac{1}{3} x e^{2 x}$.

Based on formula (10.21), we obtain the general solution

$$
y=C_{1} e^{2 x}+C_{2} e^{-x}+\frac{1}{3} x e^{2 x}
$$