Given. A critically damped, constant-coefficient second-order ODE with cosine forcing and initial conditions $y(0)=2$, $y'(0)=0$.
Find. $y(t)$.
Approach. Solve the repeated-root homogeneous equation, find a particular solution by undetermined coefficients, then fix the two constants from the initial conditions.
Particular solution. Try $y_p=A\cos2t+B\sin2t$. Substituting, $y_p''+4y_p'+4y_p=8B\cos2t-8A\sin2t$. Matching to $\cos2t$ gives $8B=1$, $-8A=0$, so $A=0,\ B=\tfrac18$:
$$y_p=\tfrac18\sin2t.$$
General solution and initial conditions.
$$y(t)=(C_1+C_2t)e^{-2t}+\tfrac18\sin2t.$$
$y(0)=C_1=2$. Differentiating, $y'(t)=C_2e^{-2t}-2(C_1+C_2t)e^{-2t}+\tfrac14\cos2t$, so $y'(0)=C_2-2C_1+\tfrac14=0\Rightarrow C_2=2(2)-\tfrac14=\tfrac{15}{4}$.