TExcelTAD
Home › Linear Algebra & Matrix Theory › Linear Algebra Intro

Linear Algebra Intro

Linear algebra is the mathematics of vectors, matrices and linear equations. It is the workhorse of modern computing: every 3D game, every neural network and every search engine runs on it. This course takes you from solving small systems of equations by hand to eigenvalues, inner products and the matrix tricks behind LLMs.

The reference book

The topic order of this course follows the chapters of Peter Selinger's open textbook Matrix Theory and Linear Algebra (Dalhousie University), which is published under the Creative Commons Attribution 4.0 (CC BY 4.0) licence. You can read the book for free at mathstat.dal.ca/~selinger/linear-algebra. Thanks to Peter Selinger for making it open.

The book is used as a map of topics only: the explanations, examples, numbers and exercises in these lessons are written from scratch, with a programmer's angle and runnable Python.

What is in the course

Part Topics
1. Systems of linear equations geometric and algebraic view, elementary row operations, Gaussian and Gauss-Jordan elimination, homogeneous systems, fields, applications
2. Vectors in Rn\mathbb{R}^n points and vectors, addition, scalar multiplication, linear combinations, length, dot and cross product
3. Lines and planes in Rn\mathbb{R}^n parametric and normal forms
4. Matrices arithmetic, multiplication, inverses, elementary matrices, transpose, arithmetic mod pp, cryptography
5. Spans, independence and bases in Rn\mathbb{R}^n span, linear independence, subspaces, dimension, column/row/null space
6. Linear transformations in Rn\mathbb{R}^n the matrix of a transformation, rotations, projections, perspective rendering
7. Determinants cofactors, row operations, the inverse formula, Cramer's rule
8. Eigenvalues and eigenvectors diagonalization, matrix powers, recurrences, differential equations, Cayley-Hamilton
9. Vector spaces the abstract definition, subspaces, bases, error-correcting codes
10. Linear transformations of vector spaces the algebra of transformations, matrices with respect to a basis
11. Inner product spaces orthogonality, Gram-Schmidt, least squares, symmetric matrices, PCA
Appendix complex numbers
Linear algebra in computing graphics pipelines, quaternions, neural layers, embeddings, attention, SVD, LoRA, PageRank, numerical methods

Why programmers need linear algebra

Where What linear algebra does there
3D graphics and games Every vertex is a vector; moving, rotating and projecting a model is a matrix product. Lighting uses dot products, surface normals use cross products.
Machine learning A dataset is a matrix (rows = samples). Linear regression is a least-squares problem; PCA is an eigenvalue problem.
Deep learning A dense layer computes y=Wx+b\mathbf{y} = W\mathbf{x} + \mathbf{b}. Training a network is mostly multiplying big matrices on a GPU.
LLMs Tokens become embedding vectors; similar meanings have a large cosine similarity. Attention is the matrix product softmax⁡(QKT/d) V\operatorname{softmax}(QK^T / \sqrt{d})\,V.
Search and ranking Google's PageRank is an eigenvector of the web's link matrix.
Error-correcting codes QR codes, disks and network packets use linear codes over the field GF(2)\mathrm{GF}(2).
Simulation and engineering Circuits, structures and fluids reduce to large linear systems Ax=bA\mathbf{x} = \mathbf{b}.

Here is a tiny taste of the most common task in the whole course, solving a linear system:

python · try it yourself
from sympy import Matrix

# 2x + 3y = 13
#  x -  y = -1
A = Matrix([[2, 3], [1, -1]])
b = Matrix([13, -1])
print("solution:", list(A.solve(b)))
solution: [2, 3]

And the same object, a matrix, doing graphics work: rotating the point (1,0)(1, 0) by 90° about the origin.

python · try it yourself
import numpy as np

theta = np.pi / 2
R = np.array([[np.cos(theta), -np.sin(theta)],
              [np.sin(theta),  np.cos(theta)]])
p = np.array([1.0, 0.0])
print("rotated point:", np.round(R @ p, 6))
rotated point: [0. 1.]

How lessons work

Every lesson explains the idea in plain words, typesets formulas in math notation (x1+2x2=5x_1 + 2x_2 = 5, ∥v∥\lVert \mathbf{v} \rVert, ATA^T), and then computes it. We use two Python libraries:

  • SymPy Matrix for exact arithmetic with fractions, so row reduction gives 1/3 instead of 0.333333.
  • NumPy for fast floating-point work on big arrays, the way ML and graphics code does it.

The next lesson, Linear Algebra with SymPy and NumPy, shows both side by side. If NumPy is new to you, see the NumPy course first.

Tip: Linear algebra rewards doing small examples by hand. Each lesson ends with exercises that have answers and full solutions: try them on paper before opening the solution.

Learning paths

Your goal Suggested route
General university math Basic Math → Algebra → Calculus → this course → Differential Equations
Game developer Calculus (vectors, motion) → this course (parts 1–3, 4, 6) → Game Math → Game Physics
AI / ML engineer Calculus → this course (all parts, especially 8, 11 and computing) → Probability → Machine Learning → the Machine Learning track
Deep learning and LLMs this course → Math for Deep Learning → Generative AI & LLMs

Exercises

Exercise 1: Spot the linear equation

Which of these equations are linear in xx and yy? (a) 3x−2y=73x - 2y = 7, (b) xy=4xy = 4, (c) x+y2=1x + y^2 = 1, (d) 12x=5−4y\frac{1}{2}x = 5 - 4y.

Answer

(a) and (d) are linear; (b) and (c) are not.

Solution

A linear equation only adds constant multiples of the variables: no products of variables, no powers, no functions of them.

(a) 3x−2y=7linear(b) xy=4product of two variables→not linear(c) x+y2=1y is squared→not linear(d) 12x+4y=5rearranged, it is linear\begin{aligned} &\text{(a) } 3x - 2y = 7 && \text{linear} \\ &\text{(b) } xy = 4 && \text{product of two variables} \to \text{not linear} \\ &\text{(c) } x + y^2 = 1 && y \text{ is squared} \to \text{not linear} \\ &\text{(d) } \tfrac{1}{2}x + 4y = 5 && \text{rearranged, it is linear} \end{aligned}

Exercise 2: Check a solution

Does (x,y)=(4,−1)(x, y) = (4, -1) solve both x+2y=2x + 2y = 2 and 3x−y=133x - y = 13?

Answer

Yes.

Solution
x+2y=4+2⋅(−1)=2✓3x−y=12−(−1)=13✓\begin{aligned} x + 2y &= 4 + 2 \cdot (-1) = 2 && \checkmark \\ 3x - y &= 12 - (-1) = 13 && \checkmark \end{aligned}

Exercise 3: Your first solve (code)

Use SymPy to solve x+y+z=6x + y + z = 6, x−y=−1x - y = -1, y+2z=8y + 2z = 8.

Answer

x=1x = 1, y=2y = 2, z=3z = 3.

Solution

Write the coefficients row by row (a missing variable has coefficient 0) and call solve.

python · try it yourself
from sympy import Matrix

A = Matrix([[1, 1, 1], [1, -1, 0], [0, 1, 2]])
b = Matrix([6, -1, 8])
print(list(A.solve(b)))
[1, 2, 3]

Test yourself

In a dense neural-network layer y=Wx+b\mathbf{y} = W\mathbf{x} + \mathbf{b}, what is WW?

  1. A single number
  2. A matrix of weights
  3. An activation function
  4. A list of training examples

Why does this course use SymPy Matrix for row reduction?

  1. It is faster than NumPy
  2. It computes exactly with fractions, so no rounding errors appear
  3. NumPy cannot store matrices
  4. It runs on the GPU

Which of these is computed as an eigenvector?

  1. A cross product
  2. PageRank scores
  3. A cosine similarity
  4. A rotation by 90°