MATRICES AND MATRIX OPERATIONS: Unit 4
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
-------------------------------------------------------------------
(4) Multiplication of matrices
OBJECTIVES :
• To define the operation of matrix multiplication and state the multiplication conformability rule .
• To introduce the concepts of pre-multiplier and post-multiplier matrices.
• To provide alternative methods of matrix multiplication with Maple .
• To specify the laws obeyed by matrix multiplication.
• To introduce the concept of, and provide an example of, commuting matrices.
• To state and illustrate the various properties of operation of matrix multiplication.
> restart : with(linalg, multiply) :
The matrices to be multiplied must obey the multiplication conformability rule , which states:
"Two matrices can only be multiplied together if the number of columns of the first (left-hand one) is equal to the number of rows of the second."
Such matrices are called conformable or compatible for multiplication. If the matrices do not satisfy this rule, their product is not defined (does not exist).
If two matrices to be multiplied are [
A
] of order
(
×
)
with elements
and [
B
] of order
(
×
)
with elements
,
then the matrix product [
A
] [
B
] is the matrix [
C
] of order
(
×
)
with elements
that are found from the following definition.
The element of the
th row and
th column of [
C
] is obtained by summing the products of each element of the
th row of the
first
matrix with the corresponding elements of the
th column of the
second
matrix.
Thus, the general element of the product matrix [ C ] is given by
+ ... +
i
= 1,...,
m
;
j
= 1,...,
p
The scalar
is called the
inner product
of the
th row of [
A
] with
th column of [
B
].
N.B. Distinction should be made between the above inner product of a row of one matrix with a column of another matrix and the inner product of a sequence of vectors and matrices .
The first factor in the matrix product is called the pre-multiplier and the second is called the post-multiplier . In the product [ A ] [ B ], matrix [ A ] pre-multiplies [ B ], or, alternately, matrix [ A ] is post-multiplied by [ B ].
For example, consider a
(
×
)
matrix [
A
] given as
> A := matrix(3, 4, [a[11], a[12], a[13], a[14], a[21], a[22], a[23], a[24], a[31], a[32], a[33], a[34]]) : A = matrix(A) ;
and a
(
×
)
matrix [
B
] given as
> B := matrix(4, 2, [b[11], b[12], b[21], b[22], b[31], b[32], b[41], b[42]]) : B = matrix(B) ;
The product [
A
] [
B
] is a
(
×
)
matrix, which may be obtained using either of the following alternative methods.
Method 1 . Using the multiply function:
> `AB` := multiply(A, B) : A*B = matrix(`AB`) ;
Method 2 . Using the evalm function and the operator &* (called amperstar in Maple ) that indicates non-commutative matrix multiplication:
> `AB` := evalm(A &* B) : A*B = matrix(`AB`) ;
This matrix multiplication may be displayed in "like-in-a-book" form, namely
> matrix(A) * matrix(B) = matrix(`AB`) ;
Numerical example of matrix multiplication
Let a
(
×
)
matrix [
A
] and a
(
×
)
matrix [
B
] be given as
> A := matrix(3, 4, [1, 2, 1, 0, 0, 1, 1, 3, 1, 2, 1, 4]) : B := matrix(4, 2, [2, 1, 1, 2, 0, 2, -1, 1]) :
> A = matrix(A) ; B = matrix(B) ;
The product [
A
] [
B
] is the following
(
×
)
matrix:
> `AB` := multiply(A, B) : A*B = matrix(`AB`) ;
or, in "like-in-a-book" form,
> matrix(A) * matrix(B) = matrix(`AB`) ;
* * *
N.B. In general, matrix multiplication does not obey the commutative law , i.e.
[ A ] [ B ] is not equal to [ B ] [ A ]
since the product [ B ] [ A ] may not satisfy the multiplication conformability rule, which means that it is not defined. Even if it is defined, it may not be equal to the product [ A ] [ B ].
For example, consider two
(
×
)
matrices [
A
] and [
B
] given as
> A := matrix(2, 2, [1, -1, 0, 4]) : B := matrix(2, 2, [1, -2, 3, 6]) : A = matrix(A) ; B = matrix(B) ;
(a) The product [
A
] [
B
] is the following
(
×
)
matrix:
> `AB` := multiply(A, B) : `A B` = matrix(`AB`) ;
(b) The product [
B
] [
A
] is the following
(
×
)
matrix:
> `BA` := multiply(B, A) : `B A` = matrix(`BA`) ;
It is obvious that the two product matrices of (a) and (b) are not equal.
* * *
N.B. If two matrices satisfy the commutative law of multiplication, i.e.
[ A ] [ B ] = [ B ] [ A ]
they are said to be commuting matrices.
For example, consider two
(
×
)
matrices [
A
] and [
B
] given as
> A := matrix(2, 2, [6, 8, 4, 6]) : B := matrix(2, 2, [15, 20, 10, 15]) : A = matrix(A) ; B = matrix(B) ;
(a) The product [
A
] [
B
] is the following
(
×
)
matrix:
> `AB` := multiply(A, B) : `A B` = matrix(`AB`) ;
(b) The product [
B
] [
A
] is the following
(
×
)
matrix:
> `BA` := multiply(B, A) : `B A` = matrix(`BA`) ;
Both product matrices are equal.
* * *
N.B. The matrix product
[ A ] [ B ] = [ 0 ]
does not necessarily imply either that [ A ] = [ 0 ] or that [ B ] = [ 0 ].
For example, consider two
(
×
)
matrices [
A
] and [
B
] given as
> A := matrix(3, 3, [1, -1, 1, -3, 2, -1, -2, 1, 0]) : B := matrix(3, 3, [1, 2, 3, 2, 4, 6, 1, 2, 3]) :
> A = matrix(A) ; B = matrix(B) ;
The product [
A
] [
B
] is a
(
×
)
zero
matrix
> `AB` := multiply(A, B) : `A B` = matrix(`AB`) ;
Notice that the product [
B
] [
A
] is
not
a
zero
matrix, but it is the following
(
×
)
matrix:
> `BA` := multiply(B, A) : `B A` = matrix(`BA`) ;
which is yet another example for the statement that matrix multiplication does not obey the commutative law .
* * *
N.B. Matrix multiplication is associative , so that
[ A ] ( [ B ] [ C ] ) = ( [ A ] [ B ] ) [ C ]
( [ A ] [ B ] ) [ C ] = [ A ] ( [ B ] [ C ] )
* * *
N.B. Matrix multiplication is distributive with respect to addition , so that
[ A ] ( [ B ] + [ C ] ) = [ A ] [ B ] + [ A ] [ C ]
( [ B ] + [ C ] ) [ A ] = [ B ] [ A ] + [ C ] [ A ]
( [ A ] + [ B ] ) ( [ M ] + [ N ] ) = [ A ] ( [ M ] + [ N ] ) + [ B ] ( [ M ] + [ N ] )
For example, consider
(
×
)
matrices [
A
] and [
B
] given as
> A:=matrix(3, 4, [1, -2, 1, 0, 6, 1, 1, 3, -1, 2, 1, 4]) : B:=matrix(3, 4, [3, 2, -2, 1, 0, -3, 2, 1, 3, 2, 5, -1]) :
> A = matrix(A) ; B = matrix(B) ;
and
(
×
)
matrices [
M
] and [
N
] given as
> M := matrix(4, 2, [1, 2, -1, 3, 0, -2, -1, 7]) : N := matrix(4, 2, [4, -6, 5, -2, 3, 2, -4, 1]) :
> M = matrix(M) ; N = matrix(N) ;
(a) The product
(
[
A
]
+
[
B
]
)
(
[
M
]
+
[
N
]
)
is the following
(
×
)
matrix:
> `(A+B) (M+N)` := evalm((A+B) &* (M+N)) : '(A+B) (M+N)' = matrix(`(A+B) (M+N)`) ;
(b) The sum of the products [
A
]
(
[
M
]
+
[
N
]
) +
[
B
]
(
[
M
]
+
[
N
]
)
is the following
(
×
)
matrix:
> `A(M+N) + B(M+N)` := evalm(A&*(M+N) + B&*(M+N)) :
> 'A(M+N) + B(M+N)' = matrix(`A(M+N) + B(M+N)`) ;
The resultant matrices of (a) and (b) are equal.
* * *
N.B. The cancellation law is not valid for matrix multiplication, i.e. if
[ A ] [ B ] = [ A ] [ C ]
then
[ B ] is not equal to [ C ]
For example, consider three
(
×
)
matrices [
A
], [
B
], and [
C
] given as
> A := matrix(3, 3, [4, 2, 0, 2, 1, 0, -2, -1, 1]) : B := matrix(3, 3, [2, 3, 1, 2, -2, -2, -1, 2, 1]) :
> C := matrix(3, 3, [3, 1, -3, 0, 2, 6, -1, 2, 1]) : A = matrix(A) ; B = matrix(B) ; C = matrix(C) ;
(a) The product [
A
] [
B
] is the following
(
×
)
matrix:
> `AB` := multiply(A, B) : A*B = matrix(`AB`) ;
(b) The product [
A
] [
C
] is the following
(
×
)
matrix:
> `AC` := multiply(A, C) : A*C = matrix(`AC`) ;
Although the product matrices of (a) and (b) are equal, the matrices [ B ] and [ C ] are different.
* * *
Proceed to Unit (5) for " Multiplication of row and column matrices ".
-------------------------------------------------------------------