Use complex valued functions
for 
We want to solve the ODE
For the homogeneous problem we obtain the characteristic polynomial
syms p(r) % define symbolic variable r and function p(r)
p(r) = r^2+2*r+1
p(r) = 
Solving
gives solve(p(r)==0)
ans =

For the particular solution we use the method of undetermined coefficients:
Plugging this into the ODE gives two equations for
. We solve this linear system and obtain our particular solution. Alternative method using complex 
We use one complex number
and We have
We consider the complex-valued solution
of the ODE and find a particular solution
. Then will be a particular solution for
. Plugging
into
gives hence
C = (2-1i)/p(2i)
C =

yielding
Here is the solution of the ODE found by dsolve:
syms y(t) % define symbolic variable t and function y(t)
Dy = diff(y); D2y = diff(Dy);
sol = dsolve(D2y+2*Dy+y==2*cos(2*t)+sin(2*t));
simplify( sol , 1000)
ans =
