General solution for ordinary differential equation $y'' + 9y = 18x + 36 \sin 3x$ Find a (real) general solution for
$$y'' + 9y = 18x + 36 \sin 3x$$
I need some help in finding the solution, have been struggling for long. My answer does not match with the final answer which is:
$$y_h = A\cos 3x + B\sin 3x $$
$$y_p = 2x - 6x\cos 3x$$
 A: Let $D$ stands for the differentiation operator. I mean, for example, $$\color{blue}{D}(x^2)=(x^2)\color{blue}{'}=2x,~~\color{blue}{D^2}{x^2}=(x^2)\color{blue}{''}=2$$ 


*

*It is not hard to see that $$D^2(18x)=0,~~(D^2+9)(36\sin 3x)=0$$ and so $$\color{red}{D^2(D^2+9)}(18x+36\sin 3x)=0$$

*We can use the operator $D$ to write the associated homogenous OE $y''+9y=0$ as follows: $$(D^2+9)y=0$$ which has the general solution $y_c=C_1\sin 3x+C_2\cos 3x$

*Therefore, according to the final results above and considering the original OE, we get:
$$\color{red}{D^2(D^2+9)}(D^2+9)y=0$$ So, $$y''+9y=18x+36\sin 3x\equiv D^2(D^2+9)^2y=0$$

  
*
  
*The differential operator $[D^2+9]^2$ annihilate any combination of the functions $$\sin 3x,~~x\sin 3x,~~\cos 3x,~~x\cos 3x$$ and $D^2$ does the same for the following functions: $$1,~~x$$ 
  

For a while, assume that you are given $D^2(D^2+9)^2y=0$ and asked to find the proper function $y$ in which the operator $D^2(D^2+9)$ annihilates it. Acording to above point we have $$(D^2+9)^2(C_1\sin 3x+C_2 \cos 3x+C_3x\sin 3x+C_4\cos 3x)=0,~~~D^2(C_4+C_5x)=0$$ So we, overall, have $$D^2(D^2+9)^2(C_1\sin 3x+C_2 \cos 3x+C_3x\sin 3x+C_4\cos 3x+C_4+C_5x)=0$$ Now, I think, you can select $y$ and $y_c$ and $y_p$ inside it from above latter result.
A: Given:
$$\tag 1 y'' + 9y = 18x + 36 \sin 3x$$
Homogeneous
$$m^2 +9 = 0 \rightarrow m_1 = 3i, m_2 = -3i$$
So,
$$y_h = A \cos 3x + B \sin 3x$$
Particular
Since we have a $\sin 3x$ term in the homogeneous solution, we will choose a particular solution:


*

*$y_p = a x + b x \cos 3x + c x \sin 3x$

*$y'_p = a + b \cos 3x + 3 c \cos 3x + c \sin 3x -3b \sin 3x$

*$y''_p = 6 c \cos 3x - 9b x \cos 3x-6 b \sin 3x - 9c x \sin 3x$


Substituting into $(1)$ yields:
$\tag 2 y''_p + 9y_p = 9~a x - 6 b ~\sin 3x + 6 c ~\cos 3x  = 18 x + 36 \sin 3x$
Equating terms yields:
$$a = 2, b = -6, c = 0$$
Our final solution:
$$y(x)= y_h + y_p = A \cos 3x + B \sin 3x + 2x -6 x \cos 3x$$
