1.) (D^2+1)=cosx
2.) y"-3y'-4y=16x-50cos2x
The general solutions to these take the form of the general solution to the corresponding homogeneous equation plus a particular integral of the non homogeneous equation.
I will presume that you know how to solve the homogeneous equations (which is what I presume your first equation id supposed to be) and
For the first, as is a solution of the homogeneous equation we try a trial solution
For the second we try a trial solution of the form
RonL