How to solve $y′′′+y'=2-\sin(x)$ I have tried to solve this but with no luck.
So far I just get,
$$y_p(x) = A \sin x + B \cos x \\  
  y'_p(x) = A \cos x - B \sin x  \\
 y''_p(x) =-A \sin x - B \cos x  \\
y'''_p(x) =-A \cos x + B \sin x $$
$$y'''+ y' =  -A \cos x + B \sin x + A \cos x - B \sin x \\ \\ 
         =  \cos x (-A+A) + \sin x (B-B) = 2 - \sin x $$
I would really appreciate help in solving this
 A: Rewrite the equation as $$(D^3+D)y=2-\sin(x)$$
Differentiate twice to obtain
$$\begin{align}D^2(D^3+D)y&=\sin(x)\\
\implies (D^2+1)(D^3+D)y&=2\\
\implies D(D^2+1)(D^3+D)y=D^2(D^2+1)^2y&=0\end{align}$$
Which I leave to you to show has the solution
$$y=C_1+C_2x+(C_3+C_4x)\sin(x)+(C_5+C_6x)\cos(x)$$
Plug this back into the original equation to obtain
$$(D^3+D)y=y'''+y'=C_2-2C_4\sin(x)-2C_6\cos(x)=2-\sin(x)$$
Equating coefficients, we have $C_2=2,C_4=1/2,C_6=0$. Shifting the coefficients on $y$, we have that the general solution to the equation is
$$y=C_1+C_2\sin(x)+C_3\cos(x)+2x+\frac12x\sin(x)$$
A: Better than guessing the possible form of the solution is to use a more solid method. Consider the Laplace Transform of the differential equation (if you don't know it you can look at a table of Laplace Transforms):
$$\mathscr L\{y'''+y′=2−\sin x\}(s)=s^3Y(s)-s^2y(0)-sy'(0)-y''(0)+sY(s)-y(0) = \frac{2}{s}-\frac{1}{s^2+1}.$$
where $Y(s)$ is the laplace transform of $y(x)$. Then we have:
$$s^3Y(s)+sY(s)=\frac 2s - \frac 1{s^2+1}+s^2y(0)+sy'(0)+y''(0)+y(0)\\
\Longrightarrow Y(s)=\frac 2{s (s^3+s)}-\frac1{(s^2+1)(s^3+s)}+\frac{(s^2-1)y(0)}{s^3+s}+\frac{sy'(0)}{s^3+s}+\frac{y''(0)}{s^3+s}.$$
Here you have to use partial fractions and possible a table to look for the inverse of each term resulting from the partial fraction decomposition. This method will yield $y(x)$ by taking the inverse Laplace Transform of the last expression.
A: here is a way to why $x$'s are added. we will find a particular solution to $$y'' + y = \sin x \tag 1$$ the equation is forced by a solution of the homogeneous problem(called  the resonant case). first you look at a more general problem of the solution of 
$$y'' + y = \sin kx$$ a particular solution is $$y_p = \frac{\sin kx}{1-k^2}$$ so is $$y_p(x) = \frac{\sin kx - \sin x}{1-k^2}= -\frac{1}{1+k}\frac{\sin kx - \sin x}{k - 1} $$ in the limit as $k \to 1, $ we have 
$$y_p = -\frac{1}{2}\left( \frac{d}{dk}\sin kx \right)|_{k = 1} 
=-\frac{1}{2}x\cos x $$
you can see that a particular solution of $(1)$ is $$y_p = -\frac{1}{2}x\cos x. $$
