13.6. A Matrix Exponent and Systems of ODEs¶
We have already learned from Systems of Linear ODEs that ordinary differential equations (ODEs) of the form
have the solution
The same principle applies to systems of ODEs, except that we use vectors and matrices to describe the equations.
In matrix notation, this is ,
which has a solution
of the form
.
We will show here that the matrix form of the solution leads to the same
general solution given in Systems of Linear ODEs. First, let us put the matrix
exponent into a more manageable form and then apply it to
the ODE.
13.6.1. A Matrix in the Exponent¶
The equation seems unusual. What does it mean to have a
matrix in the exponent of the natural number
?
We need to use a Maclaurin series expansion of to get the
matrix out of the exponent and then we will use diagonalization from
Diagonalization to simplify the
powers of
that the series expansion gives us.
From the Maclaurin series expansion we have,
From Diagonalization and Powers of A, we know that Where
and
are the eigenvector and diagonal eigenvalue matrices
of
.
Thus,
We will call the middle term (Gamma).
If we add the elements in , we will find a
Maclaurin series for
in each diagonal element.
In MATLAB, if variable L
(Lambda) is used for , then
Gamma = exp(L) .* eye(n)
, where n
is the size of the matrix.
Or if we have the variable e = exp(1)
, then Gamma = e.^L .* eye(n)
.
The expression Gamma = expm(L)
gives the same result using a built-in
MATLAB function.
Finally,
13.6.2. Example Matrix Exponent¶
>> A = [10 0; -10 7]
A =
10 0
-10 7
>> [X, L] = eig(A)
X =
0 0.2873
1.0000 -0.9578
L =
7 0
0 10
>> e = exp(1)
e =
2.7183
>> Gamma = e.^L .* eye(2)
Gamma =
1.0e+04 *
0.1097 0
0 2.2026
>> % find e^A
>> X*Gamma*inv(X)
ans =
1.0e+04 *
2.2026 0
-6.9766 0.1097
>> % verify with MATLAB's expm() function
>> expm(A)
ans =
1.0e+04 *
2.2026 0
-6.9766 0.1097
13.6.3. Matrix Solution to a System of ODEs¶
Returning to the problem of systems of ODEs, we know that in matrix notation,
the ODE , has a solution of the form
(13.5)¶
where
Note
Using (13.5), we find from
when
.
Letting
gives the same solution as we used in Systems of Linear ODEs
13.6.4. Example ODE Matrix Solution¶
In Systems of Linear ODEs, we solved the following ODE example with initial conditions,
Here we keep all of the variables as matrices and vectors in MATLAB and find the same solution.
>> A = [-2 1; 1 -2]
A =
-2 1
1 -2
>> [X, L] = eig(A)
X =
0.7071 0.7071
-0.7071 0.7071
L =
-3 0
0 -1
>> X = X*2/sqrt(2) % scaling for appearance - not needed
X =
1.0000 1.0000
-1.0000 1.0000
>> y0 = [6; 2]
y0 =
6
2
>> c = X\y0
c =
2.0000
4.0000