[Math] 2nd order ODE to 1st order ODE/Forward euler method

numerical methodsordinary differential equations

I have a $2^\text{nd}$ ODE:

$$
\begin{cases}{d^2u \over dt^2} =5tu+\sin \left({du\over dt}\right)\\[5 pt] u(0)=1\\[5 pt]
{du\over dt}(0)=0
\end{cases}
$$

I was reading my notes and it asked to write the $2^\text{nd}$ order ODE as a system of $1^\text{st}$ 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:

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

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{matrix}
u \\
v
\end{matrix}
\right)\\
\text{then } {dw \over dt}=f(t,w), \;\;\;\;\;\; w(0)=w_0 \\
\text{where } f(t,w)=\left(
\begin{matrix}
v \\
5tu+\sin v
\end{matrix}
\right) \text{ and } w_0=\left(
\begin{matrix}
1 \\
0
\end{matrix}
\right)$$


Continuing on from there, how does the following work? In particular how does

$$
f(t_0, W^0)= \left(
\begin{matrix}
V^0 \\
5\cdot 0 \cdot U^0 + \sin V^0
\end{matrix}
\right) = \left(
\begin{matrix}
0 \\
0
\end{matrix}
\right)$$

Forward euler for the $1^\text{st}$ 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 \implies $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) \\ \implies W^1 = W^0 +\tau \left(
\begin{array}{c}
0 \\
0
\end{array}
\right) \implies W^1 = W^0
$$

Best Answer

$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$).

Related Question