No history yet

Vectors and Matrices

What Are Vectors?

Think of giving directions. You wouldn't just say, "Walk 500 feet." You'd also give a direction, like "Walk 500 feet northeast." This combination of magnitude (500 feet) and direction (northeast) is the core idea of a vector.

In mathematics, a vector is an ordered list of numbers, called components. These components can represent coordinates in space, quantities of different items, or any data that has both size and direction. We usually write vectors as a column of numbers.

v=[31]\vec{v} = \begin{bmatrix} 3 \\ 1 \end{bmatrix}

Vectors can have any number of components. A vector with three components would define a point in 3D space, and a vector with ten components could represent the prices of ten different products.

Working with Vectors

We can perform mathematical operations with vectors. The two most basic are addition and scalar multiplication.

Vector Addition To add two vectors, you simply add their corresponding components. Imagine taking two separate journeys. The sum of the two vectors represents the single direct journey from your starting point to your final destination. For this to work, the vectors must have the same number of components.

u+v=[12]+[31]=[1+32+1]=[43]\vec{u} + \vec{v} = \begin{bmatrix} 1 \\ 2 \end{bmatrix} + \begin{bmatrix} 3 \\ 1 \end{bmatrix} = \begin{bmatrix} 1+3 \\ 2+1 \end{bmatrix} = \begin{bmatrix} 4 \\ 3 \end{bmatrix}

Scalar Multiplication A "scalar" is just a regular number, not a vector. Multiplying a vector by a scalar changes its magnitude (length) but not its fundamental direction. If the scalar is positive, the vector gets longer or shorter. If it's negative, the vector flips to point in the opposite direction.

2v=2[31]=[2321]=[62]2 \cdot \vec{v} = 2 \begin{bmatrix} 3 \\ 1 \end{bmatrix} = \begin{bmatrix} 2 \cdot 3 \\ 2 \cdot 1 \end{bmatrix} = \begin{bmatrix} 6 \\ 2 \end{bmatrix}

Introducing Matrices

If a vector is a list of numbers, a matrix is a grid of numbers organized into rows and columns. You can think of a matrix as a collection of vectors or a way to store data in a structured table.

We describe the size of a matrix by its number of rows and columns. A matrix with mm rows and nn columns is called an m×nm \times n matrix (read "m by n").

Lesson image

For example, this is a 2×32 \times 3 matrix because it has two rows and three columns.

A=[123456]A = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix}

Matrix Operations

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

Addition and Scalar Multiplication Matrix addition and scalar multiplication work exactly like they do for vectors. To add two matrices, they must have the same dimensions. You simply add the corresponding elements. For scalar multiplication, you multiply every single element in the matrix by the scalar.

3[1234]+[5678]=[36912]+[5678]=[3+56+69+712+8]=[8121620]\begin{aligned} \\ 3 &\begin{bmatrix} \\ 1 & 2 \\ 3 & 4 \\ \end{bmatrix} + \begin{bmatrix} \\ 5 & 6 \\ 7 & 8 \\ \end{bmatrix} \\ &= \begin{bmatrix} \\ 3 & 6 \\ 9 & 12 \\ \end{bmatrix} + \begin{bmatrix} \\ 5 & 6 \\ 7 & 8 \\ \end{bmatrix} \\ &= \begin{bmatrix} \\ 3+5 & 6+6 \\ 9+7 & 12+8 \\ \end{bmatrix} \\ &= \begin{bmatrix} \\ 8 & 12 \\ 16 & 20 \\ \end{bmatrix} \\ \end{aligned}

Matrix Multiplication Matrix multiplication is a bit more complex. It's not an element-by-element multiplication. To multiply matrix AA by matrix BB to get C=ABC = AB, the number of columns in AA must equal the number of rows in BB.

Each element in the resulting matrix CC is calculated by taking the dot product of a row from AA and a column from BB. That is, you multiply corresponding elements and then sum them up.

To find the element in row ii and column jj of the product matrix, you use row ii from the first matrix and column jj from the second matrix.

Let's multiply a 2×32 \times 3 matrix by a 3×23 \times 2 matrix. The result will be a 2×22 \times 2 matrix.

C=AB=[123456][789101112]=[(17+29+311)(18+210+312)(47+59+611)(48+510+612)]=[7+18+338+20+3628+45+6632+50+72]=[5864139154]\begin{aligned} \\ C &= A B \\ &= \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix} \begin{bmatrix} 7 & 8 \\ 9 & 10 \\ 11 & 12 \end{bmatrix} \\ &= \begin{bmatrix} \\ (1 \cdot 7 + 2 \cdot 9 + 3 \cdot 11) & (1 \cdot 8 + 2 \cdot 10 + 3 \cdot 12) \\ (4 \cdot 7 + 5 \cdot 9 + 6 \cdot 11) & (4 \cdot 8 + 5 \cdot 10 + 6 \cdot 12) \\ \end{bmatrix} \\ &= \begin{bmatrix} 7+18+33 & 8+20+36 \\ 28+45+66 & 32+50+72 \end{bmatrix} \\ &= \begin{bmatrix} 58 & 64 \\ 139 & 154 \end{bmatrix} \\ \end{aligned}
Quiz Questions 1/6

What are the two fundamental properties that define a vector?

Quiz Questions 2/6

What is the result of the following vector addition? [835]+[231]\begin{bmatrix} 8 \\ -3 \\ 5 \end{bmatrix} + \begin{bmatrix} 2 \\ 3 \\ -1 \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 complex problems.