How is $\ y'' + 2y' +2y = e^{-x} \cdot \sin(x)$, $y(0)=0$, $y'(0)=0$ converted into a system of 1st order ODEs?

I worked the following: $$\ y{_1}=y,\; y_1'=y'=y_2,\; y_2=y',\; y_2'=y'' $$ such that I have: $$\ y_1'=y_2,\; y_2'=e^{-x} \cdot \sin(x)-2y_2-2y_1$$. Separately, I have the exact solution of the original 2nd order ODE to be: $$\ y(x) = \frac{1}{2}e^{-x}(\sin(x)-x\cos(x)) $$

However, I don't know how to express that in terms of the solutions for $\ y_1 $ and $\ y_2 $ which I need to then test some numerical approximations (e.g.: Euler, RK4, Midpt) for some pre-written MATLAB code. Is there a quick way for me to use the exact solution I already have to get $\ y_1 $ and $\ y_2 $ or do I need to solve the 1st order ODE system on its own? If so, how?

  • 1
    $\begingroup$ The solutions are $y_1(x) = \dfrac{1}{2} e^{-x} ( \sin x - x \cos x), y_2(x) = \dfrac{1}{2} e^{-x} ( (x - 1) \sin x + x \cos x)$. Compare $y_1(x)$ to your $y(x)$. What do you notice? $\endgroup$
    – Moo
    Nov 13, 2016 at 17:59
  • $\begingroup$ Thank you both very much. Clearly I wasn't connecting the relation between my own variable substitutions and the exact solution. $\endgroup$
    – xq1515426
    Nov 13, 2016 at 18:17

1 Answer 1


You wrote that in the first line of definitions of $y_1,y_2$, relative to a solution $y$ of the second order equation, the first order components are $$ y_1=y,\, y_2=y' $$ so that the only thing you have to do is to compute the derivative of the exact solution. See also the comment of Moo.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .