First solve y"+4y=0 which has the solution yc=Ae2ix+Be-2ix where yc is the characteristic solution. We need yp, the particular solution. We know it must contain e2ix which is just a special case of yc, so it cannot be in this form, otherwise we would end up with zero on the right side of the DE instead of e2ix. So let yp=axe2ix, where a is another constant, which this time needs to be evaluated. From this, yp'=ae2ix+2aixe2ix, yp"=4aie2ix-4axe2ix.
Therefore: yp"+4yp=4aie2ix-4axe2ix+4axe2ix≡e2ix. Therefore:
4aie2ix=e2ix and 4ai=1, -4a=i, a=-i/4 so yp=-ixe2ix/4.
y=yc+yp=Ae2ix+Be-2ix-ixe2ix/4.
e2ix=cos(2x)+isin(2x), e-2ix=cos(2x)-isin(2x).
Therefore, y=(A+B)cos(2x)+i(A-B)sin(2x)-¼ix(cos(2x)+isin(2x))=
(A+B)cos(2x)+i(A-B)sin(2x)-¼ixcos(2x)+¼xsin(2x).
We can replace A+B and i(A-B) with P and Q (which can be complex constants):
y=f(x)=(P-¼ix)cos(2x)+(Q+¼x)sin(2x).