Learn Without Walls
← Module 2 Home Lesson 1 of 4 Next Lesson →

Lesson 1: Matrix Addition, Scalar Multiplication, Matrix Multiplication

Estimated time: 35-45 minutes

Learning Objectives

By the end of this lesson, you will be able to:

Matrix Notation and Size

Matrix: A rectangular array of numbers arranged in rows and columns. An m x n matrix has m rows and n columns. The entry in row i, column j is denoted a_{ij}.

Example: Matrix Dimensions

A = [ 1   2   3 ]
    [ 4   5   6 ]

A is a 2 x 3 matrix (2 rows, 3 columns). Entry a_{12} = 2 (row 1, column 2). Entry a_{21} = 4 (row 2, column 1).

Matrix Addition

Matrix Addition: Two matrices A and B can be added only if they have the same dimensions. The sum A + B is computed entry by entry: (A + B)_{ij} = a_{ij} + b_{ij}.

Worked Example

[ 1   2 ]  +  [ 5  -1 ]  =  [ 1+5   2+(-1) ]  =  [ 6   1 ]
[ 3   4 ]     [ 0   2 ]     [ 3+0   4+2   ]     [ 3   6 ]

Scalar Multiplication

Scalar Multiplication: To multiply a matrix by a scalar c, multiply every entry by c: (cA)_{ij} = c * a_{ij}.

Worked Example

3 * [ 1  -2 ]  =  [ 3  -6 ]
    [ 4   0 ]     [ 12   0 ]

Matrix Multiplication

Matrix multiplication is the most important (and most involved) operation. It is NOT computed entry by entry.

Matrix Multiplication: If A is m x n and B is n x p, then the product AB is an m x p matrix. The entry (AB)_{ij} is computed by taking the dot product of row i of A with column j of B.

Size requirement: The number of columns of A must equal the number of rows of B.

Size Check for AB

(m x n) times (n x p) = (m x p). The inner dimensions must match.

Worked Example: 2x2 Times 2x2

A = [ 1   2 ]    B = [ 5   6 ]
    [ 3   4 ]       [ 7   8 ]

AB:

Entry (1,1): row 1 of A dot column 1 of B = 1(5) + 2(7) = 5 + 14 = 19

Entry (1,2): row 1 of A dot column 2 of B = 1(6) + 2(8) = 6 + 16 = 22

Entry (2,1): row 2 of A dot column 1 of B = 3(5) + 4(7) = 15 + 28 = 43

Entry (2,2): row 2 of A dot column 2 of B = 3(6) + 4(8) = 18 + 32 = 50

AB = [ 19   22 ]
     [ 43   50 ]

Worked Example: 2x3 Times 3x1

[ 1   0   2 ]  *  [ 3 ]  =  [ 1(3)+0(1)+2(4) ]  =  [ 11 ]
[ 2   1  -1 ]     [ 1 ]     [ 2(3)+1(1)+(-1)(4) ]    [ 3 ]
                  [ 4 ]

A is 2x3, B is 3x1. Inner dimensions match (3=3). Result is 2x1.

Worked Example: Multiplication Not Defined

If A is 2x3 and B is 2x3, can we compute AB?

No! A has 3 columns but B has 2 rows. The inner dimensions (3 and 2) do not match, so AB is not defined.

The Identity Matrix

Identity Matrix I_n: The n x n matrix with 1s on the main diagonal and 0s everywhere else. For any m x n matrix A: I_m A = A and A I_n = A.

Example

I_3 = [ 1   0   0 ]
      [ 0   1   0 ]
      [ 0   0   1 ]

The identity matrix is the matrix equivalent of the number 1: multiplying by it changes nothing.

Check Your Understanding

1. If A is 3x4 and B is 4x2, what is the size of AB? Can you compute BA?

Answer: AB is 3x2. BA is NOT defined because B is 4x2 and A is 3x4 -- the inner dimensions (2 and 3) do not match.

2. Compute: 2 * [ 3 -1 ; 0 4 ] + [ 1 2 ; -3 1 ]

Answer: 2*[3 -1; 0 4] = [6 -2; 0 8]. Then [6 -2; 0 8] + [1 2; -3 1] = [7 0; -3 9].

3. Compute the product: [ 1 0 ; 0 -1 ] * [ 3 ; 5 ]

Answer: [ 1(3)+0(5) ; 0(3)+(-1)(5) ] = [ 3 ; -5 ]. This matrix flips the second component -- it is a reflection.

4. Is matrix multiplication commutative? That is, does AB = BA in general?

Answer: No. In general AB does not equal BA. In fact, even when both products are defined, they are usually different. Example: for 2x2 matrices, AB and BA are both defined but typically AB is not equal to BA.

Key Takeaways

Next Lesson

Lesson 2 covers the properties of matrix arithmetic and the transpose operation.

Start Lesson 2

Module Home

Module 2 Home