Matrices-Unit20.mws

MATRICES AND MATRIX OPERATIONS: Unit 20

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

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

(20) Trace of a matrix

OBJECTIVES :

To define the trace of a square matrix.

To specify and illustrate properties of the matrix trace.

> restart : interface(warnlevel=0) : with(linalg, inverse, trace) :

The trace of a square matrix is the sum of the elements of the principal diagonal of the matrix.

Consider a ( 3 × 3 ) matrix [ A ] given as

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

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

The trace of the matrix, Trace [ A ], is

> `trace(A)` := trace(A) : Trace(A) = `trace(A)` ;

Trace(A) = a[11]+a[22]+a[33]

For instance, consider a ( 3 × 3 ) matrix [ A ] containing numerical elements as follows:

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

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

The trace of [ A ] is

> `trace(A)` := trace(A) : Trace(A) = `trace(A)` ;

Trace(A) = 6

* * *

N.B. If two square matrices, [ A ] and [ B ], are of the same order, then the trace of their sum is equal to the sum of their traces

Trace( [ A ] + [ B ] ) = Trace [ A ] + Trace [ B ]

For example, consider the matrix [ A ] as above and matrix [ B ] given as

> B := matrix(3, 3, [8, 2, 1, 1, 3, 0, 4, 2, 3]) : B = matrix(B) ;

B = matrix([[8, 2, 1], [1, 3, 0], [4, 2, 3]])

(a) The trace of the sum matrix, Trace( [ A ] + [ B ] ) , is

> `trace(A+B)` := trace(A + B) : Trace(A + B) = `trace(A+B)` ;

Trace(A+B) = 20

(b) The sum of traces of both matrices, Trace [ A ] + Trace [ B ], is

> `trace(A)+trace(B)` := trace(A) + trace(B) : Trace(A) + Trace(B) = `trace(A)+trace(B)` ;

Trace(A)+Trace(B) = 20

* * *

N.B. If two square matrices, [ A ] and [ B ], are of the same order, then the trace of their product does not depend on the order in matrix multiplication

Trace( [ A ] [ B ] ) = Trace( [ B ] [ A ] )

Exemplarily, consider the same matrices [ A ] and [ B ] that were used above.

(a) The trace of the product [ A ] [ B ] is

> `trace(AB)` := trace(evalm(A &* B)) : Trace(`A B`) = `trace(AB)` ;

Trace(`A B`) = 47

(b) The trace of the product [ B ] [ A ] is

> `trace(BA)` := trace(evalm(B &* A)) : Trace(`B A`) = `trace(BA)` ;

Trace(`B A`) = 47

* * *

N.B. If matrix [ B ] is an invertible matrix of the same order as matrix [ A ], then the trace of the product matrix of the inverse of [ B ] and [ A ] [ B ] is equal to the trace of [ A ]

Trace{(Inv [ B ] ) [ A ] [ B ] } = Trace [ A ]

Exemplarily, consider the same matrices [ A ] and [ B ] as before.

(a) The trace of the product matrix of the inverse of [ B ] and [ A ] [ B ] is

> `trace((inv(B) AB)` := trace(evalm(inverse(B) &* A &* B)) :

> Trace(Inv(B)*A*B) = `trace((inv(B) AB)` ;

Trace(Inv(B)*A*B) = 6

(b) The trace of [ A ] is

> `trace(A)` := trace(A) : Trace(A) = `trace(A)` ;

Trace(A) = 6

* * *

Proceed to Unit (21) for " Eigenvalues and eigenvectors of matrices ".

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