1
$\begingroup$

I have been struggling with this problem for awhile now and I just can't seem to get the hang of it.

The problem: Write the problem as a system of the first order and perform a step with Euler's method with step length k = 0.1.

The ODE: $u''(t) + u^{2} = sin(t), u(0)=1, u'(0)=0$

Here is how far I've come: My work

I don't know/understand how to perform a step with Euler's method.

Euler's Method formula: $y_{n} = y_{n-1} + kf(t_{n-1}, y_{n-1})$

In this case: $y_{n} = y_{n-1} + 0.1(sin(t_{n-1}) - y_{n-1}^{2})$

Any help would be appreciated!

$\endgroup$
3
$\begingroup$

You did set $\vec y=[y_1;\,y_2]=[u;\,u']$ and found $\vec F(t,\vec y)=[y_2;\, \sin(t)-y_1^2]$. Now apply the Euler formula in this setup using two-dimensional vectors as state, $$ \vec y_{n+1}=\vec y_n+k\vec F(t_n,\vec y_n)\implies \left\{\begin{align} y_{n+1,1} &= y_{n,1}+ky_{n,2},\\ y_{n+1,2} &= y_{n,2}+k[\sin(t_n)-y_{n,1}^2]. \end{align}\right. $$ This is how you would do it with general solver software that can compute with vector types. You would implement a function for $\vec F$ and the vector $\vec y_0$ and just let it run.


For a not so structured approach you can also call the second component $v$ and replace $y_{n,1}$ back with $u_n$ and $y_{n,2}$ with $v_n=u_n'$, so that \begin{align} u_{n+1}&=u_n+kv_n,\\ v_{n+1}&=v_n+ka_n=v_n+k[\sin(t_n)-u_n^2]. \end{align}

You just can't cross-mix the update equations, a system is different from a scalar first-order equation.

$\endgroup$
2
  • $\begingroup$ @Lutz_Lehmann This is what I do not know how to do. I am also unfamiliar with the notation $y_{n,1}$, $y_{n,2}$, could you explain what that means? The introduction to linear algebra by my professor has been very brief and not well done. $\endgroup$
    – NoName123
    Jan 6 '20 at 14:53
  • 1
    $\begingroup$ Then perhaps call the second component $v$ and replace $y_{n,1}$ back with $u_n$ and $y_{n,2}$ with $v_n=u_n'$. You just can not cross-mix the update equations, a system is different from a scalar first-order equation. $\endgroup$ Jan 6 '20 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.