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 (ai⁢j⁢bi⁢j). 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=(ai⁢j)∈Mn×m⁡(ℝ) and B=(bi⁢j)∈Mp×q⁡(ℝ), for positive integers n,m,p,q. Then,

  1. (i)

    The product A⁢B exists if and only if m=p.

  2. (ii)

    Assume m=p, and define coefficients

    ci⁢j=∑1≤k≤mai⁢k⁢bk⁢j for all 1≤i≤n and 1≤j≤q.

    Then the product of A and B is defined to be the matrix A⁢B=(ci⁢j). We write the product as A⁢B or A⋅B, and note that it lives in Mn×q⁡(ℝ).

We use the exponential notation as usual A2=A⋅A and A3=A⋅A⋅A, etc.

Example 1.4.2.

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

    A⁢B=(1⋅2+2⋅11⋅(-1)+2⋅00⋅2+3⋅10⋅(-1)+3⋅01⋅2+0⋅11⋅(-1)+0⋅0)=(4-1302-1)∈M3×2⁡(ℝ).

    Notice that the product B⁢A 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 B∈ℝp, then the product A⁢B 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 A⁢B and B⁢A both are defined, it is not true that A⁢B=B⁢A, 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

    A⁢B=(0010) and B⁢A=(0000).

For real numbers, x,y∈ℝ, if x⋅y=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 X⋅Y=0.

Remark 1.4.5.

If A=(ai)∈M1×n⁡(ℝ) is a row vector and B=(bi)∈ℝn is a column vector, then A⁢B∈ℝ is a 1×1 matrix whose single entry is the scalar product ∑i=1nai⁢bi of the vectors corresponding to A and B. The product B⁢A is an n×n matrix whose (i,j) coefficient is bi⁢aj.

Example 1.4.6. (Zero Matrix)

  • See also Example 1.2. For any matrix A, matrix multiplication gives 0⁢A=0 and A⁢0=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=(101⋱01), so that   (In)i⁢j={1if i=j0otherwise.

    Then for any n×n matrix A, matrix multiplication gives A⁢In=A and In⁢A=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 1≤j≤n, we define the standard basis vectors:

ej=(0⋮010⋮0)∈ℝn and ejt=(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) and e2t=(0 1).

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

v=(v1v2⋮vn)∈ℝn , then 
v=v1⁢(10⋮0)+v2⁢(01⋮0)+…+vn⁢(00⋮1)=v1⁢e1+v2⁢e2+…+vn⁢en.

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 A∈Mn×m⁡(R), the following hold.

  1. (i)

    For all integers 1≤j≤m the column vector A⁢ej∈ℝn is the j-th column of A,

  2. (ii)

    For all integers 1≤i≤n, the row vector eit⁢A∈M1×m⁡(ℝ) is the i-th row of A.

  3. (iii)

    If B∈Mn×m⁡(ℝ) is such that A⁢u=B⁢u for all column vectors u∈ℝm, then A=B.

Proof.

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

A⁢ej∈ℝn and eit⁢A∈M1×m⁡(ℝ).

By definition of matrix-vector multiplication, the p-th coefficient (A⁢ej)p of A⁢ej is

(A⁢ej)p=∑1≤k≤map⁢k⁢(ej)k=ap⁢j,

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

A⁢ej=((A⁢ej)1⋮(A⁢ej)p⋮(A⁢ej)n)=(a1⁢j⋮ap⁢j⋮an⁢j)

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 B∈Mn×m⁡(ℝ) with A⁢u=B⁢u for all u∈ℝm. Since any column vector

u=(u1⋮um)∈ℝm can be written as 
u=u1⁢e1+…+um⁢em=∑1≤j≤muj⁢ej,

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

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

Lemma 1.4.10.

Let A∈Mn×m⁡(R), let B,B1,B2∈Mm×p⁡(R) and let C∈Mp×q⁡(R). The following properties hold.

  1. (i)

    Associativity: A⁢(B⁢C)=(A⁢B)⁢C.

  2. (ii)

    Distributivity:{A⁢(B1+B2)=A⁢B1+A⁢B2 𝑎𝑛𝑑(B1+B2)⁢C=B1⁢C+B2⁢C.

Proof.

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

  1. (i)

    ((A⁢B)⁢C)i⁢j=(A⁢(B⁢C))i⁢j, for arbitrary i,j with 1≤i≤n and 1≤j≤q. By definition,

    ((A⁢B)⁢C)i⁢j=∑1≤k≤p(A⁢B)i⁢k⁢Ck⁢j=∑1≤k≤p(∑1≤l≤mAi⁢l⁢Bl⁢k)⁢Ck⁢j=(*).

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

    (*)=∑1≤l≤mAi⁢l⁢(∑1≤k≤pBl⁢k⁢Ck⁢j)=(A⁢(B⁢C))i⁢j,

    and so, A⁢(B⁢C)=(A⁢B)⁢C as claimed.

  2. (ii)

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

    (A⁢(B1+B2))i⁢j=∑1≤k≤mAi⁢k⁢(B1+B2)k⁢j=∑1≤k≤mAi⁢k⁢((B1)k⁢j+(B2)k⁢j)=(*),

    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

    (*)=∑1≤k≤mAi⁢k⁢(B1)k⁢j+∑1≤k≤mAi⁢k⁢(B2)k⁢j=(A⁢B1)i⁢j+(A⁢B2)i⁢j=(A⁢B1+A⁢B2)i⁢j,

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

∎

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