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

Theorem
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:

Substituting in $(1)$:

Hence by equating coefficients:

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$