Arriving at a particular solution of the ODE $y''-2y'-2y=\sin x$
Solution 1:
In principle your approach is correct, but the parametrization is wrong, especially where you use $p(-1)$. The operator polynomial $p(D)$ needs to be split into even and odd parts as $p(D)=p_e(D^2)+Dp_o(D^2)$ to isolate the squares of $D$ so that then you can transform under $(D^2+1)\sin(x)=0$ as $$ \frac1{p(D)}=\frac1{p_e(-1)+Dp_o(-1)} =\frac{p_e(-1)-Dp_o(-1)}{p_e(-1)^2-D^2p_o(-1)^2} =\frac{p_e(-1)-Dp_o(-1)}{p_e(-1)^2+p_o(-1)^2} $$ For $p(x)=x^2-2x-2$ one has $p_e(u)=u-2$ and $p_o(u)=-2$, so that the last fraction becomes $$ \frac{-3+2D}{(-3)^2+(-2)^2}=\frac{2D-3}{13}. $$