On my lecture material on solving non-homogeneous differential equations, I have a chart that I'm supposed to consult that tells me the the form of the attempt-particular solution. For example: If the differential equation is of the form $y''+ay'+by=sin(kx),$, my particular solution takes the form $Acos(kx)+Bsin(kx)$ if the characteristic polynomial $P(ik) \neq 0$. If the $P(ik) =0$, then the particular solution takes the form $Axcos(kx)+Bxsin(kx)$.
Why is this result true in general? I can see after doing some examples that I don't find a solution with the first form if the characteristic polynomial has the complex root involving $k$, but can we show in a simple manner why this is true, and why the addition of $x$ to the form fixes the situation?
Also, there is another curiosity: If the differential equation is of the form $y''+ay'+by=e^{kx}$,the attempted particular solution involves $Ae^{kx}$ if $P(k)\neq 0$, $Axe^{kx}$ if $P(k)=0$ but $P'(k)\neq0$, and $Ax^2e^{kx}$ if $P(k)=P'(k)=0$. Again, I can see from problem examples that these attempted solution forms do work, but what is the reason behind it?
So to summarize: Can we show, preferably by using the properties of the characteristic equation, the reasons why we don't find solutions when the characteristic equation or its derivatives take on certain values?