Matrices-Unit11.mws

MATRICES AND MATRIX OPERATIONS: Unit 11

Dr. Wlodzislaw Kostecki

The Papua New Guinea University of Technology (PNGUT)

Department of Electrical and Communication Engineering

Lae, Morobe Province

Papua New Guinea

Copyright © 2000 by Wlodzislaw Kostecki

All rights reserved

-------------------------------------------------------------------

(11) The determinant of a matrix

OBJECTIVES :

To define the determinant of a square matrix and introduce the concept of the order of determinant.

To provide examples of computation of the determinant of matrices with symbolic and numerical elements.

To investigate the value of the determinant of some specific types of matrices.

To investigate properties of determinants of matrices having specific values of, or specific relations between, row and column elements.

To investigate how some operations performed on entire matrices or their components affect the determinant.

To introduce further functions from the linalg package and show their use in matrix computations.

> restart : with(linalg, addcol, addrow, coldim, det, diag, mulcol, mulrow, multiply, rowdim, swapcol, swaprow, transpose, vandermonde) :

The determinant of a matrix is defined only for square matrices and it is the sum of certain products of the matrix elements. It is, therefore, a scalar (real number, complex number, or function, depending on the elements of the matrix).

Exemplarily, consider a square ( 2 × 2 ) matrix [ A ] given as

> A := matrix(2, 2, [ a[11], a[12], a[21], a[22] ]) : A = matrix(A) ;

A = matrix([[a[11], a[12]], [a[21], a[22]]])

The determinant of this matrix is defined as the following sum of products of the diagonal elements:

> `det(A)` := det(A) : Det(A) = `det(A)` ;

Det(A) = a[11]*a[22]-a[12]*a[21]

This sum is also the value of the determinant of [ A ].

* * *

N.B. In textbooks, a common method of visualization of the determinant of [ A ] uses the symbol abs(A) , which is followed by the = sign and a square array of elements arranged exactly as they are displayed above, but enclosed in a pair of vertical lines. The number of rows or columns of the array is the order of the determinant.

In the case of the above matrix [ A ], its determinant is of second order.

Maple does not offer this type of visualization of the determinant.

* * *

As a more advanced example, consider a ( 3 × 3 ) matrix [ B ] given as

> B := matrix(3, 3, [b[11], b[12], b[13], b[21], b[22], b[23], b[31], b[32], b[33]]) : B = matrix(B) ;

B = matrix([[b[11], b[12], b[13]], [b[21], b[22], b...

The determinant of this matrix is the third-order determinant. Its value is the following sum of products:

> `det(B)` := det(B) : Det(B) = `det(B)` ;

Det(B) = b[11]*b[22]*b[33]-b[11]*b[23]*b[32]-b[21]*...

Numerical example

Compute the determinant of a ( 3 × 3 ) matrix [ C ] given as

> C := matrix(3, 3, [7, 18, 8, 1, 5, 7, 3, 9, 4]) : C = matrix(C) ;

C = matrix([[7, 18, 8], [1, 5, 7], [3, 9, 4]])

The determinant of [ C ] is

> `det(C)` := det(C) : Det(C) = `det(C)` ;

Det(C) = -43

* * *

N.B. The determinant of a ( 1 × 1 ) matrix is the element itself.

Exemplarily, consider a ( 1 × 1 ) matrix [ A ] given as

> A := matrix(1, 1, [a]) : A = matrix(A) ;

A = matrix([[a]])

> `det(A)` := det(A) : Det(A) = `det(A)` ;

Det(A) = a

* * *

N.B. The determinant of a unit matrix is unity .

Exemplarily, consider a ( 3 × 3 ) unit matrix [ U ]:

> U := diag(1, 1, 1) : U = matrix(U) ;

U = matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]])

The determinant of this matrix is

> `det(U)` := det(U) : Det(U) = `det(U)` ;

Det(U) = 1

* * *

N.B. If all the elements of a row (or of a column) in a matrix are zeros , then the determinant of the matrix is zero .

Exemplarily, consider a ( 3 × 3 ) matrix [ A ] given as

> A := matrix(3, 3, [a[11], a[12], a[13], 0, 0, 0, a[31], a[32], a[33]]) : A = matrix(A) ;

A = matrix([[a[11], a[12], a[13]], [0, 0, 0], [a[31...

The determinant of this matrix is

> `det(A)` := det(A) : Det(A) = `det(A)` ;

Det(A) = 0

and the matrix [ A ] is said to be singular .

* * *

N.B. If two rows of a square matrix are equal , then its determinant is zero .

Exemplarily, consider a ( 4 × 4 ) matrix [ A ] given as

> A := matrix(4, 4, [2, 2, 3, 3, 2, 3, 3, 2, 5, 3, 7, 9, 2, 2, 3, 3]) : A = matrix(A) ;

A = matrix([[2, 2, 3, 3], [2, 3, 3, 2], [5, 3, 7, 9...

in which the rows 1 and 4 are equal.

The determinant of this matrix is

> `det(A)` := det(A) : Det(A) = `det(A)` ;

Det(A) = 0

* * *

N.B. The determinant of a matrix [ A ] raised to any positive or negative integer power is equal to the determinant raised to the same power

Det( [ A ] ^ n ) = (Det [ A ] )^ n

Exemplarily, consider a ( 3 × 3 ) non-singular matrix [ A ] given as

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

A = matrix([[2, 1, 3], [4, 2, -1], [2, -1, 1]])

> `det(A)` := det(A) : Det(A) = `det(A)` ;

Det(A) = -28

Let the positive exponent be 3 and the negative exponent -2 .

(a) The values of Det( [ A ] ^ 3 ) and Det( [ A ] ^( -2 )) are

> `det(A^3)` := det(evalm(A^3)) : `det(A^(-2))` := det(evalm(A^(-2))) :

> Det(A^3) = `det(A^3)` ; Det(A^(`-2`)) = `det(A^(-2))` ;

Det(A^3) = -21952

Det(A^`-2`) = 1/784

(b) The values of (Det [ A ] )^ 3 and (Det [ A ] )^( -2 ) are

> `(det(A))^3` := (det(A))^3 : `(det(A))^(-2)` := (det(A))^(-2) :

> [Det(A)]^3 = `(det(A))^3` ; [Det(A)]^(`-2`) = `(det(A))^(-2)` ;

[Det(A)]^3 = -21952

[Det(A)]^`-2` = 1/784

[ For integer exponentiation of matrices, refer to Unit (15). ]

* * *

N.B. The determinant of the product of any square matrices of the same order is equal to the product of the determinants of the matrices

Det( [ A ] [ B ] ) = Det [ A ] Det [ B ]

Let ( 2 × 2 ) matrices [ A ] and [ B ] be given as

> A := matrix(2, 2, [5, 4, -8, 7]) : B := matrix(2, 2, [3, 2, 5, 4]) : A = matrix(A) ; B = matrix(B) ;

A = matrix([[5, 4], [-8, 7]])

B = matrix([[3, 2], [5, 4]])

(a) The determinant of the matrix product, Det( [ A ] [ B ] ) , has the value

> `det(AB)` := det(multiply(A, B)) : Det(A * B) = `det(AB)` ;

Det(A*B) = 134

(b) The product Det [ A ] Det [ B ] is the following number:

> `det(A) det(B)` := det(A) * det(B) : Det(A) * Det(B) = `det(A) det(B)` ;

Det(A)*Det(B) = 134

* * *

N.B. The determinant of the transpose of a square matrix is equal to the determinant of the matrix

Det(Transp [ A ] ) = Det [ A ]

Exemplarily, consider a ( 3 × 3 ) matrix [ A ] given as

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

A = matrix([[1, -2, 3], [0, 4, -2], [6, -1, -1]])

(a) The determinant of the matrix, Det [ A ], has the value

> `det(A)` := det(A) : Det(A) = `det(A)` ;

Det(A) = -54

(b) The determinant of the matrix transpose, Det(Transp [ A ] ) , has the value

> `det(transp(A))` := det(transpose(A)) : Det(Transp(A)) = `det(transp(A))` ;

Det(Transp(A)) = -54

* * *

N.B. Transposition of the following matrix does not change the determinant of the matrix:

> V := matrix(3, 3, [1, 1, 1, a, b, c, a^2, b^2, c^2]) : V = matrix(V) ;

V = matrix([[1, 1, 1], [a, b, c], [a^2, b^2, c^2]])...

(a) The determinant of the matrix, Det [ V ], has the value

> `det(V)` := factor(det(V)) : Det(V) = `det(V)` ;

Det(V) = -(-c+b)*(a-c)*(a-b)

(b) The determinant of the matrix transpose, Det(Transp [ V ] ) , has the value

> `det(transp(V))` := factor(det(transpose(V))) : Det(Transp(V)) = `det(transp(V))` ;

Det(Transp(V)) = -(-c+b)*(a-c)*(a-b)

The determinant of this matrix is called an alternate determinant or alternant . The matrix itself is the transpose of the Vandermonde matrix and may be created automatically using the vandermonde function, viz.

> V := transpose(vandermonde([a, b, c])) : V = matrix(V) ;

V = matrix([[1, 1, 1], [a, b, c], [a^2, b^2, c^2]])...

* * *

N.B. If the elements of a row (or of a column) of a matrix are multiplied by a scalar lambda , then the value of the determinant of the matrix is multiplied by lambda .

Exemplarily, consider the same ( 3 × 3 ) matrix [ A ] as above and assume that a scalar lambda = 3 .

> lambda := 3 :

(a) Let the column j = 2 be multiplied by lambda . This yields the following ( 3 × 3 ) matrix [ B ]:

> j := 2 : B := mulcol(A, j, lambda) : B = matrix(B) ;

B = matrix([[1, -6, 3], [0, 12, -2], [6, -3, -1]])

The determinant of the matrix, Det [ B ], has the value

> `det(B)` := det(B) : Det(B) = `det(B)` ;

Det(B) = -162

which is three times that of the determinant of the matrix [ A ], i.e. Det [ B ] = 3 Det [ A ].

(b) Let the row i = 1 be multiplied by lambda . This yields the following ( 3 × 3 ) matrix [ C ]:

> i := 1 : C := mulrow(A, i, lambda) : C = matrix(C) ;

C = matrix([[3, -6, 9], [0, 4, -2], [6, -1, -1]])

The determinant of the matrix, Det [ C ], has the value

> `det(C)` := det(C) : Det(C) = `det(C)` ;

Det(C) = -162

which is three times that of the determinant of the matrix [ A ], i.e. Det [ C ] = 3 Det [ A ].

* * *

N.B. The determinant of a matrix multiplied by a scalar (whether real or complex) is equal to the product of the matrix determinant and the scalar raised to the power equal to the number of rows, m , or columns, n , in the matrix

Det ( k [ A ]) = k^m Det [ A ] = k^n Det [ A ]

Exemplarily, consider the same ( 3 × 3 ) matrix [ A ] as before and assume that a scalar k = 2 .

> k := 2 :

(a) The determinant of the matrix multiplied by the scalar, Det( k [ A ] ) , has the value

> `det(kA)` := det(k*A) : k := 'k' : Det(k * A) = `det(kA)` ; k := 2 :

Det(k*A) = -432

Notice that the multiplication order, k A or A k , under the det function is not important .

(b) The product of the matrix determinant and the scalar raised to the power equal to the number of rows, m , or columns, n , in the matrix, k^m Det [ A ] and k^n Det [ A ], respectively, may be computed using either of the following alternative methods:

> `k^m det(A)` := k^rowdim(A)*det(A) : k := 'k' : k^m * Det(A) = `k^m det(A)` ; k := 2 :

k^m*Det(A) = -432

> `k^n det(A)` := k^coldim(A)*det(A) : k := 'k' : k^n * Det(A) = `k^n det(A)` ;

k^n*Det(A) = -432

The value of either product, k^m Det [ A ] or k^n Det [ A ], is eight times ( k^3 = 8 ) that of the determinant of the matrix [ A ], i.e. Det( 2 [ A ] ) = 8 Det [ A ].

The functions coldim and rowdim return the number of columns or rows in a matrix, respectively .

* * *

N.B. If a matrix [ B ] is formed from a matrix [ A ] by interchanging two rows or two columns of [ A ], then

Det [ B ] = –Det [ A ]

Exemplarily, consider a ( 4 × 4 ) matrix [ A ] given as

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

A = matrix([[-2, 4, 3, -3], [-2, -3, 6, -2], [-5, 3...

(a) The determinant of [ A ] is

> `det(A)` := det(A) : Det(A) = `det(A)` ;

Det(A) = 1400

(b) The matrix [ B ] formed by interchanging columns 2 and 4 of [ A ], and the determinant of [ B ] are

> B := swapcol(A, 2, 4) : B = matrix(B) ; `det(B)` := det(B) : Det(B) = `det(B)` ;

B = matrix([[-2, -3, 3, 4], [-2, -2, 6, -3], [-5, -...

Det(B) = -1400

(c) The matrix [ B ] formed by interchanging rows 1 and 3 of [ A ], and the determinant of [ B ] are

> B := swaprow(A, 1, 3) : B = matrix(B) ; `det(B)` := det(B) : Det(B) = `det(B)` ;

B = matrix([[-5, 3, -7, -9], [-2, -3, 6, -2], [-2, ...

Det(B) = -1400

This property is sometimes expressed in the following words:

"If two rows (or columns) of a matrix are interchanged, the determinant changes sign."

* * *

N.B. If a matrix [ B ] is formed from a square matrix [ A ] by adding to one row (or column) of [ A ] a scalar times another row (or column) of [ A ], then

Det [ B ] = Det [ A ]

Exemplarily, consider a ( 3 × 3 ) matrix [ A ] given as

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

A = matrix([[4, -2, 3], [0, 4, -2], [6, -1, -3]])

(a) The determinant of [ A ] is

> `det(A)` := det(A) : Det(A) = `det(A)` ;

Det(A) = -104

(b) Let each element of the column j[B] = 2 in a new matrix [ B ] be formed as a sum of the corresponding element in the same column of [ A ] and scalar lambda = k^2 times the corresponding element of the column j[A] = 1 of [ A ], i.e. b[i,j[B]] = a[i,j[A]]+lambda*a[i,j[A]] . Let k = 4 .

> j[A] := 1 : j[B] := 2 : k := 4 : lambda := k^2 :

Therefore, the matrix [ B ] is

> B := addcol(A, j[A], j[B], lambda) : B = matrix(B) ;

B = matrix([[4, 62, 3], [0, 4, -2], [6, 95, -3]])

(c) The determinant of [ B ] is

> `det(B)` := det(B) : Det(B) = `det(B)` ;

Det(B) = -104

(d) Let each element of the row i[B] = 1 in a new matrix [ B ] be formed as a sum of the corresponding element in the same row of [ A ] and scalar lambda = sin(Pi/k) times the corresponding element of the row i[A] = 3 of [ A ], i.e. b[i[B],j] = a[i[A],j]+lambda*a[i[A],j] . Let k = 6 .

> i[A] := 3 : i[B] := 1 : k := 6 : lambda := sin(Pi/k) :

Therefore, the matrix [ B ] is

> B := addrow(A, i[A], i[B], lambda) : B = matrix(B) ;

B = matrix([[7, -5/2, 3/2], [0, 4, -2], [6, -1, -3]...

(e) The determinant of [ B ] is

> `det(B)` := det(B) : Det(B) = `det(B)` ;

Det(B) = -104

The determinants of (a), (c), and (e) are identical.

An obvious implication of the above result is that if a row (or column) of a matrix is expressible as the sum of multiples of other rows (or columns) of the matrix, then the value of the determinant must be zero . This is so because by subtraction of this sum of multiples of other rows (or columns) in question, it is possible to produce a row (or column) containing only zero elements.

Exemplarily, consider a ( 3 × 3 ) matrix [ A ] given as

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

A = matrix([[6, 18, 8], [1, 5, 7], [3, 9, 4]])

Notice that the elements of the first row of [ A ] are equal to the doubled elements of the third row.

Consequently, the determinant of [ A ] is

> `det(A)` := det(A) : Det(A) = `det(A)` ;

Det(A) = 0

* * *

N.B. The determinant of the following matrix

> A := matrix(3, 3, [sin(t+Pi/4), sin(t), cos(t), sin(t+Pi/4), cos(t), sin(t), 1, a, 1-a]) : A = matrix(A) ;

A = matrix([[sin(t+1/4*Pi), sin(t), cos(t)], [sin(t...

is independent of a and is expressible as a function of t only, i.e.

> `det(A)` := det(A) : Det(A) = `det(A)` ;

Det(A) = sin(t+1/4*Pi)*cos(t)-sin(t+1/4*Pi)*sin(t)+...

Some extra operations result in a more compact form of the above, viz.

> `det(A)` := collect(combine(expand(det(A))), cos(2*t)) : Det(A) = `det(A)` ;

Det(A) = (1/2*sqrt(2)-1)*cos(2*t)

* * *

N.B. There are symmetric matrices with elements created according to a specific pattern whose determinant is zero . One of them is the following matrix:

> A := matrix(3, 3, [a^2, a*b, a*c, a*b, b^2, b*c, a*c, b*c, c^2]) : A = matrix(A) ;

A = matrix([[a^2, a*b, a*c], [a*b, b^2, b*c], [a*c,...

From the definition of the determinant, it can be easily noticed that the determinant of [ A ] is zero , which is verified by the following computation:

> `det(A)` := det(A) : Det(A) = `det(A)` ;

Det(A) = 0

This may not be noticeable so easily if such a symmetric matrix is given with numerical elements following the same pattern. For example, let a , b , and c in the above matrix [ A ] be given as

> a := 3*exp(2) : b := -5 : c := 7*sin(Pi/3) : 'a' = a ; 'b' = b ; 'c' = c ;

a = 3*exp(2)

b = -5

c = 7/2*sqrt(3)

Evaluation of [ A ] with these values of a , b , and c yields the following exact symmetric matrix:

> A := map(combine, map(x->eval(x), A)) : A = matrix(A) ;

A = matrix([[9*exp(4), -15*exp(2), 21/2*exp(2)*sqrt...

The determinant of the exact [ A ] is precisely zero , viz.

> `det(A)` := det(A) : Det(A) = `det(A)` ;

Det(A) = 0

while the determinant of [ A ] subjected to floating-point evaluation yielding the matrix

> A := evalf(matrix(A)) : A = matrix(A) ;

A = matrix([[491.3833503, -110.8358415, 134.3813162...

is only approximately equal to zero , viz.

> `det(A)` := det(A) : Det(A) = `det(A)` ;

Det(A) = -.475654669e-4

* * *

N.B. The determinant of a diagonal matrix having no zero elements on the diagonal equals the product of its diagonal elements

Det [ A ] = Product(diag_el[i](A),i = 1 .. n)

Exemplarily, consider a ( 4 × 4 ) diagonal matrix [ A ] given as

> A := diag(3, -4, 2, -5) : A = matrix(A) ;

A = matrix([[3, 0, 0, 0], [0, -4, 0, 0], [0, 0, 2, ...

(a) The determinant of [ A ] is

> `det(A)` := det(A) : Det(A) = `det(A)` ;

Det(A) = 120

(b) The product of the diagonal elements of [ A ] is

> `product(diag_el(A))` := 1 :

> for i to rowdim(A) do for j to coldim(A) do if j = i then `product(diag_el(A))` := `product(diag_el(A))` * A[i,j] fi : od : od :

> `product(diag_el(A))` := `product(diag_el(A))` : i := 'i' :

> Product(diag_el[i](A), i=1..rowdim(A)) = `product(diag_el(A))` ;

Product(diag_el[i](A),i = 1 .. 4) = 120

* * *

N.B. The determinant of a matrix equals the product of the eigenvalues of the matrix.

[ For the eigenvalues of a matrix, refer to Unit (21). ]

* * *

N.B. If the determinant of a matrix of order ( 3 × 3 ) or higher is to be evaluated manually, it is necessary to introduce the notion of a minor and cofactor ( signed minor ) of an element of the matrix.

[ For the definitions of the minor and cofactor , refer to Unit (12). ]

* * *

N.B. In computing determinants of large sparse matrices, it is advisable to use the sparse optional directive. This argument specifies that the method of minor expansion should be used by the program.

[ Refer also to Unit (12) for the Laplace expansion theorem. ]

Exemplarily, compute the determinant of a ( 6 × 6 ) sparse matrix [ E ] given as

> E := array(1..6, 1..6, [(1,1)=15, (1,2)=-10, (1,3)=-5, (2,1)=-10, (2,2)=10, (3,1)=-5, (3,3)=0, (3,4)=-12, (3,5)=0, (4,3)=-12, (4,4)=12, (5,3)=-8, (5,5)=23, (5,6)=0, (6,5)=-15, (6,6)=15], sparse) : E = matrix(E) ;

E = matrix([[15, -10, -5, 0, 0, 0], [-10, 10, 0, 0,...

The determinant of [ E ] is

> `det(E)` := det(E, sparse) : Det(E) = `det(E)` ;

Det(E) = -3519000

* * *

Proceed to Unit (12) for " The minor and cofactor of a matrix element ".

-------------------------------------------------------------------