This is the same as:
y"+y=e-x+cos(x)+x3+exsin(x).
First consider the general (characteristic) solution of y"+y=0, which is yc=Acos(x)+Bsin(x).
To find the particular solution we need to work out how each term on the RHS can be produced.
For example, if y1=aexcos(x)+bexsin(x),
y1'=-aexsin(x)+aexcos(x)+bexcos(x)+bexsin(x)=ex(cos(x)(a+b)+sin(x)(b-a)),
y1"=ex(-sin(x)(a+b)+cos(x)(b-a))+ex(cos(x)(a+b)+sin(x)(b-a))=
ex(cos(x)(b-a+a+b)+sin(x)(-a-b+b-a))=ex(2bcos(x)-2asin(x))
But y1"+y1=ex(2bcos(x)-2asin(x))+aexcos(x)+bexsin(x)=ex(cos(x)(2b+a)+sin(x)(-2a+b)).
To arrive at exsin(x) in the DE, -2a+b=1 and 2b+a=0, which can be written 2a+4b=0. Add the two equations: 5b=1, b=⅕, a=-2b=-⅖.
This makes y1=-⅖excos(x)+⅕exsin(x).
We now have to consider three other terms e-x+cos(x)+x3. This is a heterogeneous set of terms.
Let y2=ce-x, y2'=-ce-x, y2"=ce-x; y2"+y2=2ce-x, so 2c=1, c=½, y2=½e-x.
Let y3=a1x+a2x2+a3x3, y3'=a1+2a2x+3a3x2, y3"=2a2+6a3x; y3"+y3=2a2+6a3x+a1x+a2x2+a3x3⇒a3=1; a2=0; 6a3+a1=0⇒a1=-6.
Therefore y3=-6x+x3.
This leaves cos(x). Let y4=dxsin(x), y4'=dxcos(x)+dsin(x), y4"=-dxsin(x)+dcos(x)+dcos(x)=-dxsin(x)+2dcos(x);
y4"+y4'=-dxsin(x)+2dcos(x)+dxsin(x)=2dcos(x). When d=½, y4"+y4'=cos(x), and y4=½xsin(x)
Therefore we have the (verified) solution, where A and B are constants:
y=yc+y1+y2+y3+y4=Acos(x)+Bsin(x)-⅖excos(x)+⅕exsin(x)+½e-x-6x+x3+½xsin(x).