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
(
×
)
matrix [
A
] is multiplied by a scalar
, whether
is real or complex, then each element in the matrix is multiplied by
.
For example, consider a
(
×
)
matrix [
A
] given as
> A := matrix(4, 2, [a, b, c, d, e, f, g, h]) : A = matrix(A) ;
The product
[
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`) ;
Method 2 . Using the evalm function:
> `kA` := evalm(k * A) : k*A = matrix(`kA`) ;
* * *
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`) ;
This scalar multiplication of a matrix may be displayed in "like-in-a-book" form, namely
> k * matrix(A) = matrix(`kA`) ;
* * *
N.B.
An essential difference arises in using the
evalm
and
scalarmul
functions when
is the multiplier of a matrix, the former function yielding the scalar
, the latter a
zero
matrix.
For example, consider the
(
×
)
matrix [
A
] used earlier in this Unit.
> `0A` := evalm(0 &* A) : `0 A` = `0A` ;
> `0A` := scalarmul(A, 0) : `0 A` = matrix(`0A`) ;
* * *
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
must be presented in the form of a
scalar matrix
[
K
] of order
(
×
)
. 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
(
×
)
matrix [
A
], or
. The product matrix is a new
(
×
)
matrix, every element of which is
times that of the original matrix [
A
].
Therefore, the
pre-multiplying
scalar matrix [
K
] must be of order
(
×
)
, viz.
> K := diag(k, k, k, k) : K = matrix(K) ;
Thus, the product
[
A
] is obtained as a result of matrix multiplication [
K
] [
A
], viz.
> `kA` := multiply(K, A) : k*A = matrix(`kA`) ;
or,
> matrix(K) * matrix(A) = matrix(`kA`) ;
This operation may be displayed in "like-in-a-book" form, viz.
> k * matrix(A) = matrix(`kA`) ;
* * *
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) ;
Let the multiplier number be
.
> k := 2 :
(a) Multiplication using the scalarmul and evalm functions:
> `kA` := scalarmul(A, k) : k * A = matrix(`kA`) ;
> `kA` := evalm(k * A) : k * A = matrix(`kA`) ;
(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
(
×
)
and have the form
> k := 'k' : K := subs(k=2, matrix(K)) : K = matrix(K) ; k := 2 :
Thus, the product
[
A
]
=
[
K
] [
A
] is
> `kA` := multiply(K, A) : k * A = matrix(`kA`) ;
or, in "like-in-a-book" form,
> k * matrix(A) = matrix(`kA`) ;
* * *
Proceed to Unit (9) for " Multiplication involving the unit matrix ".
-------------------------------------------------------------------