# Introduction to matrices

To start off our introduction to matrices, we will first show you that a matrix is nothing but a convenient way to organize data with rows and columns.

Suppose you have a business selling T-shirts and pants. The table below shows the number of items sold for 5 days.

 Monday Tuesday Wednesday Thursday Friday T-shirt 8 1 5 0 15 Pants 1 6 10 4 0

You may re-organize the number of T-shirts and pants sold from Monday through Friday using the matrix below.

$$\begin{bmatrix} 8 & 1 & 5 & 0 & 15\\ 1 & 6 & 10 & 4 & 0\\ \end{bmatrix}$$

As you can see, a matrix is a rectangular array of numbers in rows and columns.

## Matrix notation

In general, we can write a matrix with m rows and n columns as shown below.

$$A = [a_{ij}] = \begin{bmatrix} a_{11} & a_{12} & a_{13} & . . . & a_{1n}\\ a_{21} & a_{22} & a_{23} & . . . & a_{2n}\\ a_{31} & a_{32} & a_{33} & . . . & a_{3n}\\ . & . & . & & .\\ . & . & . & & .\\ . & . & . & & .\\ a_{m1} & a_{m2} & a_{m3} & . . . & a_{mn}\\ \end{bmatrix}$$

We use a capital letter such as A, B, or C to represent or name a matrix as shown above.

We use lower-case letters with double subscripts to denote the entries of the matrix. For example, a36 read " a sub three six, " indicates the entry in the third row and the sixth column.

A general term is represented by aij and aij indicates the entry in ith row and jth column.

Going back to the example above about T-shirts and pants, we see that the matrix above has 2 rows and 5 columns and we say the matrix is a 2 × 5 matrix. That is, the order or dimensions of the matrix is 2 × 5. Learn more about writing the dimensions of a matrix.

2 × 5 is read 2 by 5 and it does not mean multiplication!

Notice that the number of rows is listed first and that is the way it goes with matrices.

If 4 × 3 represent the dimensions of a matrix, the matrix has 4 rows and 3 columns.

## Elements of a matrix

$$A = \begin{bmatrix} 8 & 1 & 5 & 0 & 15\\ 1 & 6 & 10 & 4 & 0\\ \end{bmatrix}$$

Each number in a matrix is a matrix element. We like to locate the position of elements when working with matrices.

To locate elements for matrix A, use a lower case letter and a subscript with two numbers.

The number on the left of the subscript represents the row the element is located.

The number on the right of the subscript represents the column the element is located.

a23 is the element in the second row and third column.

a23 = 10

a15 is the element in the first row and fifth column.

a15 = 15

Don't let the 15 confuse you. The number in the first row and fifth column does not have to be 15. It could be anything!

Now, let's us re-organize the information above about selling T-shirts and pants!

 T-shirt Pants Monday 8 1 Tuesday 1 6 Wednesday 5 10 Thursday 0 4 Friday 15 0

$$As \ a \ matrix, \ we \ can \ write \ B \ = \begin{bmatrix} 8 & 1\\ 1 & 6 \\ 5 & 10\\ 0 & 4\\ 15 & 0\\ \end{bmatrix}$$

The dimensions of matrix B is 5 × 2.

Important concept:

Although matrices A and B are describing the same situation, the matrices are not equal!

Two matrices are equal when they have the same dimensions and equal corresponding elements.

Simply put, write down a matrix and then write down again the exact same matrix. These two matrices are equal!

## Types of matrices

• Square matrix
• Rectangular matrix
• Row matrix
• Column matrix
• Diagonal matrix
• Identity matrix
• Zero matrix
• Singleton matrix

### Square matrix

A square matrix is a matrix with the same number of columns as rows. Matrices C, D, E, and F are square matrices.

$$C = \begin{bmatrix} a & b\\ c & d\\ \end{bmatrix} D = \begin{bmatrix} 5 & -1\\ 4 & 0\\ \end{bmatrix} E = \begin{bmatrix} a & b & c\\ d & e & f\\ g & h & i\\ \end{bmatrix}$$ $$F = \begin{bmatrix} 0 & 1 & 0\\ 12 & -1 & 6\\ -2 & 0 & 2\\ \end{bmatrix}$$

### Rectangular matrix

In a rectangular matrix, the number of rows is not equal to the number of columns.

$$\begin{bmatrix} 2 & 0 & -2 & 8 & 0\\ 5 & 6 & 0 & -6 & 1\\ -7 & 3 & 20 & 1 & -9\\ \end{bmatrix}$$

### Row matrix

A row matrix has only a single row and at least 2 columns.

$$\begin{bmatrix} 8 & -4 & 3 & 1 & 2\\ \end{bmatrix}$$

### Column matrix

A column matrix has only a single column and at least 2 rows.

$$\begin{bmatrix} 4\\ 2 \\ -6\\ 0\\ 1\\ \end{bmatrix}$$

### Singleton matrix

A singleton matrix has only one element. A singleton matrix has only 1 row and 1 column.

$$\begin{bmatrix} 745\\ \end{bmatrix}$$

### Diagonal matrix

A diagonal matrix is a square matrix with any number on the main diagonal and 0's elsewhere.

$$\begin{bmatrix} 8 & 0 & 0 & 0 & 0\\ 0 & -2 & 0 & 0 & 0\\ 0 & 0 & 4 & 0 & 0\\ 0 & 0 & 0 & 3 & 0\\ 0 & 0 & 0 & 0 & 1\\ \end{bmatrix}$$

### Identity matrix

An identity matrix is a square matrix with 1's on the main diagonal and 0's elsewhere. An identity matrix is denoted by

$$I = \begin{bmatrix} 1 & 0 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 & 0\\ 0 & 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 0 & 1\\ \end{bmatrix}$$

### Zero matrix

All elements of an m × n zero matrix are zero. The following matrix is a zero matrix.

$$\begin{bmatrix} 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0\\ \end{bmatrix}$$

To add matrices A and B with the same dimensions, just add the corresponding entries or elements.

$$A = \begin{bmatrix} a & b & c\\ d & e & f\\ \end{bmatrix} B = \begin{bmatrix} g & h & i\\ j & k & l\\ \end{bmatrix}$$
$$A + B = \begin{bmatrix} a & b & c\\ d & e & f\\ \end{bmatrix} + \begin{bmatrix} g & h & i\\ j & k & l\\ \end{bmatrix}$$
$$A + B = \begin{bmatrix} a + g & b + h & c + i\\ d + j & e + k & f + l\\ \end{bmatrix}$$

Matrix subtraction

If two matrices A and B have the same dimensions, then A - B  = A + (-B)

## Scalar multiplication

The product of a matrix and a number is a scalar product. The scalar product of a matrix A and a number k is the matrix kA. We find kA by multiplying each element of A by the number k. The number k is called scalar.

$$A = \begin{bmatrix} 2 & -3\\ 1 & 0\\ \end{bmatrix}$$

Find the scalar product 4A if A is equal to the matrix immediately above

$$4A = 4\begin{bmatrix} 2 & -3\\ 1 & 0\\ \end{bmatrix} = \begin{bmatrix} 4(2) & 4(-3)\\ 4(1) & 4(0)\\ \end{bmatrix}$$
$$4A = \begin{bmatrix} 8 & -12\\ 4 & 0\\ \end{bmatrix}$$

## Transpose of a matrix

Starting from top to bottom, the "transpose" of a matrix is found by turning each row of the matrix into a column.

The first row becomes the first column

The second row becomes the second column

And so on ...

Suppose A is a matrix. The letter T is used as a superscript for A so that AT is the transpose of A

$$A = \begin{bmatrix} 8 & 1 & 5 & 0 & 15\\ 1 & 6 & 10 & 4 & 0\\ \end{bmatrix} A^T = \begin{bmatrix} 8 & 1\\ 1 & 6 \\ 5 & 10\\ 0 & 4\\ 15 & 0\\ \end{bmatrix}$$

## Matrix multiplication

Let A = [aij] be an m × n matrix and let B = [bij] be an n × p matrix.

The product AB = [cij] is an m × p matrix, where cij = ai1 × b1j + ai2 × b2j + ai3 × b2j + ... + ain × bnj

To find the entry cij in AB, just multiply the entries in row i of matrix A by the entries in column j of matrix B.

$$A = \begin{bmatrix} 4 & 1\\ 3 & 1\\ \end{bmatrix} B = \begin{bmatrix} 1 & -1\\ -3 & 4\\ \end{bmatrix}$$
$$A × B = \begin{bmatrix} 4 & 1\\ 3 & 1\\ \end{bmatrix} × \begin{bmatrix} 1 & -1\\ -3 & 4\\ \end{bmatrix}$$ $$A × B = \begin{bmatrix} 4 × 1 + 1 × -3 & 4 × -1 + 1 × 4\\ 3 × 1 + 1 × -3 & 3 × -1 + 1 × 4\\ \end{bmatrix}$$ $$A × B = \begin{bmatrix} 4 + -3 & -4 + 4\\ 3 + -3 & -3 + 4\\ \end{bmatrix}$$ $$A × B = \begin{bmatrix} 1 & 0\\ 0 & 1\\ \end{bmatrix}$$

## Inverse of a matrix

Perhaps you recall that for every nonzero real number x, there is a multiplicative inverse 1/x or x-1, such that x(x-1) = x-1(x) = 1. You can do something similar to find the inverse of a matrix.

Inverse of a matrix

For an n × n matrix A, the inverse of the matrix A-1 exists if A × A-1 = A-1 × A = I

I is the identity matrix.

In the previous section about matrix multiplication, matrix B is the inverse of matrix A.

## Take this introduction to matrices quiz to check your understanding of this lesson.

Continue this introduction to matrices with some related topics: