The method of undetermined coefficients will only work for a fairly small class of functions. More specifically, the inhomogeneous term (the right side) must be an exponential, polynomial, sine or cosine, or a combination of these. Also, it is generally only useful for constant coefficient DEs.

The method of variation of parameters is a more general method that can be used for many more cases, although it is a messier process. (I don't want to mislead you by saying it works in all cases, just in case there is some exception outside the scope of this course)