No history yet

Vectors and Matrices

What Are Vectors?

In math and physics, some quantities just have a size, or magnitude. Your height, the temperature outside, or the price of a coffee are all simple numbers. These are called scalars. But what if you need to describe something that also has a direction? For that, we use vectors.

vector

noun

A mathematical object that has both magnitude (size or length) and direction.

Think about giving someone directions. You wouldn't just say, "Walk for 10 minutes." You'd say, "Walk 10 minutes north." That instruction, combining a magnitude (10 minutes) and a direction (north), is a vector.

In linear algebra, we represent vectors as lists of numbers called components. For example, a vector in a 2D plane (like a flat map) has two components: one for its movement along the x-axis (horizontal) and one for the y-axis (vertical). We usually write them in a column.

v=[32]\vec{v} = \begin{bmatrix} 3 \\ 2 \end{bmatrix}

The components tell us how far the vector goes in each standard direction from its starting point.

Lesson image

Working with Vectors

We can perform operations on vectors, just like with regular numbers. The two most basic operations are addition and scalar multiplication.

Vector Addition is like following two sets of directions, one after the other. If you walk 3 blocks east and 2 blocks north (vector a\vec{a}), and then 1 block east and 4 blocks north (vector b\vec{b}), where do you end up? To find the total displacement, you just add the corresponding components of the vectors.

a+b=[32]+[14]=[3+12+4]=[46]\vec{a} + \vec{b} = \begin{bmatrix} 3 \\ 2 \end{bmatrix} + \begin{bmatrix} 1 \\ 4 \end{bmatrix} = \begin{bmatrix} 3+1 \\ 2+4 \end{bmatrix} = \begin{bmatrix} 4 \\ 6 \end{bmatrix}

Geometrically, this is often called the "tip-to-tail" or parallelogram method. The resulting vector goes from the start of the first vector to the end of the second.

Lesson image

Scalar Multiplication involves a vector and a scalar (a plain number). Multiplying a vector by a scalar scales its magnitude. If you multiply a vector by 2, it becomes twice as long in the same direction. If you multiply it by -1, it keeps its length but flips to the opposite direction.

Lesson image

To perform scalar multiplication, you just multiply every component of the vector by the scalar.

2[32]=[2322]=[64]2 \cdot \begin{bmatrix} 3 \\ 2 \end{bmatrix} = \begin{bmatrix} 2 \cdot 3 \\ 2 \cdot 2 \end{bmatrix} = \begin{bmatrix} 6 \\ 4 \end{bmatrix}

Introducing Matrices

If a vector is a list of numbers, a matrix is a grid of numbers, arranged in rows and columns. You can think of a matrix as a collection of vectors, or as a tool for organizing data.

We describe the size of a matrix by its number of rows and columns, written as rows ×\times columns. For example, a 2 ×\times 3 matrix has 2 rows and 3 columns.

Lesson image

Matrices are incredibly useful for storing data and, as we'll see later, for performing complex transformations on vectors, like rotations and scaling. There are many types of matrices, but a few common ones are:

  • Square Matrix: Has the same number of rows and columns (e.g., 3 ×\times 3).
  • Column Matrix (or Column Vector): Has only one column.
  • Row Matrix (or Row Vector): Has only one row.

Matrix Operations

Just like with vectors, we can perform arithmetic operations with matrices.

Matrix Addition is straightforward, but it only works for matrices of the same size. You simply add the corresponding elements in each position.

[1234]+[5678]=[1+52+63+74+8]=[681012]\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} + \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix} = \begin{bmatrix} 1+5 & 2+6 \\ 3+7 & 4+8 \end{bmatrix} = \begin{bmatrix} 6 & 8 \\ 10 & 12 \end{bmatrix}

Matrix Multiplication is more complex. You can't just multiply corresponding elements. To multiply matrix AA by matrix BB, the number of columns in AA must equal the number of rows in BB.

The element in the ii-th row and jj-th column of the resulting matrix is found by taking the dot product of the ii-th row of the first matrix with the jj-th column of the second matrix.

Let's see an example. To find the top-left element of the product, we take the dot product of the first row of matrix AA with the first column of matrix BB.

AB=[1234][5678]=[(15+27)(16+28)(35+47)(36+48)]=[19224350]\begin{aligned} A \cdot B &= \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \cdot \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix} \\ &= \begin{bmatrix} (1 \cdot 5 + 2 \cdot 7) & (1 \cdot 6 + 2 \cdot 8) \\ (3 \cdot 5 + 4 \cdot 7) & (3 \cdot 6 + 4 \cdot 8) \end{bmatrix} \\ &= \begin{bmatrix} 19 & 22 \\ 43 & 50 \end{bmatrix} \end{aligned}

Notice that matrix multiplication is not commutative, which is a fancy way of saying that ABA \cdot B is generally not the same as BAB \cdot A. The order matters!

Finally, the Transpose of a matrix is what you get when you flip it over its main diagonal. The rows become columns and the columns become rows. We denote the transpose of a matrix AA as ATA^T.

A=[123456]AT=[142536]A = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix} \quad A^T = \begin{bmatrix} 1 & 4 \\ 2 & 5 \\ 3 & 6 \end{bmatrix}

Vectors and matrices are the fundamental building blocks of linear algebra. Understanding how to manipulate them is the first step toward using them to solve much more interesting problems.

Quiz Questions 1/6

Which of the following quantities is best described as a vector?

Quiz Questions 2/6

Given two vectors, a=(32)\vec{a} = \begin{pmatrix} 3 \\ -2 \end{pmatrix} and b=(15)\vec{b} = \begin{pmatrix} 1 \\ 5 \end{pmatrix}, what is their sum a+b\vec{a} + \vec{b}?