Skip to content

Matrix Basics

mike nicholas edited this page Jun 20, 2026 · 28 revisions

Linear Algebra deals primarily with matrices, which are boxes of numbers. Here's an example of a matrix:

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

We typically use capital letters to denote matrices. The matrix $\large A$ in the example above is a $\large 2\times 3$ matrix, which means it has 2 rows and 3 columns. To pick out an individual element of a matrix (one number in the box), we use a subscript notation. In the example above, we could write $\large A_{1,2}=-1$ because the element in the first row and second column is a $\large -1$.

Important

By convention, we always use a (row,column) convention when working with matrices.

Note

Most matrices we encounter in STEM applications are very large, with hundreds or thousands of rows and/or columns. In this class, we'll do all our hand calculations using small matrices with up to 5-6 rows/columns. We'll work with larger matrices in our Python labs.

Basic Definitions and Calculations

This is a list of some basic matrix operations with examples:

  • Addition/subtraction works by corresponding components:

$$\large \begin{bmatrix} 2 & 3 \\ 4 & -1 \\ \end{bmatrix} + \begin{bmatrix} 1 & 0 \\ -2 & 6 \\ \end{bmatrix} = \begin{bmatrix} 3 & 3\\ 2 & 5 \\ \end{bmatrix}$$

  • Scalar multiplication also works by component:

$$\large 3\begin{bmatrix} 6 & -4 \\ 2 & 0 \\ 3 & 1 \\ \end{bmatrix} = \begin{bmatrix} 18 & -12\\ 6 & 0 \\ 9 & 3\\ \end{bmatrix}$$

  • The transpose of a matrix, denoted $\large A^T$, is the matrix we get if we turn the rows of $\large A$ into columnns (or, equivalently, the columns into rows):

$$\large \begin{bmatrix} 6 & -4 \\ 2 & 0 \\ 3 & 1 \\ \end{bmatrix}^T = \begin{bmatrix} 6 & 2 & 3\\ -4 & 0 & 1 \\ \end{bmatrix}$$

  • A square matrix is a matrix that has the same number of rows and columns (a $\large 2\times 2$, a $\large 3\times 3$, etc.)

  • The identity matrix $\large I$ is a square matrix with this form:

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

  • A zero matrix can be any size and consists only of 0's.

  • Vectors can be considered 1-dimensional matrices. So,

$$\large \vec{x} = \begin{bmatrix} 3 \\ -2 \\ 1\\ \end{bmatrix} \text{, a column vector is a } 3\times 1 \text{ matrix } $$

$$\large \vec{y} = \begin{bmatrix} 4 & 1 & -1 & 5\\ \end{bmatrix} \text{, a row vector is a } 1\times 4 \text{ matrix } $$

  • The diagonal of a square matrix is the line of elements connecting the upper left element to the bottom right element.

Determinants

Every square matrix is associated with a number called a determinant. For larger matrices, computing a determinant can be difficult. But we will only need to compute determinants for $\large 2\times 2$ matrices, and that computation is straightforward:

$$\large \det\begin{bmatrix} 3 & 8 \\ -1 & 6\\ \end{bmatrix} = (3)(6)-(-1)(8)=26 $$

The determinant is the difference of the product of the diagonal elements times the off-diagonal elements of the matrix.

Matrix Multiplication

The product of two matrices has a trickier definition than addition or subtraction. The product $\large C=AB$ is defined as follows:

$$\large C_{i,j}=\text{ the dot product of the ith row of A with the jth column of B}=\sum_{k=1}^nA_{i,k}B_{k,j}$$

Here's a video example of how this works:

Because of this definition, matrix multiplication is not always defined. For $\large C=AB$ to exist, the number of columns of $\large A$ must equal the number of rows of $\large B$.

Warning

Matrix multiplication is not commutative! That is, even if they both exist (which they often don't), $\large AB$ is not necessarily equal to $\large BA$.

Matrix-Vector Multiplication

Since a vector is just a one dimensional matrix, matrix-vector multiplication is just a small case of matrix-matrix multiplication. For example:

$$\large \begin{bmatrix} 3 & 8 & 0\\ -1 & 6 & -2\\ \end{bmatrix} \begin{bmatrix} 4 \\ -3 \\ 1 \\ \end{bmatrix} = \begin{bmatrix} (3)(4)+(8)(-3)+(0)(1) \\ (-1)(4)+(6)(-3)+(-2)(1) \\ \end{bmatrix} = \begin{bmatrix} -12 \\ -24 \\ \end{bmatrix} $$

Multiplication as Linear Combinations (another way to see it...)

Special matrices (symmetric, orthogonal, diagonal, triangular, etc)

Section Outcomes

I can:

  • Use linear algebra terminology and notation.
  • Perform basic matrix computations.
  • Multiply matrices together (or recognize when the matrix product does not exist).

Clone this wiki locally