Vectors and Matrices: Transformations in Disguise

Represent data as vectors and see how matrix multiplication can rotate, scale, and combine it.

By Rishipal Singh · · 6 min read

A matrix transforms a vector into a new direction and magnitude.
Visual guide: A matrix transforms a vector into a new direction and magnitude.

Vectors and matrices are ways to represent numbers and transform them. They appear in graphics, machine learning, simulations, search, and many other areas of computing.

A vector is an ordered list

A vector such as [2, 3] can represent a point, direction, or pair of measurements. Adding vectors combines their corresponding values: [2, 3] + [4, 1] = [6, 4]. Multiplying by a scalar stretches or shrinks every component.

The dot product multiplies corresponding components and sums them. It can measure how aligned two vectors are and is used in search and machine learning.

A matrix transforms vectors

A matrix is a rectangular table of values. Multiplying a matrix by a vector combines the vector's components in a structured way. In two dimensions, suitable matrices can rotate or scale points; in graphics, transformations can be combined by multiplying their matrices.

For matrix-vector multiplication to be defined, the number of columns in the matrix must equal the number of entries in the vector. Keeping track of dimensions catches many mistakes before calculating values.

Why it matters in practice

Images can be represented as grids of numbers, and neural networks repeatedly apply matrix operations to batches of data. Graphics pipelines use transformations to move objects between coordinate systems.

You do not need advanced linear algebra to get started. Learn dimensions, addition, scalar multiplication, and matrix-vector multiplication first; then connect each operation to the problem it models.

Practice: apply a matrix

The matrix [[2, 0], [0, 3]] scales x by 2 and y by 3. Where does vector (1, 2) move?

Reveal the explanation

Multiply the matrix by the vector: (2×1, 3×2) = (2, 6). The x-coordinate doubles and the y-coordinate triples.