[Math] Euler’s method for system of non-linear ODE’s

nonlinear systemnumerical methodsordinary differential equations

I am attempting to use Euler's method to express the following system of ODE's…

$$\frac{dy_i}{dx} = c_i(y_{i-1}^3 – y_{i}^3) + f_i\qquad(\text{for }i=1,\ldots,n)$$

using the discretised equations, which are presented below in matrix notation:

$$\boldsymbol{y}(t_{k+1})=\boldsymbol{C}_1\boldsymbol{y}(t_{k})+\boldsymbol{C}_2\boldsymbol{y}^3(t_{k}) + \boldsymbol{f}$$

Note $f_i=1$ when $i=1$, but otherwise equals $0$ (this considers the initial condition). Whilst I am familiar with Euler's method, I am unsure of the steps to get to the first equation to the second. Can anyone assist me with this? Understanding this is necessary for a project I'm working on, so I would really appreciate any help.

Thanks

Best Answer

Assuming $y_0 = 0$ for $i=0$, and, say, we have two equations:

$$ \frac{dy_1}{dt}=-c_1y_1^3+f_1\\ \frac{dy_2}{dt}=c_2(y_1^3-y_2^3)+f_2$$

Write it in vector form:

$$ \dot{\vec{y}} = \vec{F}(t,\vec{y})$$

So,

$$ \dot{\vec{y}} = \vec{F}(t,\vec{y}) = \begin{Bmatrix} -c_1y_1^3+f_1(t)\\ c_2(y_1^3-y_2^3)+f_2(t) \end{Bmatrix} $$

Given the initial conditions $ y_1(0)=y_{10},y_2(0)=y_{20} $, and a time step $h$ you can use the Euler Method as:

$$ \vec{y}(k+1) = \vec{y}(k)+h \vec{F}(t(k),\vec{y}(k)) $$

You don't need to use matrices on this system of equations.

Edit:

If you have an equation that is linear in $\vec{y}$ and $\vec{y}^3$, you can define two vectors $\vec{c}_1$ and $\vec{c}_2$, so your function is of the form:

$$ \dot{\vec{y}} = \vec{c}_1\cdot\vec{y}+\vec{c}_2\cdot\vec{y}^3 $$

And the time integration scheme will be (admitting constant $\vec{c}_1$ and $\vec{c}_2$):

$$ \vec{y}(k+1) = \vec{y}(k)+h\left(\vec{c}_1\cdot\vec{y}(k)+\vec{c}_2\cdot\vec{y}^3(k)\right) $$

Observe that the $\cdot$ operator is an element-wise operator. If you don't have implemented en element-wise operator, you can also use matrix multiplication and define $\vec{c}=\mathrm{diag}(\vec{c})$, so $\mathbf{c}$ will be a diagonal matrix instead.

Related Question