# Definition and Terminology

## Definition

A matrix is an array of mathematical objects. It could contain real numbers, complex numbers, functions even other matrices. For our purposes, we will focus on real numbers. We have seen vectors in various contexts in this course. One that we haven't focused on is vectors as representations of the vertices that make up an object defined by a polygonal mesh. In future chapters, we will look at how you can manipulate such an object by manipulating its vectors. These manipulations can be represented by matrices. We think of these matrices as operating on the vectors. But before we can get to all of that we need to aquint ourselves with what matrices are and how they behave algebraically.

We usually name a matrix with an uppercase letter and name its entries with the corresponding lower case letter.

The entry $a_{ij}$ refers to the entry in matrix $A$ in the *i*th row and *j*th column. For brevity we do not put a comma between the *i* and *j* values unless the number of columns or rows exceeds 9.

Exercise

For the matrix $A=\left [ \begin{array}{ccc} 5 & -0.12 & 8\\ 0 & \pi & \frac{1}{3}\\ -1 & -10 & -100 \\ \end{array} \right ]$ what would $a_{2,3}$ be?

## Dimension

The dimension of a matrix refers to the number of columns a matrix has. A matrix with *m* rows and *n* columns is said to have dimension $m \times n$. The notation $A_{m \times n}$ is used to idicate a matrix named $A$ that has dimension $m \times n$.

A matrix that has the same number of rows as columns or in other words has dimension $n \times n$ is called a **square matrix**. The name refers to the fact that the matrix is square in shape.

Exercise

What is the dimension of the matrix $B=\left [ \begin{array}{cccc} -3 & -2 & 6 & 10\\ 0 & \pi & \frac{\pi}{3} & -1\\ \end{array} \right ]$ ?

# Operations

## Addition/Subtraction

In order to add or subtract two matrices with the same dimension, we add or subtract the corresponding entries. That is to say,

(2)It is important that both matrices have the same dimension so that there is a corresponding entry to add or subtract. Otherwise, the operation is said to be undefined.

Exercise

Find the sum, $A+B$ and $A-B$ for $A= \left [ \begin{array}{ccc} 2 & -2 & 1 \\ 0 & 15 & 100\\ \end{array} \right ]$ and $B=\left [ \begin{array}{ccc} -3 & -2 & 6 \\ 0.4 & -5.3 & -1\\ \end{array} \right ]$

Exercise

Find the sum, $A+B$ and $A-B$ for $A= \left [ \begin{array}{cc} 5 & 8 \\ -9 & 5 \\ \end{array} \right ]$ and $B=\left [ \begin{array}{ccc} 3 & 6 & 7 \\ -8 & 0 & 1\\ \end{array} \right ]$

## Scalar Multiplication

In order to multiply a matrix by a scalar, we multiply every entry in the matrix by the scalar. That is to say,

(3)

Exercise

Find, 5$A$ where $A=\left [ \begin{array}{ccc} 4 & 0 & -2 \\ 6 & 1 & -0.2\\ \end{array} \right ]$

## Matrix Multiplication

In order to multiply two matrices, we take the dot product of each row in the first matrix with each column in the second matrix. IN other words,

(4)**Example**

Note that in order for each row in matrix $A$ to be the same length as each column in matrix $B$, we must have their inner dimensions match. In other words $A_{p \times q}$ and $B_{q \times r}$. If that inner dimension $q$ does not match the operation is undefined.

Exercise

Find the products, $AB$ and $BA$ for $A= \left [ \begin{array}{ccc} 2 & -2 & 1 \\ 0 & 15 & 100\\ \end{array} \right ]$ and $B=\left [ \begin{array}{cc} -3 & -2 \\ 4 & -5\\ \end{array} \right ]$

## Transpose

The transpose $(A^T)$ of a matrix $A$ is one in which each row in the original matrix becomes a column in the resulting matrix.

**Example**

This operation can be useful as a way of changing the way vectors are represented in a matrix. Say for example you had a matrix that was storing vertices of an object as column vectors. This is the standard in OpenGL. If you needed to use this in Direct3D which uses row vectors you could change that representation to a matrix of row vectors instead.

## Determinant

The determinant of a matrix is related to the content of the space spanned by the vectors that make up the matrix. It has many other uses as we have already seen in the calculation of the cross product and in Cramer's Rule. The definition of the determinant is recursive. The 3D determinant is based on the 2D determinant, the 4D determinant is based on the 3D determinant and so on. For our purposes, we will just focus on 1D, 2D, and 3D determinants.

### 1D

(7)Note that the absolute value of this determinant would just give the magnitude of the vector $\vec{u}=<a>$.

### 2D

(8)Note that the absolute value of this determinant would give the area of the parallelogram spanned by the vectors $\vec{u}=<a,b>$ and $\vec{v}=<c,d>$

### 3D

(9)Note that the absolute value of this determinant would give you the volume of the parallelepiped spanned by $\vec{u}=<a,b,c>$, $\vec{v}=<d,e,f>$, and $\vec{w}=<g,h,i>$.

Note that the determinant is only defined for square matrices.

**Example**

Exercise

Find $|A|$ for the matrix $A=\left [ \begin{array}{ccc} 6 & -1 & 3\\ 2 & 4 & 5\\ -3 & 8 & 0\\ \end{array} \right ]$

## Matrix Division and the Inverse

Using the previously mentioned operations we could solve equations whose unknowns are now matrices instead of real numbers. To do so we would use take our ideas from Algebra and apply them to matrices thereby defining a matrix algebra. As we know from algebra, solving equations involves applying the inverse operations in order to isolate the unknown quantity. In this case an unknown matrix. The problem we have is that we have yet to define the inverse of matrix multiplication. A matrix division if you will.

Recall from algebra that we accomplish division by multiplication of the reciprocal. The reciprocal is what we would call the multiplicative inverse. The multiplicative inverse is defined to be that number which when multiplied yield the multiplicative identity, 1. For example,

Therefore, the multiplicative inverse of $4$ is $\frac{1}{4}$ and vice versa. The nice thing about real numbers is that every real number has a multiplicative inverse, except 0. Therefore, we can divide by any number except 0.

If we were to define a matrix division, we would first need to determine the multiplicative identity for matrix multiplication. In other words, we would need to find the matrix $I$, such that for any matrix $A$,

As you can confirm for yourself this identity matrix would need to be of the form,

(13)So in general, you have an $n \times n$ matrix with ones on the diagonal and zeros everywhere else. So now the question is, given a matrix $A$ can we find its multiplicative inverse $A^{-1}$ such that,

(14)If we can find such a matrix, we could solve a matrix algebra question, such as,

(15)by applying the inverse matrix to the left side of both sides of the equation, as follows.

(16)As it turns out, unlike the real numbers, there are many matrices that have no multiplicative inverse. Actually, the invertibility of a matrix can be determined by its determinant. If $|A|=0$ the matrix has no inverse. For our purposes in this class, we do not need to do matrix division, so we will not go into the process of finding the inverse of a matrix. The process is rather involved. If you would like to know more, check out this video

# Exercises

1) Given the matrices

(17)a) Find $2A-3B$

b) Find $AB$

c) Find $BA$

d) Find $A^T$

2) Given the matrices

(18)a) Find $AB$

b) Find $BA$

3) Find $|A|$ for the matrix

(19)4) Find $|B|$ for the matrix and sketch a picture of the volume it represents.

(20)5) If $A_{5 \times 7}$, what dimensions must $B$ have in order for $AB$ to be defined?

6) If $A_{5 \times 7}$, what dimensions must $B$ have in order for $BA$ to be defined?

7) Given two n-dimensional vectors $\vec{u}$ and $\vec{v}$, say we represent them as two $n \times 1$ matrices $U$ and $V$. How would we calculate the dot product of $\vec{u}$ and $\vec{v}$, using matrix operations on $U$ and $V$.

8) Verify with matrix multiplication that if $A=\left [ \begin{array}{cc} 2 & -14 \\ 6 & -43 \\ \end{array} \right ]$ , then $A^{-1}=\left [ \begin{array}{cc} \frac{43}{2} & 7 \\ 3 & 1 \\ \end{array} \right ]$