y''-2y'+2y=xeˣcos(x).
Let s=sin(x), c=cos(x), s'=c, c'=-s, then:
y''-2y'+2y=xeˣc.
First solve the homogeneous equation: y''-2y'+2y=0.
The characteristic equation is r²-2r+2=0=(r-1+i)(r-1-i).
So y=Ae^((1+i)x)+Be^((1-i)x), which can be written:
y=eˣ(Ae^(ix)+Be^(-ix)), where A and B are constants.
Use Euler’s expansion:
y=eˣ(Acos(x)+Aisin(x)+Bcos(x)-Bisin(x)),
y=eˣ((A+B)cos(x)+i(A-B)sin(x)).
Let C=A+B and D=A-B, then:
y=eˣ(Ccos(x)+Dsin(x)).
Call this general solution y₁=eˣ(Ccos(x)+Dsin(x))=eˣ(Cc+Ds)
Now we have to deal with xeˣc, the particular solution, which will give us y₂, such that the entire solution is y=y₁+y₂.
We guess the solution, where P, Q, R and S are constants:
Let u=(Px+Q)s+(Rx+S)c and apply the tentative solution y₂=xeˣu:
u'=(Px+Q)c+Ps-(Rx+S)s+Rc,
u''=-(Px+Q)s+2Pc-(Rx+S)c-2Rs,
y₂'=xeˣu'+ueˣ(x+1),
2(y₂-y₂')=-2eˣ(xu'+u),
y₂''=xeˣu''+2u'eˣ(x+1)+ueˣ(x+2);
add the last two equations:
y₂''-2y'+2y=eˣ(xu''+2xu'+2u'+xu+2u-2xu'-2u)=
eˣ(xu''+2u'+xu)≡xeˣc, so xu''+2u'+xu≡xc.
Substitute for u and its derivatives:
xu''=-x(Px+Q)s+2Pcx-x(Rx+S)c-2Rsx;
2u'=2(Px+Q)c+2Ps-2(Rx+S)s+2Rc;
xu=x(Px+Q)s+x(Rx+S)c.
Now add the three equations above:
2(Px+Q)c-2(Rx+S)s+2Pcx+2Ps-2Rsx+2Rc=
4Pcx+2Qc-4Rsx-2Ss+2Ps+2Rc≡xc.
Therefore, equating cx coefficients: 4P=1, P=¼.
Equating sx coefficients: R=0, implying:
2Qc-2Ss+2Ps=0⇒Q=0, S=P, so S=¼.
Therefore u=¼(xs+c)=¼(xsin(x)+cos(x)), making:
y₂=¼xeˣ(xsin(x)+cos(x)), and:
y=eˣ(Ccos(x)+Dsin(x))+¼xeˣ(xsin(x)+cos(x)).