[Math] Solve two coupled second order differential equations using ode45 in MatLab

MATLABordinary differential equationssystems of equations

How to solve two coupled second order differential equations using ode45 in MatLab?

Equations are:

$b_1\cdot\ddot{X}+b_2\cdot\ddot{Y}+b_3\cdot X+b_4\cdot Y+b_5\cos{2t}\cdot X=0$

$a_1\cdot\ddot{X}+a_2\cdot\ddot{Y}+b_4\cdot X+a_3\cdot Y=0$

where $t$ is time variable, overdots are time derivatives and $a$ and $b$ are constants. Notice the two coupled second order derivatives in both equations.

Best Answer

Let $A=\begin{bmatrix} b_1 & b_2 \\ a_1 & a_2 \end{bmatrix}$. Then $\begin{bmatrix} \ddot{X} \\ \ddot{Y} \end{bmatrix} = -A^{-1} \begin{bmatrix} b_3 X + b_4 Y + b_5 \cos(2t) X \\ b_4 X + a_3 Y \end{bmatrix}$. You can combine this with new variables $B=\dot{X},C=\dot{Y}$ to get a system of four scalar first order differential equations.

This assumes $A$ is invertible in the first place; the system is ill-defined otherwise.

Related Question