Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 62 ยท Getting Started

What Is Linear Algebra?

Find out what linear algebra is, where it shows up in graphics, machine learning, physics and search, and how this track uses NumPy to make every idea runnable.

Linear algebra is the mathematics of lists of numbers and the operations that combine them. Instead of working with one number at a time, you work with whole columns and grids of numbers and treat each one as a single object. That small change of viewpoint is surprisingly powerful: a photograph, a set of house prices, a rotation in a video game and the links between web pages can all be described with the same few tools.

If you have ever wondered why every machine-learning course starts with "matrices", why graphics cards are built around multiplying them, or how a search engine ranks a billion pages, the answer is the same. Those problems are linear algebra problems in disguise. This track teaches the subject from the ground up, with short explanations, pictures in your mind, and code that you can run and change right on the page.

You do not need a math degree. You should be comfortable with school algebra (solving 2x + 3 = 11) and with the basics of Python. If you have never used NumPy, skim Your First Arrays first; we will explain each call we use anyway.

The two objects: vectors and matrices

Everything in this subject is built from two kinds of objects.

  • A vector is an ordered list of numbers, such as [3, 4] or [72, 1.8, 24]. You can read it as an arrow in space, as a point, or simply as a row in a spreadsheet.
  • A matrix is a rectangular grid of numbers. You can read it as a table, as a stack of vectors, or as a machine that turns one vector into another.

The word "linear" tells you which operations are allowed: you may add vectors and scale them (multiply by a plain number), and the rules stay simple and predictable. Doubling an input doubles the output; adding two inputs adds the outputs. Anything that obeys those two rules is called linear, and linear things are the ones we can fully understand and compute fast.

Two objects, one language

Vector An ordered list of numbers.
Matrix A grid of numbers.
Product Combine them to transform data.

Almost every lesson is about these three ideas.

1 / 2

Where it appears

Linear algebra is not a niche topic. Here are four places you meet it every day, often without noticing.

Graphics and games. A 3D model is a list of points. Rotating, moving and projecting it onto your screen is done by multiplying every point by a small matrix. A graphics card is, at heart, a very fast matrix multiplier. We build a tiny renderer in Project: A Tiny 3D Wireframe Renderer.

Machine learning. A dataset is a matrix: one row per example, one column per feature. A neural network layer is a matrix multiplication followed by a simple function. Fitting a line to data is a linear algebra problem called least squares.

Search and recommendations. Google's original PageRank idea treats the web as a giant matrix and finds its most important direction. Streaming services guess what you will like by factoring a huge table of ratings into smaller pieces. You will build both in the projects chapter.

Science and engineering. Circuits, bridges, heat flow and quantum states are all described by systems of linear equations or by matrices whose special numbers (eigenvalues) tell you how the system behaves.

The big ideas map

The 46 lessons of this track are organized around a handful of questions. Knowing the map in advance makes each lesson easier to place.

The journey in four stops

Vectors Length, angle, dot and cross product.
Matrices Multiply them, flip them, invert them.
Systems Solve many equations at once.
Spaces Span, basis, rank, null space.
1 / 2

Read in order the first time. The ideas stack: matrix multiplication needs the dot product, solving systems needs matrix multiplication, and eigenvalues need both.

How this track uses NumPy

You could do linear algebra with pencil and paper, and we will often compute small examples by hand so you understand what is going on. But real problems have thousands or millions of numbers, so we also use NumPy, the standard Python library for arrays. It stores a vector or matrix as an ndarray, performs arithmetic on all the numbers at once, and contains the module np.linalg with fast, battle-tested routines.

Here is a first taste. Two vectors, one sum, one scaling, and one dot product:

Python Your first vectors in NumPy

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The code has only four ideas, and all of them are lessons in this chapter. The @ operator is Python's matrix-multiplication symbol; between two vectors it computes the dot product.

A matrix is just a two-dimensional array, and a matrix times a vector is again one @:

Python A matrix as a machine

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice what happened. We never wrote a loop or an if; we wrote the transformation as a small grid of numbers and let multiplication apply it. That is the central trick of the whole subject: describe an action as a matrix, then compute with it.

Because the live editors run Python in your browser, every example in this track is self-contained. Random data always uses a fixed seed so your output matches what the lesson shows.

A tiny problem, three ways

Here is a puzzle: a coffee and a muffin cost 7 dollars; two coffees and a muffin cost 11. What does each cost? In school you would eliminate a variable. In linear algebra you write it as a matrix equation A x = b and hand it to a solver. The numbers in each row are the amounts of coffee and muffin; x holds the unknown prices.

Python Solving two equations at once

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The answer is a coffee at 4 and a muffin at 3. With two unknowns that is easy by hand, but the same three lines would solve a system with a thousand unknowns. Systems of Linear Equations develops this fully.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does the word "linear" promise about an operation?

    A linear operation respects addition and scaling. That is why it can be written as a matrix and computed quickly.
  2. 2. In the context of data science, what does a typical dataset look like as a matrix?

    Rows are observations (examples) and columns are measured features. Most machine-learning code expects exactly this layout.
  3. 3. In NumPy, what does u @ v compute for two 1D arrays of the same length?

    The @ operator is matrix multiplication; for two vectors it reduces to the dot product, a single number.
  4. 4. Which task is best described as solving A x = b?

    Whenever several totals depend on several unknown amounts in a linear way, you can write the situation as a matrix equation and solve it.

Summary

  • Linear algebra studies vectors (lists of numbers) and matrices (grids of numbers) and the operations of adding and scaling.
  • It powers graphics, machine learning, search ranking, recommendations and much of science and engineering.
  • A matrix can be read as a machine that transforms vectors; matrix multiplication applies the machine.
  • NumPy stores vectors and matrices as arrays and provides @ and np.linalg for fast computing.
  • The track moves from vectors and matrices to systems, vector spaces, transformations, orthogonality, eigenvalues, the SVD and finally real projects.

Next up: meet the first object in detail in Vectors.