Section 4.3

Computation of determinants and Cramer's Rule

>

>

Introduction

- To compute the determinant of a n x n matrix using the cofactor expansion requires roughly n! operations.

(n! = 1 * 2 * 3 . . . * n).

- Consider a 25 x 25 matrix. This would require 25! operations or roughly 1.5*10^`25` operations.

- Suppose you have a super computer that can do 1 trillion operations per second. This calculation

would require 500,000 years!!

How do you find the determinant of 25 x 25 matrix?

Computation of a Determinant

********************************************************************

Computation of a determinant of a n x n matrix A:

1.) Reduce A to an echelon form, using only row additions and row interchanges.

2.) If any of the matrices appearing in the reduction contains a row of zeros, then det(A) = 0.

3.) Otherwise,

det(A) = (-1)^r (Product of pivots)

where r is the number of row interchanges performed.

**********************************************************************

ROW OPERATIONS

*******************************************************

Property 2 : If two different rows of a square matrix A are interchanged,

the determinant of the resulting matrix is -det(A).

*******************************************************

*******************************************************

Property 4 : If a single row of a square matrix A is multiplied by a scalar r,

the determinant of the resulting matrix is r* det(A).

*******************************************************

*******************************************************

Property 5 : If the product of one row of a square matrix A by a scalar is

added to a different row of A, the determinant of the resulting

matrix is the same as the det(A).

*******************************************************

Example 1:

>

> A := matrix([[2,5,7],[6,4,2],[8,4,1]]);

A := matrix([[2, 5, 7], [6, 4, 2], [8, 4, 1]])

> A := addrow(A,1,2,-A[2,1]/A[1,1]);

A := matrix([[2, 5, 7], [0, -11, -19], [8, 4, 1]])

> A := addrow(A,1,3,-A[3,1]/A[1,1]);

A := matrix([[2, 5, 7], [0, -11, -19], [0, -16, -27...

> A := addrow(A,2,3,-A[3,2]/A[2,2]);

A := matrix([[2, 5, 7], [0, -11, -19], [0, 0, 7/11]...

> `det(A)` = A[1,1]*A[2,2]*A[3,3];

`det(A)` = -14

>

Example 2:

>

> A := matrix([[1,-3,1,-2],[2,-5,-1,-2],[0,-4,5,1],[-3,10,-6,5]]);

A := matrix([[1, -3, 1, -2], [2, -5, -1, -2], [0, -...

>

Row reducing and then computing the determinant requires roughly 2/3*n^3 operations.

Consider a 25 x 25 matrix. This would require 2/3*25^3 = 10,500 operations. Less than

1 second to compute.

Cramer's Rule

Cramer's Rule for solving Systems of Linear Equations

Cramer's rule is a method, based on determinants, for solving a system of linear equations.

The system must be a square system and the coefficient matrix must be nonsingular;

that is; its determinant is nonzero.

Example 3: Consider the system

>

> x-3*y+4*z=2;
-x-4*y+3*z=-2;
2*x-5*y+6*z= 5;

x-3*y+4*z = 2

-x-4*y+3*z = -2

2*x-5*y+6*z = 5

>

The coefficient matrix is:

> C:=matrix([[1,-3,4],[-1,-4,3],[2,-5,6]]);

C := matrix([[1, -3, 4], [-1, -4, 3], [2, -5, 6]])

>

Right hand side is,

> b := matrix([[2],[-2],[5]]);

b := matrix([[2], [-2], [5]])

>

> evalm(C) * matrix(3,1,[x,y,z]) = evalm(b);

matrix([[1, -3, 4], [-1, -4, 3], [2, -5, 6]])*matri...

Construct the matrix A[1] obtained from matrix C by replacing the first column of C

with the right side of the system:

> A1:=matrix([[2,-3,4],[-2,-4,3],[5,-5,6]]);

A1 := matrix([[2, -3, 4], [-2, -4, 3], [5, -5, 6]])...

Find the value of x

> x=det(A1)/det(C);

x = 3

Construct the matrix A[2] obtained from matrix C by replacing the second column of C

with the right side of the system:

> A2:=matrix([[1,2,4],[-1,-2,3],[2,5,6]]);

A2 := matrix([[1, 2, 4], [-1, -2, 3], [2, 5, 6]])

Find the value of y

> y=det(A2)/det(C);

y = -1

Construct the matrix A[3] obtained from matrix C by replacing the third column of C

with the right side of the system:

> A3:=matrix([[1,-3,2],[-1,-4,-2],[2,-5,5]]);

A3 := matrix([[1, -3, 2], [-1, -4, -2], [2, -5, 5]]...

Find the value of z

> z=det(A3)/det(C);

z = -1

Note that the solution coincides with the solution obtained using

> solve({x-3*y+4*z=2,-x-4*y+3*z=-2,
2*x-5*y+6*z= 5},{x,y,z});

{y = -1, z = -1, x = 3}

>

Adjoint matrix

***********************************************************************

The steps for finding the adjoint matrix of A.

1. Find the cofactor of each entry of the matrix A. The cofactor of an entry a[ij] is defined as:

C[ij] = (-1)^`i+j` *det( M[ij] )

where the submatrix M[ij] is the minor of the entry a[ij] .

2. Replace each entry of matrix A by its cofactor to get a new matrix C. This matrix is

called the cofactor matrix .

3. The transpose of matrix C is called the adjoint matrix of A and is denoted by Adj(A).

***********************************************************************

Example 4: Find the adjoint of the matrix

> A:=matrix([[1,3,5],[5,3,6],[8,4,2]]);

A := matrix([[1, 3, 5], [5, 3, 6], [8, 4, 2]])

The minors of all of the entries are respectively given by

> M11:=minor(A,1,1);
M12:=minor(A,1,2);
M13:=minor(A,1,3);

> M21:=minor(A,2,1);
M22:=minor(A,2,2);
M23:=minor(A,2,3);

> M31:=minor(A,3,1);
M32:=minor(A,3,2);
M33:=minor(A,3,3);

M11 := matrix([[3, 6], [4, 2]])

M12 := matrix([[5, 6], [8, 2]])

M13 := matrix([[5, 3], [8, 4]])

M21 := matrix([[3, 5], [4, 2]])

M22 := matrix([[1, 5], [8, 2]])

M23 := matrix([[1, 3], [8, 4]])

M31 := matrix([[3, 5], [3, 6]])

M32 := matrix([[1, 5], [5, 6]])

M33 := matrix([[1, 3], [5, 3]])

The cofactor C[ij] of the each entry a[ij] is (-1)^`i+j` *det( M[ij] );

> C11:=(-1)^2*det(M11);
C12:=(-1)^3*det(M12);
C13:=(-1)^4*det(M13);

C11 := -18

C12 := 38

C13 := -4

> C21:=(-1)^3*det(M21);
C22:=(-1)^4*det(M22);
C23:=(-1)^5*det(M23);

C21 := 14

C22 := -38

C23 := 20

> C31:=(-1)^4*det(M31);
C32:=(-1)^5*det(M32);
C33:=(-1)^6*det(M33);

C31 := 3

C32 := 19

C33 := -12

The cofactor matrix is,

>

> C := matrix([[C11,C12,C13],[C21,C22,C23],[C31,C32,C33]]);

C := matrix([[-18, 38, -4], [14, -38, 20], [3, 19, ...

>

The adjoint of A is

>

> `Adj(A)` = transpose(C);

`Adj(A)` = matrix([[-18, 14, 3], [38, -38, 19], [-4...

>

*****************************************************

Result:

Let A=[ a[ij] ] be an n x n matrix. If C[ij] = (-1)^`i+j` *det( M[ij] ) denotes the

cofactor for a[ij] then

a[i1]*C[k1]+a[i2]*C[k2]+a[i3]*C[k3] + . . . + a[i*n] C[k*n] = det(A) if k = i

= 0 if k <> i

*****************************************************

Example 5:

>

> A:=matrix([[a11,a12,a13],[a21,a22,a23],[a31,a32,a33]]);

A := matrix([[a11, a12, a13], [a21, a22, a23], [a31...

>

The minors of entries a[11], a[12], a[13] are respectively given by

> M11:=minor(A,1,1);
M12:=minor(A,1,2);
M13:=minor(A,1,3);

>

M11 := matrix([[a22, a23], [a32, a33]])

M12 := matrix([[a21, a23], [a31, a33]])

M13 := matrix([[a21, a22], [a31, a32]])

The cofactor C[ij] of the entry a[ij] is (-1)^`i+j` *det( M[ij] );

> C11:=(-1)^2*det(M11);
C12:=(-1)^3*det(M12);
C13:=(-1)^4*det(M13);

C11 := a22*a33-a23*a32

C12 := -a21*a33+a23*a31

C13 := a21*a32-a22*a31

The determinant of A.

> `det(A)` = a11*C11 +a12*C12+a13*C13;

`det(A)` = a11*(a22*a33-a23*a32)+a12*(-a21*a33+a23*...

Value should be zero.

> simplify(a21*C11 +a22*C12+a23*C13);

0

******************************************************************

Let A be an nxn nonsingular matrix. Then the inverse of A is given by:

A^`-1` = Adj(A)/det(A)

*******************************************************************

Example 6 Find the inverse of the following matrix

>

> A:=matrix([[1,3,5],[5,3,6],[8,4,2]]);

A := matrix([[1, 3, 5], [5, 3, 6], [8, 4, 2]])

> Adjoint(A):=matrix([[-18,14,3],[38,-38,19],[-4,20,-12]]);

Adjoint(A) := matrix([[-18, 14, 3], [38, -38, 19], ...

The product of A with its adjoint is the matrix

> multiply(A,Adjoint(A));

>

This is the identity matrix multiplied by the determinant of the matrix A.

> det(A);

matrix([[76, 0, 0], [0, 76, 0], [0, 0, 76]])

76

> `A^-1` = Adjoint(A)/det(A);

`A^-1` = 1/76*matrix([[-18, 14, 3], [38, -38, 19], ...

>

Exercises

1, 3, 5, 7, 9, 15, 17, 19, 21, 22, 25, 27, 29.