Matrices-Unit8.mws

MATRICES AND MATRIX OPERATIONS: Unit 8

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

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

(8) Multiplication of a matrix by a number

OBJECTIVES :

To define the operation of multiplication of a matrix by a number.

To provide alternative methods of multiplication of a matrix by a number with Maple .

> restart : with(linalg, diag, multiply, scalarmul) :

Multiplication of a matrix by a number is sometimes called multiplication of a matrix by a scalar to distinguish it from multiplication by another matrix. The scalar may be a real or complex number.

If an ( n × p ) matrix [ A ] is multiplied by a scalar k , whether k is real or complex, then each element in the matrix is multiplied by k .

For example, consider a ( 4 × 2 ) matrix [ A ] given as

> A := matrix(4, 2, [a, b, c, d, e, f, g, h]) : A = matrix(A) ;

A = matrix([[a, b], [c, d], [e, f], [g, h]])

The product k [ A ] can be computed using any of the following alternative methods.

Method 1 . Using the scalarmul function:

> `kA` := scalarmul(A, k) : k*A = matrix(`kA`) ;

k*A = matrix([[k*a, k*b], [k*c, k*d], [k*e, k*f], [...

Method 2 . Using the evalm function:

> `kA` := evalm(k * A) : k*A = matrix(`kA`) ;

k*A = matrix([[k*a, k*b], [k*c, k*d], [k*e, k*f], [...

* * *

N.B. The order of the multiplier and multiplicand in the evalm function does not matter for this type of multiplication. If the scalarmul function is used for scalar mul tiplication, the order of the arguments must be this: (matrix, scalar) .

* * *

Method 3 . Using the map function together with the arrow-type functional operator ( x-> ) :

> `kA` := map(x->x*k, A) : k*A = matrix(`kA`) ;

k*A = matrix([[k*a, k*b], [k*c, k*d], [k*e, k*f], [...

This scalar multiplication of a matrix may be displayed in "like-in-a-book" form, namely

> k * matrix(A) = matrix(`kA`) ;

k*matrix([[a, b], [c, d], [e, f], [g, h]]) = matrix...

* * *

N.B. An essential difference arises in using the evalm and scalarmul functions when zero is the multiplier of a matrix, the former function yielding the scalar zero , the latter a zero matrix.

For example, consider the ( 4 × 2 ) matrix [ A ] used earlier in this Unit.

> `0A` := evalm(0 &* A) : `0 A` = `0A` ;

`0 A` = 0

> `0A` := scalarmul(A, 0) : `0 A` = matrix(`0A`) ;

`0 A` = matrix([[0, 0], [0, 0], [0, 0], [0, 0]])

* * *

It seems to be instructive to see how multiplication of a matrix by a scalar could be executed with Maple if the scalarmul , evalm , and map functions were not available.

To perform this multiplication with Maple , the scalar k must be presented in the form of a scalar matrix [ K ] of order ( m × m ) . According to the multiplication conformability rule, the number of columns and rows in the scalar matrix (which is a diagonal , hence square matrix) must be equal to the number of rows in the post-multiplied ( n × p ) matrix [ A ], or m = n . The product matrix is a new ( n × p ) matrix, every element of which is k times that of the original matrix [ A ].

Therefore, the pre-multiplying scalar matrix [ K ] must be of order ( 4 × 4 ) , viz.

> K := diag(k, k, k, k) : K = matrix(K) ;

K = matrix([[k, 0, 0, 0], [0, k, 0, 0], [0, 0, k, 0...

Thus, the product k [ A ] is obtained as a result of matrix multiplication [ K ] [ A ], viz.

> `kA` := multiply(K, A) : k*A = matrix(`kA`) ;

k*A = matrix([[k*a, k*b], [k*c, k*d], [k*e, k*f], [...

or,

> matrix(K) * matrix(A) = matrix(`kA`) ;

matrix([[k, 0, 0, 0], [0, k, 0, 0], [0, 0, k, 0], [...

This operation may be displayed in "like-in-a-book" form, viz.

> k * matrix(A) = matrix(`kA`) ;

k*matrix([[a, b], [c, d], [e, f], [g, h]]) = matrix...

* * *

Numerical example for multiplication of a matrix by a number

Let the elements of the matrix [ A ] defined above be now assigned numerical values, as follows:

> a:=-1 : b:=2 : c:=1 : d:=3 : e:=3 : f:=-1 : g:=-2 : h:=2 :

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

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

Let the multiplier number be k = 2 .

> k := 2 :

(a) Multiplication using the scalarmul and evalm functions:

> `kA` := scalarmul(A, k) : k * A = matrix(`kA`) ;

2*A = matrix([[-2, 4], [2, 6], [6, -2], [-4, 4]])

> `kA` := evalm(k * A) : k * A = matrix(`kA`) ;

2*A = matrix([[-2, 4], [2, 6], [6, -2], [-4, 4]])

(b) Multiplication without using the scalarmul and evalm functions:

According to the multiplication conformability rule, the pre-multiplying scalar matrix [ K ] must be of order ( 4 × 4 ) and have the form

> k := 'k' : K := subs(k=2, matrix(K)) : K = matrix(K) ; k := 2 :

K = matrix([[2, 0, 0, 0], [0, 2, 0, 0], [0, 0, 2, 0...

Thus, the product 2 [ A ] = [ K ] [ A ] is

> `kA` := multiply(K, A) : k * A = matrix(`kA`) ;

2*A = matrix([[-2, 4], [2, 6], [6, -2], [-4, 4]])

or, in "like-in-a-book" form,

> k * matrix(A) = matrix(`kA`) ;

2*matrix([[-1, 2], [1, 3], [3, -1], [-2, 2]]) = mat...

* * *

Proceed to Unit (9) for " Multiplication involving the unit matrix ".

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