Write the equation as (∗)
P(D)y = e2x cos(x),
where P(D) = D2 − 4D + 5. Note that e2xcos(x) is the real part of e(2+i)x, so we can solve (∗) by solving the complex equation
(♥) P(D)y = e(2+i)x
and then taking the real part. To solve equation (♥), move the exponential to the left side and rewrite the equation as
e−(2+i)xP(D)y = 1.
By the shifting rule, this is equivalent to
P(D + (2 + i))[e−(2+i)x y] = 1.
Set z = e−(2+i)x and calculate
P(D + (2 + i)) = (D + (2 + i))2 − 4(D + (2 + i)) + 5
= D2 + 2(2 + i)D + (2 + i)2 − 4(D + 2 + i) + 5
= D2 + (4 + 2i)D + 3 + 4i − 4d − 8 − 4i + 5
= D2 + 2iD.
Thus, the equation for z is (D2 + 2iD)z = 1.
Factor out a D and write this as
(D + 2i)[Dz] = 1.
Set w = Dz, so the equation for w is (D + 2i)w = 1.
Since the right-hand side is a polynomial of degree 0, we try a polynomial of degree 0, i.e., w = A, where A is a constant. Plugging into the equation gives 2iA = 1, so
w = 1/2i = − 1/2i.
Since Dz = w, integrating gives us
z = − 1/2ix.
Since z = e−(2+i)xy, we get y = − 1/2ixe(2+i)x .
This is a particular solution of equation (♥). To find the solution of equation (∗), we need to find the real part of y. We have

as a particular solution of (∗). To find the general solution of the homogeneous equation (D2− 4D + 5)y = 0, use the quadratic formula to find the roots of the characteristic polynomial λ2 − 4λ + 5. The roots are 2 ± i, so the general solution of the homogeneous equation is
