Solution (source code)

= Solution

The <repeated-root constant-coefficient differential equation> has characteristic polynomial $(r+2)^2$. Its two fundamental solutions are
$$
\boxed{y_1=e^{-2x},\qquad y_2=xe^{-2x}}.
$$
They are <linearly independent>: their <Wronskian> is $e^{-4x}$, which never vanishes. For the forced equation, exploit the repeated factor by writing $y=e^{-2x}u$. Direct differentiation gives $(D+2)^2y=e^{-2x}u''$, so the forcing reduces to $u''=1$. The initial data imply $u(0)=0$ and $u'(0)=0$, hence $u=x^2/2$. Therefore
$$
\boxed{y(x)=\frac{x^2}{2}e^{-2x},\qquad x\geq0}.
$$
The extra factor $x^2$ reflects resonance of the forcing with the repeated characteristic root; the exponential substitution obtains it without guessing a particular solution.