Matrix#
A matrix is some table of numbers, symbols, or mathematical objects coming from a set. A matrix has a “height” and a “width” corresponding to the number of rows and the number of columns, respectively. We describe a matrix first by its number of rows and then by its number of columns. A “two by three matrix of integers”, shown below, has two rows, three columns, and its entries are integers.
For a particular \((i, j)\) index, we can say the \((i, j) \text{th}\) entry of a matrix is the element of the matrix in the \(i \text{th}\) row and the \(j \text{th}\) column. In the previous matrix, \(5\) is the \((1, 2)\) entry; \(-7\) is the \((2, 1)\) entry. Generally, we can have an \(m\) by \(n\) matrix with \(m\) rows and \(n\) columns. An \(m\) by \(n\) matrix can be denoted as \(A_{m \times n}\).
We give special names to matrices with certain dimensions:
When \(m = 1\), we have a row vector. Below is a row vector with 7 entries.
When \(n = 1\), we have a column vector. Below is a column vector with 6 entries.
When \(m = n\), we have a square matrix. We say a square matrix is of order \(n\) for a matrix with dimension \(n\) by \(n\). A square matrix of order \(3\) is shown below.
Operations#
When matrices have entries coming from a set with supports addition and multiplication, like real numbers, integers, or even more general objects like polynomials, it is possible to combine them when a generalized form of arithmetic.
Scalar Multiplication#
Scalar multiplication is a simple operation which multiplies a single number against each entry of a matrix to produce another matrix of the same dimensions.
Say \(A = (a_{i, j})\) is an \(m\) by \(n\) integer matrix. Given some other integer \(c\), \(cA\) is another \(m\) by \(n\) matrix where:
Example
Addition and Subtraction#
Two matrices can be added or subtracted when they have the same dimensions. For two \(m\) by \(n\) matrices, \(A = (a_{i, j})\) and \(B = (b_{i, j})\), their sum \(A + B\) is equal to \((a_{i, j} + b_{i, j})\). That is, each entry of \(A\) is added to the corresponding entry in \(B\) in the same position.
By scalar multiplication, we can define subtraction via addition:
To add or subtract matrices they must be of the same dimensions. Every entry in the first matrix must have a corresponding entry in the second matrix to be added to.
Example
Matrix Multiplication#
Matrix multiplication is much more involved than addition. First, we must consider under which conditions two matrices can be multiples.
Matrix multiplication between two matrices is only defined when the number of columns in the left-hand matrix equals the number of rows in the right-hand matrix. The result of the multiplication is another matrix whose number of rows equals the left-hand matrix’s and whose number of columns equals the right-hand matrix’s.
In this notation, the “inner” dimensions must be the same, and the “outer” dimensions give the dimensions of the product. In this case, \(n = n\) are the inner dimensions, and \(m, p\) are the outer dimensions.
But how do we define the entries of the product \(C = (c_{i, j})\)? Each entry of the matrix product \(c_{i, j}\) is an inner product of the \(i \text{th}\) row of \(A\) and the \(j \text{th}\) column of B.
Therefore, the matrix multiplication \(A_{m\times n} \cdot B_{n\times p} = C_{m \times p}\) is actually \(m \times p\) individual inner products.
A \(4\) by \(4\) matrix multiplication showing the inner product producing \(c_{2, 2}\).#
Example
Important
Matrix multiplication is not commutative. In general, \(AB \neq BA\).
Zero and Identity Matrices#
It is sometimes possible for \(AB = BA\). Two important examples are when one of the matrices is the zero matrix or the identity matrix.
Zero matrix#
The zero matrix is a matrix with all zero entries. The \(m\) by \(n\) zero matrix is denoted by \(0_{m, n}\).
Assuming matrix multiplication is defined, the product of a zero matrix by any other matrix is the zero-matrix (of possibly different dimension).
Example
For a matrix \(A = (a_{i, j})\), its main diagonal is the entries \(a_{i, j}\) for which \(i = j\). In a square matrix of order \(n\), there are \(n\) entries along the main diagonal. In a rectangular matrix, the smaller of the two dimensions determines the number of entries along the main diagonal.
Note that the other entries need to be \(0\). For example, the three main diagonals of the matrices in the zero multiplication example are \((0, 0)\), \((2, 3)\), and \((0, 0, 0)\). If all entries not on the main diagonal are \(0\), then we call that matrix a diagonal matrix.
Identity matrix#
The identity matrix is a square diagonal matrix with all entries of the main diagonal equal to \(1\). The identity matrix of order \(n\) is denoted \(I_n\).
The property of the identity matrix is that any other matrix multiplied by the identity is equal to itself. For an \(m\) by \(n\) matrix \(A\), we have:
If \(A\) is a square matrix of order \(n\), then we have:
We can also leave the order of the identity matrix implicit. For an \(m\) by \(n\) matrix \(A\), we write \(AI\) to mean \(A\) times \(I_n\). The dimensions of the other matrix dictate the order of the identity matrix.
Example
Power of Matrices#
For square matrices, we can define the power of a matrix as the repeated multiplication of the matrix with itself.
Let \(A\) be a square matrix of order \(n\). Then:
Example
Matrix Transpose#
A transpose is an operation performed on a matrix which reverses its dimensions. In particular, it exchanges the rows of the matrix with its columns.
Given an \(m\) by \(n\) matrix \(A\), its transpose is denoted \(A^T\) and is an \(n\) by \(m\) matrix. \(A^T\) is defined as:
Notice that the second column becomes the second row.
Since a transpose changes the dimensions, the transpose of a “tall” matrix is a “wide” matrix. Visually, matrix transposition “flips” or “rotates” the entries of the matrix along its main diagonal. The entries on the main giagonal do not change.
Animated matrix transpose.#
Matrix transposition is easily reversible. Simply apply the transpose a second time.
Notice also that the identity matrix is not affected by transposition.
Zero-One Matrices#
A special class of matrices whose entries come from the set \(\{0, 1\}\) are called zero-one matrices. These matrices have numerous and important applications in computer science. Indeed, \(\{0, 1\}\) may represent binary digits, ubiquitous in computer science.
Moreover, we can use \(\{0, 1\}\) to encode truth values false and true, respectively. This extends propositional logic to matrices.
See also
Join and Meet#
FOr two zero-one matrices, we can define operations similar to matrix addition, but using \(\wedge\) and \(\vee\) isntead of \(+\). Let \(A = (a_{i, j})\) and \(B = (b_{i, j})\) be \(m\) by \(n\) matrices.
The join of \(A\) and \(B\) is the \(m\) by \(n\) zero-one matrix defined as:
The meet of \(A\) and \(B\) is the \(m\) by \(n\) zero-one matrix defined as:
Example
The join of \(A\) and \(B\) is:
The meet of \(A\) and \(B\) is:
Boolean Product#
Similar to matrix multiplication, we can define a multiplication-like operation using zero-one matrices.
The typical inner product used matrix multiplication replaced by a “disjunction of conjunctions”.
Let \(A\) be an \(m\) by \(n\) zero-one matrix and \(B\) be an \(n\) by \(o\) zero-one matrix. The boolean product of \(A\) and \(B\), denoted \(A \odot B\) is an \(m\) by \(p\) zero-one matrix with elements \(c_{i, j}\) defiend as:
Example
For square zero-one matrices, we can extend Boolean product to Boolean power. Denote \(A^{[n]}\) the Boolean product product of \(A\) with itself \(n\) times. Since Boolean products are associative, the order of operations does not matter for a Boolean power.