TITLE: Why don't the roots of this characteristic equation correspond to the given solution of this 2nd order ODE?
QUESTION [6 upvotes]: I am asked to solve
$$ y'' + 9y = 6\mathrm{sin}(3x) $$
using the method of undetermined coefficients.
The characteristic equation of this 2nd order ODE is
$$ \lambda^2 + 9\lambda = 0 $$
and its roots are $0$ and $-9$. These are both real and different, so the general solution of the homogenous equation ought to be
$$ y = c_1e^{0x} + c_2e^{-9x} $$
which is the same as
$$ y = c_1 + c_2e^{-9x} $$
In my table of reasonable guesses for the particular solution of the inhomogenous equation, it says that for output functions of the form $\textrm{sin}(\beta x)$, $\textrm{cos}(\beta x)$, the particular solution will be of the form
$$ y_p = A\cdot\textrm{sin}(\beta x) + B\cdot\textrm{cos}(\beta x) $$
if $i \beta$ is not a root of the characteristic equation, and
$$ y_p = x\left[ A\cdot\sin(\beta x) + B\cdot\textrm{cos}(\beta x) \right] $$
if $i \beta$ is a root of the characteristic equation.
So, given our output function $6\sin(3x) $, $\beta = 3$, and if we test it, substituting $3i$ in the characteristic equation, we get
$$(3i)^2 + 9(3i) = -9 + 27i \neq 0 $$
so it seems clear that $i \beta$ is not a root, and so I expect that the particular solution would be of the form
$$ y_p = A\cdot\textrm{sin}(3x) + B\cdot\textrm{cos}(3x) $$
Except that it's not, and it wasn't until someone told me to try substituting the output function in the ODE that I realized this. Only $ y_p = x\left[ A\cdot\sin(\beta x) + B\cdot\textrm{cos}(\beta x) \right] $ works. Is my formulary wrong, or have I misunderstood something here?
Using $ y_p = x\left[ A\cdot\sin(\beta x) + B\cdot\textrm{cos}(\beta x) \right] $ as the reasonable guess, the particular solution turns out to be $-x\cos 3x$.
So the general solution should be
$$ y = c_1 + c_2e^{-9x} -x\cos 3x $$
but when I try solving this ODE with various tools, I get
$$ y = c_1\cos(3x) + c_2\sin(3x) -x\cos(3x) $$
which I do not understand. The characteristic equation has, as near as I can tell, real (and distinct) roots, so why are there trigonometric identities in the solution to the homogeneous equation? More generally, where have I gone wrong here?

REPLY [3 votes]: As other answers noted, you made a mistake while writing the auxiliary equation. In fact, it would suggest you to take $$y_p(x)=Ax\sin(3x)+Bx\cos(3x)$$ instead.