No history yet

Vectors and Matrices

Vectors: Beyond Direction

Vectors are more than just arrows pointing in space. They're ordered lists of numbers that represent a point in a coordinate system or a magnitude and direction. We typically write them as a column.

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

We can perform basic arithmetic with vectors. When we add or subtract vectors, we do it component by component. The vectors must have the same number of dimensions for this to work.

[ab]+[cd]=[a+cb+d]\begin{bmatrix} a \\ b \end{bmatrix} + \begin{bmatrix} c \\ d \end{bmatrix} = \begin{bmatrix} a+c \\ b+d \end{bmatrix}

For example, let's add two vectors:

[23]+[51]=[2+53+1]=[74]\begin{bmatrix} 2 \\ 3 \end{bmatrix} + \begin{bmatrix} 5 \\ 1 \end{bmatrix} = \begin{bmatrix} 2+5 \\ 3+1 \end{bmatrix} = \begin{bmatrix} 7 \\ 4 \end{bmatrix}
Lesson image

Another key operation is scalar multiplication. This involves multiplying a vector by a single number (a scalar). The result is a new vector that's been scaled, or stretched. Each component of the vector is multiplied by the scalar.

k[ab]=[kakb]k \begin{bmatrix} a \\ b \end{bmatrix} = \begin{bmatrix} k \cdot a \\ k \cdot b \end{bmatrix}

If you multiply the vector from our first example by the scalar 3, you get a new vector pointing in the same direction but three times as long.

3[23]=[3233]=[69]3 \begin{bmatrix} 2 \\ 3 \end{bmatrix} = \begin{bmatrix} 3 \cdot 2 \\ 3 \cdot 3 \end{bmatrix} = \begin{bmatrix} 6 \\ 9 \end{bmatrix}

Matrices: Organized Data

A matrix is a rectangular grid of numbers arranged in rows and columns. They're a powerful way to organize data and, as we'll see later, to perform complex transformations on vectors.

The size or dimension of a matrix is given by its number of rows and columns. We say a matrix with m rows and n columns is an m×nm \times n matrix.

Lesson image

Just like with vectors, we can add and subtract matrices. The rule is the same: the matrices must have the exact same dimensions, and the operation is performed element by element.

[abcd]+[efgh]=[a+eb+fc+gd+h]\begin{bmatrix} a & b \\ c & d \end{bmatrix} + \begin{bmatrix} e & f \\ g & h \end{bmatrix} = \begin{bmatrix} a+e & b+f \\ c+g & d+h \end{bmatrix}

Scalar multiplication also works the same way. Multiply every element in the matrix by the scalar.

k[abcd]=[kakbkckd]k \begin{bmatrix} a & b \\ c & d \end{bmatrix} = \begin{bmatrix} ka & kb \\ kc & kd \end{bmatrix}

Matrix Multiplication

Matrix multiplication is where things get more interesting. Unlike addition, it is not performed element by element. For two matrices to be multiplied, the number of columns in the first matrix must equal the number of rows in the second matrix.

If you multiply an m×nm \times n matrix by an n×pn \times p matrix, the result will be an m×pm \times p matrix.

To find the element in the i-th row and j-th column of the resulting matrix, you take the dot product of the i-th row of the first matrix with the j-th column of the second matrix.

[abcd][efgh]=[(ae+bg)(af+bh)(ce+dg)(cf+dh)]\begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} e & f \\ g & h \end{bmatrix} = \begin{bmatrix} (ae+bg) & (af+bh) \\ (ce+dg) & (cf+dh) \end{bmatrix}

One of the most important properties of matrix multiplication is that it's not commutative. In general, A×BB×AA \times B \neq B \times A. The order matters!

Let's check your understanding of these fundamental operations.

Quiz Questions 1/5

What is the result of adding the vectors [2 5]\begin{bmatrix} 2 \ 5 \end{bmatrix} and [3 1]\begin{bmatrix} 3 \ -1 \end{bmatrix}?

Quiz Questions 2/5

What happens when you multiply a vector by a scalar (a single number)?

With these basics of vector and matrix arithmetic, we have the building blocks for exploring the more powerful aspects of linear algebra.