Question

# Find the general solution of y''-2y'+2y=xe^x cosx

Second order linear equations
Find the general solution of $$\displaystyle{y}{''}-{2}{y}'+{2}{y}={x}{e}^{{x}}{\cos{{x}}}$$

2020-10-21
$$\displaystyle{y}{''}-{2}{y}'+{2}{y}={x}{e}^{{x}}{\cos{{\left({x}\right)}}}.$$
Let $$\displaystyle{s}={\sin{{\left({x}\right)}}},{c}={\cos{{\left({x}\right)}}}$$, s'=c, c'=-s, then:
$$\displaystyle{y}{''}-{2}{y}'+{2}{y}={x}{e}^{{x}}{c}$$.
First solve the homogeneous equation: $$\displaystyle{y}{''}-{2}{y}'+{2}{y}={0}.$$
The characteristic equation is $$\displaystyle{r}^{{2}}-{2}{r}+{2}={0}={\left({r}-{1}+{i}\right)}{\left({r}-{1}-{i}\right)}.$$
So $$\displaystyle{y}={A}{e}^{{{\left({1}+{i}\right)}{x}}}+{B}{e}^{{{\left({1}-{i}\right)}{x}}}$$, which can be written:
$$\displaystyle{y}={e}^{{x}}{\left({A}{e}^{{{i}{x}}}+{B}{e}^{{-{i}{x}}}\right)},$$ where A and B are constants.
Use Euler’s expansion:
$$\displaystyle{y}={e}^{{x}}{\left({A}{\cos{{\left({x}\right)}}}+{A}{i}{\sin{{\left({x}\right)}}}+{B}{\cos{{\left({x}\right)}}}-{B}{i}{\sin{{\left({x}\right)}}}\right)},$$
$$\displaystyle{y}={e}^{{x}}{\left({\left({A}+{B}\right)}{\cos{{\left({x}\right)}}}+{i}{\left({A}-{B}\right)}{\sin{{\left({x}\right)}}}\right)}.$$
Let C=A+B and D=A-B, then:
$$\displaystyle{y}={e}^{{x}}{\left({C}{\cos{{\left({x}\right)}}}+{D}{\sin{{\left({x}\right)}}}\right)}.$$
Call this general solution $$\displaystyle{y}_{{1}}={e}^{{x}}{\left({C}{\cos{{\left({x}\right)}}}+{D}{\sin{{\left({x}\right)}}}\right)}={e}^{{x}}{\left({C}{c}+{D}{s}\right)}$$
Now we have to deal with xeˣc, the particular solution, which will give us y₂, such that the entire solution is $$\displaystyle{y}={y}_{{1}}+{y}_{{2}}$$.
We guess the solution, where P, Q, R and S are constants:
Let $$\displaystyle{u}={\left({P}{x}+{Q}\right)}{s}+{\left({R}{x}+{S}\right)}{c}$$ and apply the tentative solution $$\displaystyle{y}_{{2}}={x}{e}^{{x}}{u}$$:
$$\displaystyle{u}'={\left({P}{x}+{Q}\right)}{c}+{P}{s}-{\left({R}{x}+{S}\right)}{s}+{R}{c},$$
$$\displaystyle{u}{''}=-{\left({P}{x}+{Q}\right)}{s}+{2}{P}{c}-{\left({R}{x}+{S}\right)}{c}-{2}{R}{s},$$
$$\displaystyle{y}_{{2}}'={x}{e}^{{x}}{u}'+{u}{e}^{{x}}{\left({x}+{1}\right)},$$
$$\displaystyle{2}{\left({y}_{{2}}-{y}_{{2}}'\right)}=-{2}{e}^{{x}}{\left({x}{u}'+{u}\right)},$$
$$\displaystyle{y}_{{2}}{''}={x}{e}^{{x}}{u}{''}+{2}{u}'{e}^{{x}}{\left({x}+{1}\right)}+{u}{e}^{{x}}{\left({x}+{2}\right)},$$
$$\displaystyle{y}_{{2}}{''}-{2}{y}'+{2}{y}={e}^{{x}}{\left({x}{u}{''}+{2}{x}{u}'+{2}{u}'+{x}{u}+{2}{u}-{2}{x}{u}'-{2}{u}\right)}=$$
$$\displaystyle{e}^{{x}}{\left({x}{u}{''}+{2}{u}'+{x}{u}\right)}\equiv{x}{e}^{{x}}{c},{s}{o}{x}{u}{''}+{2}{u}'+{x}{u}\equiv{x}{c}.$$
Substitute for u and its derivatives:
$$\displaystyle{x}{u}{''}=-{x}{\left({P}{x}+{Q}\right)}{s}+{2}{P}{c}{x}-{x}{\left({R}{x}+{S}\right)}{c}-{2}{R}{s}{x},$$
$$\displaystyle{2}{u}'={2}{\left({P}{x}+{Q}\right)}{c}+{2}{P}{s}-{2}{\left({R}{x}+{S}\right)}{s}+{2}{R}{c},$$
$$\displaystyle{x}{u}={x}{\left({P}{x}+{Q}\right)}{s}+{x}{\left({R}{x}+{S}\right)}{c}.$$
Now add the three equations above:
$$\displaystyle{2}{\left({P}{x}+{Q}\right)}{c}-{2}{\left({R}{x}+{S}\right)}{s}+{2}{P}{c}{x}+{2}{P}{s}-{2}{R}{s}{x}+{2}{R}{c}=$$
$$\displaystyle{4}{P}{c}{x}+{2}{Q}{c}-{4}{R}{s}{x}-{2}{S}{s}+{2}{P}{s}+{2}{R}{c}\equiv{x}{c}.$$
Therefore, equating cx coefficients: $$\displaystyle{4}{P}={1},{P}=\frac{{1}}{{4}}.$$
Equating sx coefficients: R=0, implying:
$$\displaystyle{2}{Q}{c}-{2}{S}{s}+{2}{P}{s}={0}⇒{Q}={0},{S}={P},$$ so $$\displaystyle{S}=\frac{{1}}{{4}}.$$
Therefore $$\displaystyle{u}=\frac{{1}}{{4}}{\left({x}{s}+{c}\right)}=\frac{{1}}{{4}}{\left({x}{\sin{{\left({x}\right)}}}+{\cos{{\left({x}\right)}}}\right)},$$ making:
$$\displaystyle{y}_{{2}}=\frac{{1}}{{4}}{x}{e}^{{x}}{\left({x}{\sin{{\left({x}\right)}}}+{\cos{{\left({x}\right)}}}\right)},$$ and:
$$\displaystyle{y}={e}^{{x}}{\left({C}{\cos{{\left({x}\right)}}}+{D}{\sin{{\left({x}\right)}}}\right)}+\frac{{1}}{{4}}{x}{e}^{{x}}{\left({x}{\sin{{\left({x}\right)}}}+{\cos{{\left({x}\right)}}}\right)}.$$