JOVANA
Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
All guides

What Is a Matrix?

A matrix is just a grid of numbers, but the grid can be read three different ways — as a data table, as a list of column vectors, and as a machine that moves vectors. Picking the right reading for the moment is half of linear algebra.

A grid of numbers

A matrix is a rectangular grid of numbers arranged in rows and columns. We say a matrix is m-by-n when it has m rows and n columns — rows first, columns second, always. The matrix below is 2-by-3: two rows, three columns.

A = [[1, 2, 3],
     [4, 5, 6]]   <- 2 rows, 3 columns (2-by-3)
Each number sits at a (row, column) address.

Three ways to read it

Reading 1 — a data table. Rows are records, columns are features. Three students, two test scores each: it is just a spreadsheet with the borders erased.

Reading 2 — a list of column [[vector|vectors]]. Slice the grid into vertical strips. Each column is a vector, and the matrix is those vectors standing side by side. This is the reading we lean on most.

Reading 3 — a machine. Feed the matrix a vector and it hands you back a new vector. In this reading a matrix is a *function*: numbers go in, numbers come out. The whole next guide lives here.

Flipping it: the transpose

The transpose, written A^T, flips a matrix across its diagonal: rows become columns and columns become rows. A 2-by-3 matrix becomes 3-by-2. It is the cleanest way to turn "list of columns" into "list of rows" without losing a single number.

A   = [[1,2,3],     A^T = [[1,4],
       [4,5,6]]            [2,5],
                           [3,6]]
Transpose: 2-by-3 flips to 3-by-2.