The rule here is that functions that show up in the homogeneous solution (that is, the differential equation LHS = 0), need to be "enhanced" in order not to be annihilated by the LHS's operator when you plug it into the DE. Notice that in your second yp, there's an x multiplying the exponential. That's because in that case, the exponential is already a part of the homogeneous solution. In the first problem, the trig functions are both in the homogeneous solution. Make sense?