# 2nd order ODE to 1st order ODE/Forward euler method

I have a 2nd ODE: ${d^2u \over dt^2} =5tu+\sin ({du\over dt})$, $u(0)=1$, ${du\over dt}(0)=0$. Iwas reading my notes and it asked to write the 2nd order ODE as a system of 1st order ODEs. And then to construct a forward euler discretisation of the ODE with step size $\tau =1/2$ and interval $[0,2]$.

What was done in the notes was:

$\text{Let }v={du \over dt}\\{dv \over dt}={d^2u \over dt^2}\\ \Rightarrow {dv \over dt}=5tu+\sin v, \ v(0)=0.$

I understood the above, but I'm not sure what was done after that. Could someone explain to me what was done below? Let

$w= \left( \begin{array}{c} u \\ v \end{array} \right)$, then ${dw \over dt}=f(t,w), \ w(0)=w_0$ where $f(t,w)=\left( \begin{array}{c} v \\ 5tu+\sin v \end{array} \right)$ and $w_0=\left( \begin{array}{c} 1 \\ 0 \end{array} \right)$

Continuing on from there, how does the following work? In particular how does $f(t_0, W^0)= \left( \begin{array}{c} V^0 \\ 5\cdot 0 \cdot U^0 + \sin V^0 \end{array} \right) = \left( \begin{array}{c} 0 \\ 0 \end{array} \right)$?

Forward euler for the 1st order system: Given $W^0=w_0$, find $W^{n+1}$ such that $W^{n+1}=W^n+\tau f(t_n,w)$.

$n=0$, $W^0= \left( \begin{array}{c} 1 \\ 0 \end{array} \right) \\f(t_0, W^0)= \left( \begin{array}{c} V^0 \\ 5\cdot 0 \cdot U^0 + \sin V^0 \end{array} \right) = \left( \begin{array}{c} 0 \\ 0 \end{array} \right) \\ \Rightarrow W^1 = W^0 +\tau \left( \begin{array}{c} 0 \\ 0 \end{array} \right) \Rightarrow W^1 = W^0$

-

$w$ as defined is a $2$-dimensional vector of functions, the first component of which is the function $u$ and the second component of which is the function $v=\frac{du}{dt}$. When we differentiate, we differentiate componentwise: $$\frac{dw}{dt}=\begin{bmatrix}\tfrac{du}{dt} \\ \tfrac{dv}{dt}\end{bmatrix}.$$ However, we know both $\frac{du}{dt}$ and $\frac{dv}{dt}$ (you said you understood this part). Just plugging these in, we have that $$\frac{dw}{dt}=\begin{bmatrix}v \\ 5tu+\sin (v)\end{bmatrix}.$$ Same thing with the initial condition: $$w(0)=\begin{bmatrix}u(0) \\ v(0)\end{bmatrix}=\begin{bmatrix}1 \\ 0\end{bmatrix}.$$
As for the numerical part, it seems that you should adust your equation $W^{n+1}=W^n+\tau f(t_n,w)$ to read $$W^{n+1}=W^n+\tau f(t_n,W^n).$$ In any case, when you actually started to work out the problem, it seems as if this is what you did. (Also keep in mind that $t_{n+1}=t_n+\tau$).
Thanks @JohnathanGleason , I understood everything you did. I just have one more question -- How do I get from $f(t_0, W^0)= \left( \begin{array}{c} V^0 \\ 5\cdot 0 \cdot U^0 + \sin V^0 \end{array} \right) = \left( \begin{array}{c} 0 \\ 0 \end{array} \right)$? In particular, shouldnt $U^0 =1$? –  Richard May 9 '12 at 0:45
Yes, $U^0=u(0)=1$ and $V^0=u(0)=u'(0)=0$. –  Jonathan Gleason May 9 '12 at 0:53