Home page for accesible maths 1 Matrices

Style control - access keys in brackets

Font (2 3) - + Letter spacing (4 5) - + Word spacing (6 7) - + Line spacing (8 9) - +

1.4. Matrix multiplication

The next arithmetic operation that we discuss is the multiplication of two matrices. Unlike addition, the good notion of product of matrices, that is, the one that is useful in practice, is not the obvious one, given by multiplying the coefficients (aijbij). An explanation for why it is defined this way is given in Section 6.2, where multiplication corresponds to composing linear transformations. The multiplication of two matrices is defined as follows:

Definition 1.4.1 (Matrix multiplication).

Let A=(aij)Mn×m() and B=(bij)Mp×q(), for positive integers n,m,p,q. Then,

  1. (i)

    The product AB exists if and only if m=p.

  2. (ii)

    Assume m=p, and define coefficients

    cij=1kmaikbkjfor all1inand1jq.

    Then the product of A and B is defined to be the matrix AB=(cij). We write the product as AB or AB, and note that it lives in Mn×q().

We use the exponential notation as usual A2=AA and A3=AAA, etc.

Example 1.4.2.

  • Let A=(120310),B=(2-110). Then, the product AB is defined, and it is

    AB=(12+211(-1)+2002+310(-1)+3012+011(-1)+00)=(4-1302-1)M3×2().

    Notice that the product BA is not defined.

Remark 1.4.3.
  1. (i)

    This definition generalises the definition of the product of a matrix and a column vector, in the sense that if Bp, then the product AB is as given in Definition 1.3.1.

  2. (ii)

    Observe that A2 exists if and only if A is a square matrix.

  3. (iii)

    Given matrices A and B such that AB and BA both are defined, it is not true that AB=BA, in general. That is, matrix multiplication is not a commutative operation (see Example 1.4).

Example 1.4.4.

  • Let A=(001-1) and B=(2010). We calculate

    AB=(0010)andBA=(0000).

For real numbers, x,y, if xy=0, then either x=0 or y=0. This is not true for matrices; indeed the above example shows there are non-zero matrices X,Y such that XY=0.

Remark 1.4.5.

If A=(ai)M1×n() is a row vector and B=(bi)n is a column vector, then AB is a 1×1 matrix whose single entry is the scalar product i=1naibi of the vectors corresponding to A and B. The product BA is an n×n matrix whose (i,j) coefficient is biaj.

Example 1.4.6. (Zero Matrix)

  • See also Example 1.2. For any matrix A, matrix multiplication gives 0A=0 and A0=0, where 0 is the zero matrix of the appropriate dimensions.

Example 1.4.7. (Identity Matrix)

  • Define the n×n identity matrix as

    In=(10101), so that   (In)ij={1if i=j0otherwise.

    Then for any n×n matrix A, matrix multiplication gives AIn=A and InA=A.

Before we establish further results, we need one more piece of notation which we will use throughout.

Definition 1.4.8.

Let n. For each integer j with 1jn, we define the standard basis vectors:

ej=(00100)nandejt=(0 0 1 0 0)M1×n()

where in both cases the only non-zero coefficient is the j-th one.

For example, if n=2, then we consider vectors of size 2 and we have

e1=(10),e2=(01),e1t=(1 0)ande2t=(0 1).

The vectors ej are ubiquitous, in the sense that we can express any vector of n, for any n1, as a linear combination of the ej’s. In other words, if

v=(v1v2vn)n, then
v=v1(100)+v2(010)++vn(001)=v1e1+v2e2++vnen.

The next result is an instance that illustrates the usefulness of the ei’s.

Proposition 1.4.9.

Given positive integers n and m, and a matrix AMn×m(R), the following hold.

  1. (i)

    For all integers 1jm the column vector Aejn is the j-th column of A,

  2. (ii)

    For all integers 1in, the row vector eitAM1×m() is the i-th row of A.

  3. (iii)

    If BMn×m() is such that Au=Bu for all column vectors um, then A=B.

Proof.

(i) First, we check that the sizes are correct, i.e.

AejnandeitAM1×m().

By definition of matrix-vector multiplication, the p-th coefficient (Aej)p of Aej is

(Aej)p=1kmapk(ej)k=apj,

because all the coefficients (ej)k are zero except the j-th one. It follows that

Aej=((Aej)1(Aej)p(Aej)n)=(a1japjanj)

is the j-th column of A, as required.

(ii) The row version is proven likewise. Try it!

For (iii), assume that we are given a matrix BMn×m() with Au=Bu for all um. Since any column vector

u=(u1um)mcan be written as
u=u1e1++umem=1jmujej,

we only consider the vectors ej. Now, the assumption also says that we have Aej=Bej for all j. Therefore, by (i), the j-th columns of A and B are equal, for all 1jm, and hence A and B are equal. ∎

Although matrix multiplication is not commutative (i.e. ABBA in general), it is associative and distributes over addition. In other words:

Lemma 1.4.10.

Let AMn×m(R), let B,B1,B2Mm×p(R) and let CMp×q(R). The following properties hold.

  1. (i)

    Associativity: A(BC)=(AB)C.

  2. (ii)

    Distributivity:{A(B1+B2)=AB1+AB2𝑎𝑛𝑑(B1+B2)C=B1C+B2C.

Proof.

For convenience in this proof, let us write Xij for the (i,j) coefficient of a matrix X. We need to show that

  1. (i)

    ((AB)C)ij=(A(BC))ij, for arbitrary i,j with 1in and 1jq. By definition,

    ((AB)C)ij=1kp(AB)ikCkj=1kp(1lmAilBlk)Ckj=(*).

    From associativity, commutativity and distributivity properties of the operations in , we may rearrange (*) as

    (*)=1lmAil(1kpBlkCkj)=(A(BC))ij,

    and so, A(BC)=(AB)C as claimed.

  2. (ii)

    We show one equality and leave the other as an exercise. We have

    (A(B1+B2))ij=1kmAik(B1+B2)kj=1kmAik((B1)kj+(B2)kj)=(*),

    where this latter equality holds by definition of matrix addition. As in (i), we use the well-known properties of the operations in in order to recast (*) as

    (*)=1kmAik(B1)kj+1kmAik(B2)kj=(AB1)ij+(AB2)ij=(AB1+AB2)ij,

    Therefore, A(B1+B2)=AB1+AB2 as required.

An important consequence of this result is that for products of any number of matrices, brackets are unimportant. Instead of (AB)C or A(BC) we just write ABC. Similarly we write ABCD to denote any product like (AB)(CD) or A((BC)D).