# Shorter solution to differential equation?

I'm looking for a shorter way to find a maximal solution to the differential equation $$y''-2y'+y=xe^x+e^x\cos(x)$$ $$y(0)=y'(0)=1$$ At first I was hoping I could convert the right side to $e^x(g(x))$ with g(x) polynomial, but that didn't work out. So my paths turn out to be very long (with solution $e^x(x^3/6-\cos(x)+2)$). I'd appreciate any help.

-
You can consider direct integration. –  johannesvalks Jun 27 '14 at 15:52

Hint: $$y''-2y'+y=xe^x+e^x\cos(x)$$ $$e^{-x}(y''-2y'+y)=x+\cos(x)$$ Since $$(ye^{-x})''=(y'e^{-x}-ye^{-x})'=y''e^{-x}-2y'e^{-x}+ye^{-x}\ ,$$ then putting $z:=y e^{-x}$ you get $$z''=x+\cos(x)$$

-

The method you would use here is the method of undetermined coefficients. For a function to produce $e^{x}(\cos(x))$ you should start with a function of the form $y_1 = Ae^x\sin(x) + B e^x \cos(x)$, then apply the differential equation, then isolate and solve the coefficients.

The same goes for $xe^x$, you should try a function of the form $y_2=(Ax^2+Bx+C)e^x$ then solve for $A,B,C$ after you apply the differential equation.

Finally the easy part is solving the homogeneous differential equation, which gives you two solutions $y_a$ and $y_b$.

The general solution will be of the form $y= C_1 y_a + C_2 y_b + y_1 + y_2$.

-

Hint: Consider both $$y'' - 2y' + y = xe^x \to y_1 \\ y'' - 2y' + y = xe^{ix} \to y_2$$ One solution of your equation is $y_1 + \Re y_2$.

-

Given to solve

$$y'' - 2y' + y = x \exp(x) + \exp(x) \cos(x).$$

Note that

$$\exp(x) \frac{d}{dx} \frac{d}{dx} \Big( \exp(-x) y \Big) = y'' - 2 y' + y,$$

so we obtain

$$y'' - 2 y' + y = \exp(x) \frac{d}{dx} \frac{d}{dx} \Big( \exp(-x) y \Big) = x \exp(x) + \exp(x) \cos(x),$$

whence

$$y = \exp(x) \int dx \int dx \Big( x + \cos(x) \Big)$$

$$\begin{eqnarray} y &=& \exp(x) \int dx \int dx \Big( x + \cos(x) \Big) \\&=& \exp(x) \int dx \Big( \tfrac{1}{2} x^2 + \sin(x) + C_1 \Big)\\&=& \exp(x) \Big( \tfrac{1}{6} x^3 - \cos(x) + C_1 x + C_2 \Big) \end{eqnarray}.$$ Note that $$y' = y + \exp(x) \Big( \tfrac{1}{2} x^2 + \sin(x) + C_1 \Big).$$ So $y(0)=1$ implies $C_2=2$ and $y'(0)=1$ implies $C_1=0$. So $$y(x) = \exp(x) \Big( \tfrac{1}{6} x^3 - \cos(x) + 2 \Big)$$

-

$$y=ge^x\to y''-2y'+y=(g''+2g'+g)e^x-2(g'+g)e^x+ge^x=g''e^x$$ Particular solutions such that $y(0)=g(0)=y'(0)=g'(0)+g(0)=0$ (quiescent initial state): $$g''=x\to g'=\frac{x^2}2\to g=\frac{x^3}6$$ $$g''=\cos x\to g'=-\sin x\to g=1-\cos x$$ General solution of the homogenous equation, with conditions $g(0)=g'(0)+g(0)=1$: $$g''=0\to g'=a=0\to g=b=1$$ Complete solution: $$g=\frac{x^3}6+(1-\cos x)+1$$ $$y=e^x(\frac{x^3}6-\cos x+2)$$

-