MTH215/URI

Fall 2004

Matrix Exponential

Worksheet by M. R. S. Kulenovic, URI, Fall 2004

Goals

Goals of this worksheet:

Use eigenvectors and eigenvalues to simplify computation of a matrix exponential.

Find the solution of homogeneous and nonhomogeneous linear system of differential equations.

> restart:with(plots):with(linalg):

Warning, the name changecoords has been redefined

Warning, the protected names norm and trace have been redefined and unprotected

Matrix Exponential

The MatrixExponential(A, t) command returns the Matrix exp(A*t) = I + A*t + 1/2!*A^2*t^2 + ... where I is the identity Matrix. This is an example of a generalized Matrix function , F(A).

If the scalar parameter t is not specified, the first indeterminate value in the Matrix is removed and used as a parameter.

For more information on the output options outopts, see Matrix .

Examples

Example 1.

> with(LinearAlgebra):
A := Matrix([[-5, -9], [6, 10]]);

A := Matrix([[-5, -9], [6, 10]])

> MatrixExponential(A);

Matrix([[3*exp(1)-2*exp(4), -3*exp(4)+3*exp(1)], [2*exp(4)-2*exp(1), -2*exp(1)+3*exp(4)]])

> MatrixExponential(A, x);

Matrix([[3*exp(x)-2*exp(4*x), -3*exp(4*x)+3*exp(x)], [2*exp(4*x)-2*exp(x), -2*exp(x)+3*exp(4*x)]])

Example 2.

> B := Matrix([[-39, -38, -92], [4, 3,8],[18,18,43]]);

B := Matrix([[-39, -38, -92], [4, 3, 8], [18, 18, 43]])

> MatrixExponential(B);

Matrix([[2*exp(-1)+5*exp(1)-6*exp(7), -6*exp(7)+5*exp(1)+exp(-1), -14*exp(7)+10*exp(1)+4*exp(-1)], [2*exp(1)-2*exp(-1), -exp(-1)+2*exp(1), 4*exp(1)-4*exp(-1)], [-3*exp(1)+3*exp(7), -3*exp(1)+3*exp(7),...

> MatrixExponential(B, x);

Matrix([[2*exp(-x)+5*exp(x)-6*exp(7*x), -6*exp(7*x)+5*exp(x)+exp(-x), -14*exp(7*x)+10*exp(x)+4*exp(-x)], [2*exp(x)-2*exp(-x), -exp(-x)+2*exp(x), 4*exp(x)-4*exp(-x)], [-3*exp(x)+3*exp(7*x), -3*exp(x)+3...

>

Exercise:

Finding the solutions of the system of differential equations.

Example 1.

> restart;with(LinearAlgebra):with(linalg):

Warning, the previous binding of the name GramSchmidt has been removed and it now has an assigned value

Warning, the protected names norm and trace have been redefined and unprotected

Lets try the following example:
The matrix A is given by

> A:=array([[10,6],[-9,-5]]);

A := matrix([[10, 6], [-9, -5]])

Here is the nonhomogeneous term g(t)

> g:=t->array([[2*t^2+1],[4*t]]);

g := proc (t) options operator, arrow; array([[2*t^2+1], [4*t]]) end proc

And finally an intial condition

> x0:=array([[2],[4]]);

x0 := matrix([[2], [4]])

Here is the fundamental matrix of our problem Phi(t) = Exp(A*t):

> phi:=t->exponential(A*t);

phi := proc (t) options operator, arrow; exponential(A*t) end proc

> phi(t);

matrix([[-2*exp(t)+3*exp(4*t), 2*exp(4*t)-2*exp(t)], [-3*exp(4*t)+3*exp(t), 3*exp(t)-2*exp(4*t)]])

First we will get the general solution of the homogeneous equation

> xh := t -> phi(t)&*x0;

Then the particular solution using the map command

> xp := t -> map(integrate,evalm(phi(-z)&*g(z)),z=0..t);

xh := proc (t) options operator, arrow; &*(phi(t), x0) end proc

xp := proc (t) options operator, arrow; map(integrate, evalm(&*(phi(-z), g(z))), z = (0 .. t)) end proc

And then the general solution of the problem:

> xnonh := t -> evalm(xh(t) + xp(t));

xfull := proc (t) options operator, arrow; evalm(xh(t)+xp(t)) end proc

After simplification we obtain:

> simplify(evalm(xnonh(t)));

matrix([[-12*exp(t)+14*exp(4*t)+4*exp(-t)*t^2+16*exp(-t)*t+18*exp(-t)-3/2*exp(-4*t)*t^2-11/4*exp(-4*t)*t-23/16*exp(-4*t)-265/16], [-14*exp(4*t)+18*exp(t)+3/2*exp(-4*t)*t^2+11/4*exp(-4*t)*t+23/16*exp(-...

A simple check of the initial condition...

> check := evalf(evalm(xnonh(1e-16)));

check := matrix([[2.000000000], [4.]])

Example 2.

> restart;with(LinearAlgebra):with(linalg):

Here we will use Matrix Exponential to find the solution of homogeneous and nonhomogeneous linear system of differential equations. Our principal tool is the variation of parameters formula for linear system of differential equations:

X'(t) = A X(t) + b(t)

that satisfies initial condition:

X(0) = c.

The solution of this initial value problem is given as the sum of the general solution of the corresponding homogeneous problem Xh(t) and the particular solution of nonhomogeneous system Xp(t):

X(t) = Xh(t) + Xp(t) = exp(At) X(0) + exp(At) int(exp(-As) b(s), 0, t).

> X(t) = exp(A*t)*X(0) + exp(A*t)*Int(exp(-A*s)*b(s),s=0..t);

X(t) = exp(A*t)*X(0)+exp(A*t)*Int(exp(-A*s)*b(s), s = (0 .. t))

Lets try the following example:
The matrix A is given by

> B:=array([[-6,-10,4],[2,3,-2],[-3,-6,1]]);

B := matrix([[-6, -10, 4], [2, 3, -2], [-3, -6, 1]])

Here is the nonhomogeneous term g(t)

> g:=t->array([[2*t^2+exp(t)],[4*sin(t)+1],[t+cos(t)]]);

g := proc (t) options operator, arrow; array([[2*t^2+exp(t)], [4*sin(t)+1], [t+cos(t)]]) end proc

An intial condition

> x0:=array([[2],[4],[-1]]);

x0 := matrix([[2], [4], [-1]])

Here is the fundamental matrix of our problem Phi(t) = Exp(A*t):

> phi:=t->exponential(B*t);

phi := proc (t) options operator, arrow; exponential(B*t) end proc

> phi(t);

matrix([[-2*exp(t)+2*exp(-t)+exp(-2*t), 2*exp(-2*t)+2*exp(-t)-4*exp(t), -2*exp(-t)+2*exp(t)], [-exp(-t)+exp(t), 2*exp(t)-exp(-t), exp(-t)-exp(t)], [-exp(t)+exp(-2*t), 2*exp(-2*t)-2*exp(t), exp(t)]])

First we will get the general solution of the homogeneous equation

> xh := t -> phi(t)&*x0;

Then the particular solution using the map command

> xp := t -> map(integrate,evalm(phi(-z)&*g(z)),z=0..t);

xh := proc (t) options operator, arrow; &*(phi(t), x0) end proc

xp := proc (t) options operator, arrow; map(integrate, evalm(&*(phi(-z), g(z))), z = (0 .. t)) end proc

And then the general solution of  the nonhomogeneous equation:

> xnonh := t -> evalm(xh(t) + xp(t));

xnonh := proc (t) options operator, arrow; evalm(xh(t)+xp(t)) end proc

After simplification we obtain:

> simplify(evalm(xnonh(t)));

matrix([[-10*exp(t)+24*exp(-t)+10*exp(-2*t)-2*t+1/3*exp(3*t)+5/2*exp(2*t)-t*exp(2*t)-10*t*exp(t)+exp(2*t)*t^2+7*exp(-t)*cos(t)+9*exp(-t)*sin(t)+4*exp(t)*t^2+4*exp(-t)*t^2+6*exp(-t)*t-8/5*exp(2*t)*cos(...matrix([[-10*exp(t)+24*exp(-t)+10*exp(-2*t)-2*t+1/3*exp(3*t)+5/2*exp(2*t)-t*exp(2*t)-10*t*exp(t)+exp(2*t)*t^2+7*exp(-t)*cos(t)+9*exp(-t)*sin(t)+4*exp(t)*t^2+4*exp(-t)*t^2+6*exp(-t)*t-8/5*exp(2*t)*cos(...matrix([[-10*exp(t)+24*exp(-t)+10*exp(-2*t)-2*t+1/3*exp(3*t)+5/2*exp(2*t)-t*exp(2*t)-10*t*exp(t)+exp(2*t)*t^2+7*exp(-t)*cos(t)+9*exp(-t)*sin(t)+4*exp(t)*t^2+4*exp(-t)*t^2+6*exp(-t)*t-8/5*exp(2*t)*cos(...

A simple check of the initial condition...

> check := evalf(evalm(xnonh(1e-16)));

check := matrix([[2.], [4.], [-1.]])

>