# Find the general solution of $y'' − 2y' + 5y = e^x \cos(2x)$

I've racked my head against this for hours. Finding the complementary solution (homogenous solution) is fairly simple and I got $$y_c = e^x[ C_1\sin(2x)+ C_2\cos(2x) ].$$

But I am stuck on finding the particular solution to complete the general solution.

I tried the undetermined coefficient approach but everything would keep cancelling out and I would get a 0 on one side.

• What techniques do you know for finding particular solutions when the inhomogeneous part is of the same form as the solution to the homogeneous part? – Kitter Catter Aug 16 at 3:13
• You can make the problem simpler via the substitution $z = e^x y$. The basic issue will remain, though: The inhomogeneous part of your equation is itself a solution to the homogeneous equation. – Semiclassical Aug 16 at 3:13
• @kittercatter I don't know any special technique for that. I just tried undetermined coefficient and variation of parameter. – Meraj Haq Aug 16 at 3:23
• @MerajHaq I think variation of parameters should get you there, maybe need an ansatz or guess to get things correct. Could you update your question with your variation of parameter attempt? – Kitter Catter Aug 16 at 3:30
• @kittercatter I tried variation of parameters. Unless I made a mistake I did not get the answer. Which is supposed to be y = (1/4)xe^xsin(2x) +yc. – Meraj Haq Aug 16 at 3:38

Use undetermined coefficients

I think your supposed to let $$y_p=Axe^{x}cos(2x)+bxe^{x}sin(2x)$$

then take $$y'(p)$$ and $$y"(p)$$ plug em in for $$y"(p)+2y'(p)+y(p)$$ and solve for $$A and B$$ to find particular solution

But taking all these derivatives would be an extreme hassle.

After simplifying $$y"(p)+2y'(p)+y(p)=e^xcos(2x)$$ I end up with

$$4Be^xcos2x-4Ae^xsin(2x)=e^xcos(2x)$$

So $$4B=1$$ and $$A=0$$ then $$y_p=\frac{1}{4}xe^xsin(2x)$$

Remember product rule for three functions is $$(fgh)'=f'gh+fg'h+fgh'$$

Also remember to multiply an $$x$$ to the guess for the form of the particular solution since the normal guess of $$y_p=Ae^{x}cos(2x)+be^{x}sin(2x)$$ appears in the complementary solution.

• thanks for the answer but I tried this. Unless I made a mistake everything cancels out when plugging in so it does not work. – Meraj Haq Aug 16 at 3:58
• Use \sin and \cos (MathJax tutorial) – gen-z ready to perish Aug 16 at 4:27
• @MerajHaq given that the inhomogeneous piece has the same form as the solution to the homogeneous diff-eq a natural ansatz/guess is to add $x$ to the front. en.wikipedia.org/wiki/… see that last sentence – Kitter Catter Aug 16 at 14:25

$$y'' − 2y' + 5y = e^x \cos(2x)\implies (D^2-2D+5)y=e^x \cos(2x)\qquad \text{where}\quad D\equiv \frac{d}{dx}$$

For particular integral (P.I.),

P.I.$$~=\frac{1}{D^2-2D+5}~e^x \cos(2x)$$

$$~~~~~~~= ~e^x~\frac{1}{(D+1)^2-2(D+1)+5}~\cos(2x)$$

$$~~~~~~~= ~e^x~\frac{1}{D^2+4}~\cos(2x)$$

$$~~~~~~~=~\frac{x}{4}~e^x~\sin(2x)$$

So the general solution is $$y(x)= e^x[ C_1\sin(2x)+ C_2\cos(2x) ]~+~\frac{x}{4}~e^x~\sin(2x)\qquad \text{where}\quad C_1,~C_2~\text{are constants.}$$

Note$$~ 1:$$

For the Particular Integral (i.e., P.I.) there are some general rules

$$1.$$ $$\frac{1}{D + a} \phi (x) = e^{-ax}\int e^{ax}\phi(x)$$

$$2.$$ $$\frac{1}{f(D)} e^{ax} \phi(x) = e^{ax}\frac{1}{f(D+a)} \phi(x)$$

$$3.$$ $$\frac{1}{f(D)} x^{n} \sin ax =$$Imaginary part of $$e^{iax}\frac{1}{f(D+ia)} x^n$$

$$4.$$ $$\frac{1}{f(D)} x^{n} \cos ax =$$Real part of $$e^{iax}\frac{1}{f(D+ia)} x^n$$

$$5.$$ $$\frac{1}{f(D)} x^{n} (\cos ax + i\sin ax) = \frac{1}{f(D)} x^n e^{iax}=e^{iax}\frac{1}{f(D+ia)} x^n$$

Note$$~ 2:$$ For the Particular Integral (i.e., P.I.) of trigonometric functions you have to follow the following rules:

If $$f(D)$$ can be expressed as $$\phi(D^2)$$ and $$\phi(-a^2)\neq 0$$, then

$$1.$$ $$\frac{1}{f(D)} \sin ax=\frac{1}{\phi(D^2)} \sin ax = \frac{1}{\phi(-a^2)} \sin ax$$

$$2.$$ $$\frac{1}{f(D)} \cos ax=\frac{1}{\phi(D^2)} \cos ax = \frac{1}{\phi(-a^2)} \cos ax$$

Note: If $$f(D)$$ can be expressed as $$\phi(D^2)=D^2+a^2$$, then $$\phi(-a^2)= 0$$.

$$1.$$ $$\frac{1}{f(D)} \sin ax =\frac{1}{\phi(D^2)} \sin ax=x\frac{1}{\phi'(D^2)} \sin ax= x \frac{1}{2D} \sin ax= -\frac{x}{2a} \cos ax$$.

$$2.$$ $$\frac{1}{f(D)} \cos ax =\frac{1}{\phi(D^2)} \cos ax=x\frac{1}{\phi'(D^2)} \cos ax= x \frac{1}{2D} \cos ax= \frac{x}{2a} \sin ax$$.

where $$\phi'(D^2)\equiv\frac{d}{dD}\phi(D^2)$$

First solve the homogeneous part $$y''-2y'+5y=0$$ by taking $$y-e^{mx}$$. Then $$m^2-2m+5=0$$ gives $$m=1\pm 2i$$. Hence we get two linearly independent solutions: $$y_1(x)=e^x \sin 2x,~~ y_2(x)=e^x \cos 2x ~~~(1)$$ Next the total solution of the required in-homogeneous ODE: $$Y''-2Y'+5Y=e^x \cos 2x=f(x) ~~~(2)$$ is given by $$Y(x)=C_1(x) y_1(x)+ C_2 y_2(x)~~~(3)$$, where by the method of variation of parameters

$$C_1(x)=-\int \frac{y_2(x) f(x)}{W(x)} dx+~~D_1, ~~~C_2(x)=\int \frac{y_1(x) f(x)}{W(x)} dx ~~+D_2~~~(4)$$

Here $$W(x)=y_1(x)y'_2(x)-y'_1 y_2(x).~~~(5)$$

Finally use (1) in (3), and (5) to get the total solution of (2), with two constants $$D_1, D_2.$$

• why do you add D1 and D2? – Meraj Haq Aug 16 at 4:02
• @Meraj Haq Because ultimately $D_1 e^{x}\sin 2x +D_2 e^{x} \cos 2x$ will automatically be the general part of the solution where as rest in (3) will be without a constant and this part is called particilar integral. – Dr Zafar Ahmed DSc Aug 16 at 4:18
• The particular solution is defined only up to a constant. However, notice that when you carry the constants through, you merely wind up with a restatement of the homogeneous solution. This is why they are often left off. – RghtHndSd Aug 16 at 4:19
• RightHindSd Other option is not to have$D_1$ and $D_2$ in (4) and write $Y=y_g+y_p=D_1 e^x \sin 2x +D_2 e^x \cos 2x+y_p,$ Then $y_p$ will be fiven by (3) without $D_1, D_2$. Let me re-emphasize that the particular integral $y_p$ cannot have any constant. – Dr Zafar Ahmed DSc Aug 16 at 4:42