Gradient

Courses

∇\nabla∇The maths behind AI0/72
π\piπMaths0/84
⋆\star⋆AI for everyone0/10
Γ\GammaΓGame theory0/49
py\texttt{py}pyPython for AI0/15
y^\hat{y}y^​Build your own AI0/15
All courses

Tuition

My tuitionOlympiad trackCompetitions

Practice

ProjectsAsk a questionTrain on a GPUExplorationsMaths StoriesUnsolved problemsPlaygroundScience labsMock testsOlympiad

Reference

GlossaryBlogDiscoveries
Blog › Explore in 3D

25 November 2026 · 4 min readInteractive 3D

A group of colourful blocks arranged in a grid
Photo by Google DeepMind on Unsplash

What does a matrix actually do? Watch it stretch space

A matrix is not just a box of numbers. It is a machine that stretches, squashes, shears and turns space. Drag a cube and see it happen.

Most people meet matrices as grids of numbers with fiddly multiplication rules. That hides what they are for. A matrix is an instruction for moving every point in space at once: stretch this way, squash that way, lean over, turn round.

Move the sliders and watch the cube change. The faint cube is where you started.

The columns tell you everything

Look at the three arrows. They start as the three edges of a unit cube: one along each axis. After the matrix, each arrow lands somewhere new. Those three landing spots are the matrix’s three columns. Know where the edges go and you know where every other point goes, because every point is just some mix of those edges.

Four moves, one machine

  • Stretch: make one direction longer or shorter.
  • Shear: push the top sideways so the box leans, like a stack of books.
  • Turn: spin everything round without changing its shape.
  • Combine them: any matrix is some mixture of these.

Why AI cares

A layer of a neural network is a matrix. It takes the list of numbers that describes a word or a picture and moves it to a new place, where the next layer can see patterns more easily. Training is the search for matrices that move things to helpful places.

Try this: set both stretches to 1, shear to 0 and only change the turn. The volume factor stays at exactly 1, because turning never changes size.

A worked example

Take the matrix with columns [2, 0] and [0, 1]. It sends the point (1, 1) to (2, 1): everything is stretched to twice as wide but no taller. Now take the matrix with columns [0, 1] and [−1, 0]. It sends (1, 0) to (0, 1) and (0, 1) to (−1, 0): a quarter turn anticlockwise.

  1. Matrix rows (2, 0) and (0, 1), point (3, 4)
  2. New x = 2×3 + 0×4 = 6
  3. New y = 0×3 + 1×4 = 4
  4. So (3, 4) moves to (6, 4): stretched sideways

Doing two moves in a row

Applying one matrix and then another is the same as applying their product. Order matters: turning and then stretching sideways is not the same as stretching sideways and then turning. That is why matrix multiplication is not commutative, AB is usually not BA.

The identity matrix, with columns [1, 0] and [0, 1], does nothing. An inverse matrix undoes a move, which is only possible if the move did not squash space flat.

Matrices in a neural network

A layer of a neural network is a matrix followed by a bend (an activation function). The matrix mixes the inputs, rotating and stretching the data; the bend lets the network draw curved boundaries. Stack many layers and the network can untangle very complicated data, one simple move at a time.

Every photo filter that rotates, flips or skews an image uses a 2 × 2 or 3 × 3 matrix on the pixel coordinates.

Systems of equations

The equations 2x + y = 5 and x − y = 1 can be written as one matrix times the unknown vector [x, y] equals [5, 1]. Solving the equations means finding which point the matrix sends to [5, 1]. Undoing the matrix with its inverse gives x = 2 and y = 1.

Matrices in games and graphics

Every frame of a 3D game multiplies the coordinates of thousands of corners by matrices to turn, move and project the scene onto your screen. Graphics chips were built to do exactly this quickly, which is why the same chips now train AI.

Glossary

  • Matrix: a rectangular grid of numbers.
  • Identity matrix: the matrix that changes nothing.
  • Inverse: the matrix that undoes another.
  • Shear: a slant that keeps one direction fixed.

Try these yourself

  1. Q1. Rows (3, 0) and (0, 3) on (1, 2): (3, 6), an enlargement by 3
  2. Q2. Rows (1, 0) and (0, −1) on (4, 5): (4, −5), a reflection in the x-axis
  3. Q3. Rows (1, 1) and (0, 1) on (2, 3): (5, 3), a shear
  4. Q4. What matrix turns everything 180°? Rows (−1, 0) and (0, −1)

Reading a matrix at a glance

The first column is where the point (1, 0) lands, and the second column is where (0, 1) lands. Everything else follows, because every point is a mix of those two. So to design a matrix, just decide where those two arrows should go.

In short

A matrix moves all of space at once with one rule. Its columns tell you where the basic arrows go. Multiplying matrices chains moves, and order matters.

Keep going

  • Lesson: matrices move space
  • Glossary: matrix
  • Determinants explained
  • What is gradient descent? How AI learns downhill
  • What is a local minimum? Why AI can get stuck

Read and listen in

Indian languages

World languages

Questions people ask

What does a matrix do to space?

It moves every point by the same rule: stretching, turning, flipping or shearing, while keeping straight lines straight and the origin fixed.

Why is matrix multiplication not commutative?

Because doing two moves in a different order can give a different result, like turning then stretching versus stretching then turning.

How is a matrix used in AI?

Each layer of a neural network multiplies its inputs by a matrix of learned numbers, then applies a bend. Training finds the numbers.

More articles

  • What is a determinant? How a matrix grows a shape
  • What is gradient descent? How AI learns downhill
  • What is a local minimum? Why AI can get stuck