Home»Math Guides»Solving systems of ODEs (ordinary differential equations), real distinct eigenvalues, 2 equations (2 by 2 matrix)
How to solve systems of ordinary differential equations, using eigenvalues, complex and imaginary eigenvalues/eigenvectors worked-out example problem
You may be asked to solve systems of ordinary differential equations simultaneously.
Let’s do a harder example problem where the system of equations have a matrix that has complex (real and imaginary) eigenvalues. Please see our page on solving a system of 2 ODEs that has real eigenvalues, it’s a good practice problem before this example and we’ll explain the steps in further detail.
We’ve also got code on how to solve this kind of system of ODEs using the program MATLAB.
Example problem: Solve the initial value problem: \(x’ = \left[ {\begin{array}{*{20}{c}}3&{ – 9}\\4&{ – 3}\end{array}} \right]x\), given initial condition \(x(0) = \left[ {\begin{array}{*{20}{c}}2\\{ – 4}\end{array}} \right]\)
First find the eigenvalues using \(\det \left( {A – \lambda I} \right)\). i will represent the imaginary number, \(\sqrt { – 1} \)
\[\det \left( {A – \lambda I} \right) = \left[ {\begin{array}{*{20}{c}}{3 – \lambda }&{ – 9}\\4&{ – 3 – \lambda }\end{array}} \right]\]
\[{\lambda ^2} + 27 = 0\]
\[{\lambda _{1,2}} = \pm 3\sqrt 3 i\]
First, let’s substitute \({\lambda _1} = 3\sqrt 3 i\) into \(\det \left( {A – \lambda I} \right)\).
\[\left[ {\begin{array}{*{20}{c}}{3 – 3\sqrt 3 i}&{ – 9}\\4&{ – 3 – 3\sqrt 3 i}\end{array}} \right]\left[ {\begin{array}{*{20}{c}}{{k_1}}\\{{k_2}}\end{array}} \right] = \left[ {\begin{array}{*{20}{c}}0\\0\end{array}} \right]\]
Reading the first equation,
\[\left( {3 – 3\sqrt 3 i} \right){k_1} – 9{k_2} = 0\]
Try to set \({k_2}\) to get a simpler looking eigenvector.
Let’s set \({k_2} = \frac{{1 – \sqrt 3 i}}{3}{k_1}\)
We get the eigenvector,
\[{K_1} = \left[ {\begin{array}{*{20}{c}}3\\{1 – \sqrt 3 i}\end{array}} \right]\]
If you were to separate the real and imaginary parts, the eigenvector would look as:
\[{K_1} = \left[ {\begin{array}{*{20}{c}}3\\1\end{array}} \right] + \left[ {\begin{array}{*{20}{c}}0\\{ – \sqrt 3 i}\end{array}} \right]\]
Now, complex eigenvalues will always be a complex conjugate, remember that we found earlier \({\lambda _{1,2}} = \pm 3\sqrt 3 i\), the plus or minus means it’s a complex conjugate.
You need to memorize the pattern below. The imaginary part of the eigenvalue, just use the positive one, will always be in the trigonometry arguments (inside of sine and cosines).
The real part of the eigenvalue is put on top of the powers of e, in this case it’s 0, so we put e to the power of 0, which will just simplify to one, but that won’t always be the case in these kinds of problems, you might get a nonzero real part eigenvalue.
You need to put the matrix of real or imaginary parts from eigenvectors multiplied before the trig, in a certain pattern!
Don’t mix up the eigenvalue and eigenvectors.
\[x(t) = {c_1}\left( {\left[ {\begin{array}{*{20}{c}}3\\1\end{array}} \right]\cos \left( {3\sqrt 3 t} \right) + \left[ {\begin{array}{*{20}{c}}0\\{ – \sqrt 3 }\end{array}} \right]\sin \left( {3\sqrt 3 t} \right)} \right){e^{0t}} + {c_2}\left( {\left[ {\begin{array}{*{20}{c}}0\\{ – \sqrt 3 }\end{array}} \right]\cos \left( {3\sqrt 3 t} \right) + \left[ {\begin{array}{*{20}{c}}3\\1\end{array}} \right]\sin \left( {3\sqrt 3 t} \right)} \right){e^{0t}}\]
Now use the initial condition to solve for the constants.
Remember that cos(0) = 1, and sin(0) = 0, so certain parts will cancel out, be careful not to make arithmetic mistakes!
\[\left[ {\begin{array}{*{20}{c}}2\\{ – 4}\end{array}} \right] = {c_1}\left[ {\begin{array}{*{20}{c}}3\\1\end{array}} \right] + {c_2}\left[ {\begin{array}{*{20}{c}}0\\{ – \sqrt 3 }\end{array}} \right]\]
It’s just a matrix 2 by 2 problem, if you know how to solve matrices on your scientific calculator, you can solve it within just a few seconds, DLBMaths on YouTube has an amazing tutorial on how to solve matrices easily on a Casio fx991ES PLUS.
Solving, \({c_1} = \frac{2}{3}\) and \({c_2} = \frac{{14}}{{3\sqrt 3 }}\).
Now substitute in to get the final answer. We removed the 0 terms in the matrices and e to the 0 is just 1.
\[x(t) = \frac{2}{3}\left[ {\begin{array}{*{20}{c}}{3\cos \left( {3\sqrt 3 t} \right)}\\{\cos \left( {3\sqrt 3 t} \right) + \sqrt 3 \sin \left( {3\sqrt 3 t} \right)}\end{array}} \right] + \frac{{14}}{{3\sqrt 3 }}\left[ {\begin{array}{*{20}{c}}{3\sin \left( {3\sqrt 3 t} \right)}\\{ – \sqrt 3 \cos \left( {3\sqrt 3 t} \right) + \sin \left( {3\sqrt 3 t} \right)}\end{array}} \right]\]
Solving the system of ODEs using MATLAB, double check your solution is correct!
Most of the time the answers to these questions will have analytical solutions (you can represent the answers perfectly using equations) if your instructor asked you to do them by hand.
If the system of ODEs have analytical solutions, you can use the symbolic variables in MATLAB and its “dsolve” command to get the answer, you don’t even have to have initial conditions, it will generate constants for you.
You can replace the constants in the matrix with what you have, think of the script as an easy calculator for systems of ODEs. “B” is just a matrix of non-homogeneous terms, if you have those, but here we don’t have that so it’s just a zero vector.
%bai-gaming.com/math-guides
syms x1(t) x2(t)
A = [3 -9; 4 -3];
B = [0; 0];
Y = [x1; x2];
odes = diff(Y) == A*Y + B
conds = Y(0) == [2; -4];
[x1Sol(t), x2Sol(t)] = dsolve(odes,conds)
x1Sol(t) = simplify(x1Sol(t))
x2Sol(t) = simplify(x2Sol(t))
Try an example where a system of ODEs has repeated real eigenvalues!
Try solving some single differential equations next by clicking here!