Theorem: Linear Second Order ODE/y'' + 2 y' + 5 y = x sin x

The second order ODE:
:$(1): \quad y'' + 2 y' + 5 y = x \sin x$
has the general solution:
:$y = e^{-x} \paren {C_1 \cos 2 x + C_2 \sin 2 x} + \ldots$

Proof:
It can be seen that $(1)$ is a nonhomogeneous linear second order ODE in the form:
:$y'' + p y' + q y = \map R x$
where:
:$p = 2$
:$q = 5$
:$\map R x = x \sin x$
First we establish the solution of the corresponding constant coefficient homogeneous linear second order ODE:
:$y'' + 2 y' + 5 y = 0$
From Linear Second Order ODE: $y'' + 2 y' + 5 y = 0$, this has the general solution:
:$y_g = e^{-x} \paren {C_1 \cos 2 x + C_2 \sin 2 x}$
It remains to find a particular solution $y_p$ to $(1)$.
We have that:
:$\map R x = x e^{-x}$
and so from the Method of Undetermined Coefficients for Product of Polynomial and Function of Sine and Cosine, we assume a solution:
{{begin-eqn}}
{{eqn | l = y_p
      | r = \paren {A_1 \sin x + A_2 \cos x} \paren {B_1 x + B_2}
      | c = 
}}
{{eqn | ll= \leadsto
      | l = {y_p}'
      | r = \paren {A_1 \cos x - A_2 \sin x} \paren {B_1 x + B_2} + B_1 \paren {A_1 \sin x + A_2 \cos x}
      | c = 
}}
{{eqn | ll= \leadsto
      | l = {y_p}''
      | r = \paren {-A_1 \sin x - A_2 \cos x} \paren {B_1 x + B_2} + B_1 \paren {A_1 \cos x - A_2 \sin x} + B_1 \paren {A_1 \cos x - A_2 \sin x}
      | c = 
}}
{{eqn | r = \paren {-A_1 \sin x - A_2 \cos x} \paren {B_1 x + B_2} + 2 B_1 \paren {A_1 \cos x - A_2 \sin x}
      | c = 
}}
{{end-eqn}}
Substituting in $(1)$:
{{begin-eqn}}
{{eqn | o = 
      | r = \paren {-A_1 \sin x - A_2 \cos x} \paren {B_1 x + B_2} + 2 B_1 \paren {A_1 \cos x - A_2 \sin x}
      | c = 
}}
{{eqn | o = 
      | ro= +
      | r = 2 \paren {\paren {A_1 \cos x - A_2 \sin x} \paren {B_1 x + B_2} + B_1 \paren {A_1 \sin x + A_2 \cos x} }
      | c = 
}}
{{eqn | o = 
      | ro= +
      | r = 5 \paren {\paren {A_1 \sin x + A_2 \cos x} \paren {B_1 x + B_2} }
      | c = 
}}
{{eqn | r = x \sin x
      | c = 
}}
{{eqn | ll= \leadsto
      | o = 
      | r = x \sin x \paren {-A_1 B_1 - 2 A_2 B_1 + 5 A_1 B_1}
      | c = 
}}
{{eqn | o = 
      | ro= +
      | r = x \cos x \paren {-A_2 B_1 + 2 A_1 B_1 + 5 A_2 B_1}
      | c = 
}}
{{eqn | o = 
      | ro= +
      | r = \sin x \paren {-A_1 B_2 - 2 A_2 B_1 - 2 A_2 B_2 + 2 A_1 B_1 + 5 A_1 B_2}
      | c = 
}}
{{eqn | o = 
      | ro= +
      | r = \cos x \paren {-A_2 B_2 + 2 A_1 B_1 + 2 A_1 B_2 + 2 A_2 B_1 + 5 A_2 B_2}
      | c = 
}}
{{eqn | r = x \sin x
      | c = 
}}
{{eqn | n = 2
      | ll= \leadsto
      | o = 
      | r = x \sin x \paren {4 A_1 B_1 - 2 A_2 B_1}
      | c = 
}}
{{eqn | o = 
      | ro= +
      | r = x \cos x \paren {4 A_2 B_1 + 2 A_1 B_1}
      | c = 
}}
{{eqn | o = 
      | ro= +
      | r = \sin x \paren {4 A_1 B_2 - 2 A_2 B_1 - 2 A_2 B_2 + 2 A_1 B_1}
      | c = 
}}
{{eqn | o = 
      | ro= +
      | r = \cos x \paren {4 A_2 B_2 + 2 A_1 B_1 + 2 A_1 B_2 + 2 A_2 B_1}
      | c = 
}}
{{eqn | r = x \sin x
      | c = 
}}
{{end-eqn}}
Hence by equating coefficients:
{{begin-eqn}}
{{eqn | l = 4 A_1 B_1 - 2 A_2 B_1
      | r = 1
      | c = 
}}
{{eqn | l = 4 A_2 B_1 + 2 A_1 B_1
      | r = 0
      | c = 
}}
{{eqn | l = 4 A_1 B_2 - 2 A_2 B_1 - 2 A_2 B_2 + 2 A_1 B_1
      | r = 0
      | c = 
}}
{{eqn | l = 4 A_2 B_2 + 2 A_1 B_1 + 2 A_1 B_2 + 2 A_2 B_1
      | r = 0
      | c = 
}}
{{end-eqn}}
{{finish|possibly the least fun you can have while doing mathematics}}
So from General Solution of Linear 2nd Order ODE from Homogeneous 2nd Order ODE and Particular Solution:
:$y = y_g + y_p = e^{-x} \paren {C_1 \cos 2 x + C_2 \sin 2 x} + \ldots$