Homology
Part I · Foundations
Chapter 1.5

Linear Algebra

Vectors, matrices, kernels, images — and duality

about 80 min Builds on 1.4 Abelian Groups and Formal Sums

We share a philosophy about linear algebra: we think basis-free, we write basis-free, but when the chips are down we close the office door and compute with matrices like fury.

— Irving Kaplansky, on himself and Paul Halmos, “Reminiscences” (1991)

Here is a puzzle that fits in a pocket. Twenty-five lights sit in a five-by-five grid. Pressing a light switches it (on becomes off, off becomes on), and it also switches its neighbours directly above, below, left and right. Some lights are on. Can you switch them all off?

Lights Out Click a light to press it
All dark — solved in 0 presses!
Figure 1.5.1 The electronic game Lights Out. Each press switches a plus-shaped group of lights. Play a few rounds, on the small board too, and watch for patterns. Does the order of your presses matter? What happens if you press the same light twice?

If you played for a minute, you probably discovered two facts. The order of presses does not matter: in the end each light has simply been switched some number of times. And pressing the same button twice does nothing at all: the light and its neighbours flip, then flip back. Some boards also start to feel suspicious. Is every arrangement of lights solvable? When one is, how many different solutions does it have? And if one is not, how could you ever prove it, short of trying all possible sets of presses?

The answers turn out to be startlingly crisp. Exactly a quarter of all boards can be solved. Every solvable board has exactly four solutions. And two parity tests, each checkable in ten seconds, tell the solvable boards from the rest. All three answers come from one tool, linear algebra, the mathematics of things that can be added together and scaled. Engineers, statisticians and physicists use it every day, and for this book it is the engine room: almost every computation in homology is a computation in linear algebra.

Kaplansky was owning up for himself and his friend Paul Halmos, whose 1942 book Finite-Dimensional Vector Spaces is the classic of the coordinate-free style (Kaplansky 1991, p. 88). The confession describes the two halves of the subject. One half is pictures and ideas: arrows, grids, shadows, things crushed and things reached. The other half is tables of numbers, pushed around by rules until they give up their secrets. Each idea below gets its picture first; then we close the office door and compute.

Vectors: arrows, lists and switches

The word vector has three everyday meanings in mathematics: an arrow, a list of numbers and, less obviously, a row of switches. They look different, and the first job of this chapter is to convince you that they are one idea.

The first picture is an arrow: a displacement, such as “three steps east and one step north”. What matters is the length and direction of the trip, not where it starts, but we will usually draw arrows starting from a fixed point called the origin.

The second picture is a list of numbers. The trip above is recorded as three units along the horizontal axis, one unit up the vertical one. Lists of two numbers describe the plane, lists of three describe space, and nothing stops us from using lists of numbers for any whole number The set of all such lists is written read “R-n” or “R to the n”. Here stands for the real numbers, all the points of the number line, fractions and and included. We print vectors in bold, like and to tell them apart from ordinary numbers, and we write for the zero vector the trip that goes nowhere.

Arrows and lists can do two things, and the whole subject is built from these two:

  • Add. To add arrows, put them tip to tail: walk along then along To add lists, add entry by entry: These are the same operation.
  • Scale. To multiply an arrow by a number stretch it by the factor turning it around if is negative. To multiply a list by multiply every entry: Again, the same operation. The numbers we scale by are called scalars.
Adding arrows, adding lists Drag u and v · drag the green tip to scale u

Walking along u and then along v (or the other way round) ends at the same point: the gold diagonal. In coordinates that is nothing but adding the lists entry by entry.

Figure 1.5.2 Walking along and then along ends at the same place as walking along and then along the gold diagonal of the parallelogram, The readout computes the same sum with lists. The green arrow is drag its tip and it slides along the line through never off it.

An expression built from these two operations, such as or for numbers and is called a linear combination of and Linear combinations are the sentences of linear algebra. Almost everything that follows is about which vectors can be written as linear combinations of which others.

The rules of the game

Arrows are not the only things that can be added and scaled. Polynomials can: So can sound waves, temperature maps and, as we will see in a moment, sets of edges in a network. Rather than develop a separate theory for each, mathematicians list the rules that adding and scaling always obey, and call anything that obeys them a vector space. Every theorem proved from the rules then applies to all of these examples at once.

First we must say which numbers we may scale by. We want to add, subtract and multiply them, and above all to divide by anything except zero, with all the familiar rules of arithmetic still true.

The rational numbers (fractions) and the real numbers are fields. The integers are not a field: the number has no reciprocal among the integers, because is not a whole number. Keep that failure in mind. It returns at the end of the chapter, where it is responsible for torsion.

Read slowly, the definition says only this: you can add vectors and scale them, and none of the usual algebra goes wrong. is a vector space over and lists of fractions, is one over Meet one non-example now, because it will matter later: the grid points pairs of integers, can be added and form an abelian group (the of §1.4 Abelian Groups and Formal Sums), but scaling by knocks off the grid. So is not a vector space over or

Vectors that are switches: the field

Now for a field you may not have met. In §1.3 Groups you saw with two hours, (read “Z mod 2”), in which Think “odd plus odd is even”. Multiplication is the obvious one: and This tiny number system is a field, because its only nonzero number is whose reciprocal is itself. So it is a perfectly good choice of scalars. Many books write it read “F-two”, the F standing for field; in this book we write

A vector over is a list of 0s and 1s, such as Picture it as a row of six switches, or as the set of positions that are switched on: label the positions and this vector is the set Adding two such vectors entry by entry, with switches on exactly the positions that are on in one vector or the other but not in both. For sets this operation has a name: the symmetric difference.

Vectors over ℤ/2 are rows of switches Click the switches
+
a
b
c 1+1=0
d
e
f

A switch is on in the sum when it is on in exactly one of u and v. Where both are on, they cancel: . As subsets, the sum is the symmetric difference: everything in one set or the other, but not in both.

Figure 1.5.3 Adding over A switch is on in when it is on in exactly one of the two; where both are on they cancel, since Press Make v equal to u: every vector is its own negative,

Two features of are worth savouring. First, for every vector, so there are no minus signs, ever. Second, there are only finitely many vectors. Each of the entries is 0 or 1, so the space of lists of bits has exactly elements.

Both features are visible in Lights Out. A board is a list of 25 bits (on or off), so the boards form the vector space A plan of presses, saying which buttons to press, is also a list of 25 bits, because the order of presses does not matter and pressing a button twice is the same as not pressing it, exactly as Lights Out lives entirely in

Span, independence, basis, dimension

Given a few vectors, what can you build from them? That question organises the next four definitions.

Two pieces of notation appear here. In this the vertical bar is read “such that”: the span is the set of all sums such that the are scalars. And with a capital sigma, is shorthand for the sum “add up over all values of The span of a single nonzero vector consists of its multiples a line through the origin. The span of two vectors pointing in different directions is the whole plane, because any point can be reached by going some distance along one and then some distance along the other. But if the second vector lies on the line of the first, it adds nothing new, and the span is still only a line.

Three spans
One vector
Two independent vectors
Two dependent vectors
Figure 1.5.4 The span is everything you can reach with linear combinations. One vector: its multiples fill a line. Two independent vectors pointing in different directions reach every point of the plane. The gold point is go one and a half steps along then one step along The grey dots are the combinations with whole numbers and fractions fill in everything between them. Two dependent vectors: is a multiple of so it brings nothing new.

A span is always a subspace: a subset of a vector space that contains and is closed under addition and scaling, meaning that adding or scaling its vectors never leads out of it. In the plane the subspaces are the origin on its own, the lines through the origin, and the whole plane. A line that misses the origin is not a subspace, since it does not contain Neither is the union of two different lines through the origin: add a vector from each line and you land on neither.

The right-hand panel shows waste: is redundant. Redundancy has a precise form. There, so a combination of the vectors whose coefficients are not all zero produces the zero vector.

Dependent vectors always contain a redundant one. If with, say, move to the other side and divide by (division, the field property, at work): this writes as a combination of the others. For example, and are independent, while and are dependent, because

Over the three vectors and are dependent: their sum is because each position is switched on exactly twice. Remember this little dependency. If the three positions are the corners of a triangle, and each vector is an edge (recorded as the set of its two endpoints), the dependency says that the three edges together close up into a loop: every corner is touched twice. Loops in this sense are what homology counts.

Two facts make this definition work. First, given a basis every vector can be written as in exactly one way. There is at least one way, because a basis spans; and if there were two different ways, subtracting one from the other would give a combination equal to with coefficients not all zero, which independence forbids. The numbers are the coordinates of the vector in that basis. Second, every basis of a given space has the same number of vectors. This is a genuine theorem, which we shall use without proof: an independent list is never longer than a spanning list, a fact often proved by an exchange lemma that swaps the vectors of one list into the other one at a time (Axler 2024, 2.22 and 2.34). It also shows that in a space of dimension any vectors are dependent. So “the dimension” is well defined: it counts the degrees of freedom, the number of independent numbers you need to pin down a vector.

The standard basis of is and in general A line through the origin has dimension 1, a plane through the origin dimension 2, and the space dimension 0 (its basis is the empty list). Over with a basis made of the lists that contain a single 1. A subspace of dimension over contains exactly vectors, one for each choice of its coordinates.

Linear maps: transformations that keep the grid

A vector space on its own just sits there. The action is in the functions between spaces, and the ones that matter here are those that respect adding and scaling. Picture the plane covered by a square grid, and imagine moving every point of the plane somewhere else. Most ways of doing this crumple the grid. The linear ones keep it a grid: lines stay straight, parallel lines stay parallel, evenly spaced lines stay evenly spaced, and the origin stays where it is. Such a map may rotate, stretch, shear, reflect or even flatten the plane, but it never bends anything.

Here is read “T, from V to W”: is the domain, where the inputs live, and is the codomain, where the outputs live, as in §1.1 Sets and Functions. Taking shows that a linear map always fixes the origin. Combining the two rules gives linear maps turn linear combinations into linear combinations. In particular a linear map is a of the underlying abelian groups, as in §1.3 Groups, which in addition respects scaling.

Here is the fact that makes linear maps easy to handle: a linear map is completely determined by what it does to a basis. In the plane every vector is so Know where the two basis vectors land and you know where everything lands. So we record the two landing spots side by side, as the columns of a table of numbers. That table is the matrix of

A linear map is a grid that stays a grid Drag the arrow tips · try a preset · play the map

Column 1 = where lands. Column 2 = where lands.

the two input directions: survivessurvives

Nothing is flattened: different inputs land in different places. The kernel is just , and the image is the whole plane.

before after
Figure 1.5.5 Drag where and land: the whole grid follows, and the matrix records the two landing spots as its columns. Try Flatten, or drag one arrow onto the line of the other. The plane collapses onto the teal line (the image), while the gold line (the kernel) is crushed to the origin. The determinant is the area of the violet parallelogram, the image of the unit square, counted negative when the map flips the plane over (the parallelogram then turns rose); it is exactly when the plane is flattened.

Multiplying a matrix by a vector

A matrix with rows and columns, an “ matrix” (read “m by n”), describes a linear map with inputs and outputs. Its columns are the images of so they live in the codomain The entry in row and column is written To apply the map to a vector take that combination of the columns: if are the columns, then For example, The same answer comes out row by row: entry of is the dot product of row with Here and The row way is how most people compute by hand; the column way is the one that explains things.

One number summarises how a map of the plane changes areas. The unit square, spanned by and goes to the parallelogram spanned by the two columns. Its area, with a sign attached, is the determinant Every region’s area is multiplied by The sign is negative when the map flips the plane over, like a mirror. And exactly when the parallelogram is squashed flat, which happens exactly when the two columns lie on one line, that is, when they are linearly dependent. (Determinants exist for square matrices of every size, where they measure volumes, but we will need only the case.)

Volumes lead to one of the oldest open questions about matrices. Fill a square table with s and s: how large can its determinant be? Think of the rows as the edges of a box. A box with edges of given lengths has the largest volume when its edges are perpendicular, and two rows are perpendicular when their dot product is For tables the best is whose rows have dot product and whose determinant is Jacques Hadamard proved in 1893 that an table of s has with equality exactly when every two rows are perpendicular (Hadamard 1893). Tables like that are now called Hadamard matrices, and they are used to build error-correcting codes.

Everything works the same way over a matrix is a table of 0s and 1s, and the arithmetic uses Lights Out is our example. Pressing the buttons of a plan changes the board by the sum of the effects of the individual buttons, because each light ends up switched once for each pressed button that touches it, and only the parity of that count matters. So “plan of presses change of lights” (the arrow is read “goes to”) is a linear map Its matrix is and column is the plus-shaped pattern of lights switched by button The figure in the Lights Out section below can show you this matrix.

Matrix multiplication is composition

Apply one linear map and then another: The result is again linear, so it has a matrix, which we call the product Since the columns of a matrix are the images of the basis vectors, column of is applied to column of Working this out entry by entry gives the familiar rule row of times column of The sizes must fit: an matrix times a matrix is an matrix, because the outputs of must be the inputs of

Notice the order. means “first then just like the of §1.1 Sets and Functions, read “g after f”. And order matters. With the rotation and the shear from the zoo, shearing and then rotating is not the same as rotating and then shearing. The matrix that does nothing, with 1s down the diagonal and 0s elsewhere, is the identity matrix

Same dimension, same space

A linear map that is also a bijection is called an isomorphism. It pairs off the vectors of two spaces one for one and respects adding and scaling, so the two spaces are really one space with its vectors renamed. Coordinates hand us an isomorphism for free. If is a basis of a space over a field the map is linear, and it is a bijection because every vector has exactly one list of coordinates. So every vector space of dimension is a copy of . Two spaces over the same field are isomorphic exactly when they have the same dimension (an isomorphism carries a basis to a basis, so it cannot change the count). The polynomials the pairs and the arrows in the plane are one space in three costumes. For homology this is excellent news: over a field, each homology group will be pinned down completely by a single number, its dimension (§3.4 Computing Homology).

Kernel and image: what is crushed, what is reached

Every question about Lights Out is a question about two subspaces that come with any linear map. One lives in the domain and records what the map loses. The other lives in the codomain and records what the map can do.

Both are subspaces. If and then and so the kernel is closed under adding and scaling; the image is similar. You met kernels and images of homomorphisms in §1.3 Groups. A linear map is a homomorphism, and these are the same and image, now with dimensions attached.

The kernel deserves several pictures, because homology will lean on all of them.

  • What gets crushed. The kernel is everything the map squashes onto the origin: the gold line in the playground above.
  • Solutions of the homogeneous equation. The kernel is the set of solutions of the equation with nothing on the right-hand side; “homogeneous” means exactly that.
  • Quiet patterns. In Lights Out, the kernel is the set of plans of presses that change nothing at all. The board has a few of these, and they are the reason that not every board is solvable.

The image also has a concrete description. Since is a combination of the columns of the image is the span of the columns, which is why it is also called the column space; the rank is the number of independent columns. In Lights Out, the image is the set of boards you can produce from the dark board by pressing buttons. Since pressing the same buttons again undoes them, it is exactly the set of boards that can be switched off: the solvable boards.

The kernel tells you exactly how much information a map destroys. If then so lies in the kernel. Conversely, adding a kernel vector to an input never changes the output. So is (different inputs give different outputs) exactly when and is (every output is reached) exactly when is all of

Here is a picture that ties kernel and image together: a linear map from space to itself, of rank 2. It works like a shadow cast by slanted sunlight. Every point slides along one fixed direction until it reaches the floor.

Crushing one dimension Play or scrub the map · drag to rotate
cube shadow
Figure 1.5.6 A rank-2 map of three-dimensional space. Apply it, and every point slides along the slanted direction until it reaches the floor. The teal floor is the image: 2 dimensions survive. The gold line through the origin is the kernel, crushed to a single point: 1 dimension is lost. And The thin pale gold lines parallel to the kernel collapse to single teal points as well; remember them when we reach quotient spaces.

Count dimensions in the picture. Space has 3. The floor, which is the image, has 2. The line that collapses, the kernel, has 1. And That is no coincidence.

Rank–nullity already answers questions without any computation. A linear map can never be injective: its rank is at most 3, so its nullity is at least A linear map can never be surjective: its rank is at most 3, short of 5. And a map from a finite-dimensional space to itself is injective exactly when it is surjective, since nullity 0 means rank equal to the full dimension.

Row reduction: the universal tool

So far we have found kernels by staring. That works for matrices and fails long before We need a mechanical procedure that computes ranks, kernels and images of any matrix, over any field. It is called row reduction, or Gaussian elimination, and it is the same elimination you may have used at school to solve two equations in two unknowns.

A matrix stands for a system of equations. The matrix with rows and stands for the homogeneous system whose solutions form the kernel. We may change the system in three ways without changing its solutions:

  1. swap two rows (list the equations in a different order);
  2. scale a row by a nonzero number (multiply an equation through);
  3. add a multiple of one row to another (add a multiple of one equation to another).

Each operation can be undone by another of the same kind: swap back, scale by the reciprocal, subtract what you added. So no solution is ever created or lost, and the kernel does not change. Then, by rank–nullity, the rank (the number of columns minus the nullity) does not change either.

The goal is a staircase called the reduced row echelon form. Each nonzero row begins with a 1, called a pivot; each pivot sits to the right of the pivot above it; and each pivot is the only nonzero entry in its column. The recipe:

  1. Go through the columns from left to right, keeping track of the first row that does not have a pivot yet.
  2. In the current column, look for a nonzero entry in that row or below it. If there is none, the column gets no pivot: move on to the next column.
  3. Otherwise, swap that entry’s row up into place and divide the row by the entry, so that the pivot is 1.
  4. Subtract multiples of the pivot row from every other row to make the rest of the column 0. Then move on to the next row and the next column.

Let us run it on the system above. Column 1 already has a 1 in row 1, so we clear the rest of the column with and (read: “replace row 2 by row 2 minus twice row 1”, and so on): Column 2 has only zeros below row 1, so it gets no pivot. In column 3, the entry in row 2 becomes a pivot after and then and clear its column: Column 4 has only a zero in the one remaining row, so it gets no pivot. Done: two pivots, in columns 1 and 3. You can replay every step in the figure.

Row reduction, one step at a time Step through
start
1213
2402
3615

The starting matrix. We sweep the columns from left to right, looking for pivots.

Start
Figure 1.5.7 Each step performs the row operations shown above the matrix; changed rows are tinted, the current pivot glows, and finished pivots turn teal. At the end the free columns turn gold. The pivots give the rank, the pivot columns of the original matrix give a basis of the image, and each free variable gives a vector of the kernel. Compare the two triangle matrices over and over

Now read off the answers from the staircase.

  • Rank = the number of pivots, here 2.
  • Kernel. The columns without pivots belong to free variables, here and which may take any values. The pivot rows then determine the rest: and Setting one free variable to 1 and the others to 0 gives one kernel vector for each free variable, and these form a basis of the kernel. The nullity is the number of free variables, 2.
  • Image. The pivot columns of the original matrix, here and form a basis of the image.
  • Check. 4 columns = 2 pivot columns + 2 free columns. Rank–nullity is visible in the staircase.

Row reduction over

Over the procedure is even simpler. The only nonzero number is 1, so there is never anything to divide by, and adding a row is the same as subtracting it. Row reduction becomes: find a 1, swap it into place, and add its row to every other row that has a 1 in that column. Here is the “triangle matrix”, whose columns are the three edges of a triangle, each edge recorded by its two corners: Rank 2. The free variable gives the kernel vector all three edges together, the loop around the triangle. The kernel is

Now switch the stepper to keeping the same matrix: it has rank 3, and its kernel is only The same table of numbers can have different ranks over different fields. Here the culprit is the determinant of this matrix, which is that is not zero in but it is zero in It is our first glimpse of something the last section explains: the number 2 behaves very differently in different number systems. (The signed version of the matrix, with s, which is the one homology will use, has rank 2 over both.)

Solving

Kernels answer the question “which inputs give zero?”. Most real questions ask instead: given a target which inputs give In Lights Out, is the board in front of you, and you want a plan with Pressing adds to the board, and over so the board goes dark exactly when Two questions: is there a solution, and if so, how many?

Existence is a matter of definitions: there is a solution exactly when lies in the image of

How many is answered by the kernel. Suppose is one solution, a particular solution. If is in the kernel, then so is a solution too. Conversely, if then so is plus a vector of the kernel. Therefore a copy of the kernel slid over to pass through In the language of §1.4 Abelian Groups and Formal Sums, the solution set is a of the kernel. All solutions differ by something invisible to

Solutions form a shifted copy of the kernel Drag b and x
input space: the ’s
output space: where lands

Solvable. One solution is , and every solution is : the dashed gold line, a copy of the gold kernel slid over to pass through . Your is one of them.

Figure 1.5.8 This flattens the plane onto its image, the teal line in the output space. Put on that line and the solutions appear in the input space: a dashed, paler gold line parallel to the gold kernel, a coset of the kernel in the kernel’s colour. Drag along it and stays on Move off the line and there is no solution; a rose measurement appears that proves it, a hint of the duality section to come.

So over or there are exactly three possibilities: no solution ( is not in the image), exactly one (the kernel is or infinitely many (the kernel is a line or bigger). Over the count is finite: a kernel of dimension has elements, so a solvable equation has exactly solutions.

In practice we find solutions by row reducing the augmented matrix the matrix with attached as an extra column, doing every operation to both. If a row of the form appears, it says “ and there is no solution. Otherwise, set the free variables to 0 and read off a particular solution.

Quotient spaces: blurring out a subspace

In the last figure, all the points of one dashed gold line are “the same” as far as is concerned, since sends them all to the same It is natural to treat each such line as a single object. You have done this kind of thing twice already: in §1.2 Equivalence and Quotients you formed by declaring equivalent things equal, and in §1.4 Abelian Groups and Formal Sums you formed by collapsing a subgroup. Vector spaces have quotients too, and they are where homology lives.

As with quotient groups, we must check that these operations are well defined: if we pick different representatives of the same cosets, the answer must not change. It does not, because is closed under adding and scaling. Changing and by elements of changes and by elements of too. So is again a vector space, and its zero is the coset which is itself.

The plane modulo a line Drag p and q

Each line parallel to is one element of , and each crosses the horizontal axis exactly once, at . Adding lines adds those crossing points, so the quotient behaves exactly like the number line: .

Figure 1.5.9 Here is the gold line, and each element of is a whole line parallel to it, like the faint gold lines; itself is the zero element. Sliding along its line does not change its coset. Every such line crosses the horizontal axis exactly once, and adding cosets adds the crossing points: is a copy of the number line, of dimension

The figure illustrates the general rule. A quotient forgets the directions inside and remembers the rest, so dimensions subtract: To see it, extend a basis of to a basis of by adding vectors then the cosets form a basis of (Axler 2024, 3.105). Over you can even count: the cosets split into pieces of vectors each, so has elements. For instance, modulo has elements.

Look back at the shadow figure with this in mind. Each thin pale gold line, parallel to the kernel, is a coset of the kernel, and the map squashes each of them to a single point of the floor. Different lines land on different points, and every point of the floor is hit. So the cosets of the kernel correspond exactly to the points of the image: where is read “is to”: sending each coset to is a linear bijection. This is the of §1.4 Abelian Groups and Formal Sums, for vector spaces. Take the dimensions of both sides and you get rank–nullity again, seen from a new angle.

Lights Out, solved

We now have every tool needed to settle the puzzle. Translate it into linear algebra over

  • a board is a vector in with 1 for on;
  • a plan of presses is a vector in with 1 for press;
  • the effect of a plan is where column of the matrix is the plus-shaped set of lights around button
  • the board can be switched off exactly when has a solution.

Row reducing over takes a long afternoon by hand and a millisecond by machine. (This book’s code does it, and its tests check every number in this section.) The result is: rank 23, nullity 2. Everything else follows from the theorems we have proved.

  1. Quiet patterns. The kernel has dimension 2, so it has elements: “press nothing” and three non-trivial quiet patterns, plans that leave every light exactly as it was. Show them in the figure below and press one: nothing changes, because every light is switched an even number of times.
  2. Solvable boards. The image has dimension 23, so exactly of the boards are solvable: one board in four.
  3. Number of solutions. The solutions of a solvable board form a coset of the kernel, so every solvable board has exactly 4 solutions. The figure’s solver uses the one with the fewest presses. The board with every light on, for instance, is solvable, and its shortest solution takes 15 presses.
Lights Out under the X-ray Click to press · tap a check
All lights off.
Solvable boards: of (one in ), each in = 4 ways.
Parity checks
Hover (or tap) a check to outline its cells. A board is solvable exactly when every check is even.
Quiet patterns (the kernel)
Pressing every gold-dotted button changes nothing at all: each light is toggled an even number of times.
Figure 1.5.10 The full machinery, starting from the board with every light on. Solve it presses the shortest solution; switch on show the presses to see it as violet rings. Show a quiet pattern marks a kernel element with gold rings and dots, and Press it shows that it changes nothing. The two parity checks decide solvability, as the next section explains. X-ray displays the matrix itself. Switch to paint lights to set up any board you like, including unsolvable ones.

Other sizes behave differently, and the figure lets you compare. On the board the matrix has rank 9 and nullity 0. There are no quiet patterns, so every board is solvable, in exactly one way. On the board the nullity is 4: sixteen quiet patterns, and only one board in sixteen is solvable. For boards with the nullities are and the sequence continues irregularly: (OEIS 2009).

Duality: measurements and reversed arrows

One question is still open. When a board is not solvable, how can we be sure? “A computer row reduced a big matrix” is convincing, but it does not explain anything. We would like a certificate: a short reason that anyone can check by hand.

Certificates of impossibility

Here is one. Look at the twelve cells in columns 1, 3 and 5 of the board, leaving out the middle row: the cells of “check 1” in the Lights Out figure above. Every button’s plus shape covers an even number of these cells, either 0 or 2; check a few. So every press changes the number of lit lights among those twelve cells by an even amount, and the parity of that number, even or odd, never changes however you press. The dark board has 0 lights on there, an even number. So a board with an odd number of lit lights among those cells can never be switched off. Checking that takes ten seconds, however many plans of presses there are.

The count we just used is a linear measurement of the board: add up the bits in those twelve positions, in Measuring the sum of two boards gives the sum of the two measurements, so this is a linear map from to The certificate worked because the measurement gives 0 on everything the buttons can make, but not on our board. Measurements like this deserve a name and a space of their own.

Covectors: the dual space

( and are the Greek letters phi and psi.) On every covector has the form for two numbers and because, like any linear map, it is determined by its values on and Its matrix is a single row, and measuring a vector means multiplying that row by the column So vectors are columns and covectors are rows. On a covector is a row of numbers, so for finite-dimensional spaces, which are the only ones we use.

How should we picture a covector? Not as an arrow. Draw instead the places where it takes the values For these are evenly spaced parallel lines: a stack. The value is the level that the tip of reaches, starting from line 0 at its tail: it counts the lines the arrow crosses (with a sign, negative if it goes down the numbering), plus a fraction for the last partial step. The covector is a ruler, and the lines are its marks.

A covector is a stack of lines Drag v and the blue handle
−2−101234567

The arrow crosses 3 whole lines going up the numbering, and the measurement reads . Drag the small blue handle (on the line marked 1) to change the measurement: pulling it out spreads the lines and makes the measurement smaller.

Figure 1.5.11 The covector drawn as its level lines Its value on is the level the tip of reaches: the gold dots mark the whole lines it crosses on the way. A bigger covector has denser lines: doubling doubles every measurement by packing the lines twice as tightly. Turn to run along the lines, and

Given a basis of the most useful covectors are the coordinate readers: reads off the -th coordinate. They satisfy when and otherwise, and they form a basis of called the dual basis. On with the standard basis, and

The transpose: pulling measurements back

Linear maps act on measurements too, but backwards. Suppose and is a measurement on Then “first apply then measure with is a measurement on the composite So gives a map going the other way, called the transpose, or dual map, of The arrow reverses: carries vectors forward from to and carries measurements back from to We say that pulls back

In matrices: if is the row then is the row Written as a column, that is where is the matrix flipped across its diagonal: the entry in row and column of is the entry in row and column of So the transpose you may know as “swap rows and columns” is exactly the act of pulling measurements back.

Pulling a measurement back Drag v and φ · change A
V, with the pulled-back measurement
−20246810
W, with the measurement
−2−10123456

Same number on both sides: measuring with is the same as measuring with the pulled-back . Its lines in are exactly the points that sends onto the lines in .

Figure 1.5.12 carries forward to the transpose carries the measurement back to Its lines in are exactly the points that sends onto s lines in so both sides always count the same crossings: With the rank-1 map, make vanish on the image, and the pulled-back measurement becomes zero.

Because the arrows reverse, so does the order of composition. Applying and then to vectors means pulling measurements back along first and then along Think of socks and shoes: you put on your socks and then your shoes, but you take off your shoes and then your socks. One more fact, which row reduction makes visible: The rank of is the number of independent rows of Row operations do not change the span of the rows, and in the reduced row echelon form the nonzero rows, one per pivot, are visibly independent. So the number of independent rows is the number of pivots, which is

Which targets can be reached?

Now we can state the theorem the Lights Out certificate was hinting at. If can be reached, then any measurement that is blind to everything produces, meaning or is also blind to The surprise is the converse: if no such measurement sees then can be reached. Whenever something is impossible, a certificate of its impossibility exists.

In the figure on solving equations, the measurement gives 0 on both columns of so and every with is out of reach. The theorem adds that when every such measurement gives 0, as it does on the teal line, a solution exists.

Over you may have met this theorem in another costume. Tip every row over into a column, and it says that the column space of and the null space of are perpendicular and together fill the codomain: half of what Gilbert Strang calls the fundamental theorem of linear algebra (Strang 1993). The version with measurements needs no angles, which is why it also works over Axler (2024, 3.128) proves it in the same language.

For Lights Out the theorem becomes concrete, thanks to a symmetry: button switches light exactly when button switches light since both say that the two cells are equal or neighbours. So the matrix equals its own transpose, and the measurements that are blind to every button are exactly the measurements “add up the lights in a quiet pattern”. Two quiet patterns span the kernel, so:

The third non-trivial quiet pattern is the sum of these two, so its check is the sum of their checks and tells us nothing new. The cells that belong to neither pattern are the centre and its four diagonal neighbours, and that is why a single light can be switched off on its own exactly there. Notice also the double role of a quiet pattern. As a set of presses, it is an element of the kernel of it changes nothing. As a set of cells to count, it is a measurement in the kernel of it detects unsolvable boards. Only the symmetry allows one pattern to play both parts.

The seed of cohomology

Here, in plain words, is why this section matters for the rest of the book. Homology will ask: which cycles are boundaries? That is a question about the image of a boundary map exactly like “which boards are solvable?”. Cohomology asks the dual question, with all the arrows reversed. Its objects, called cochains, are measurements on chains, and its basic map, the coboundary, is the transpose A measurement that gives 0 on every boundary but not on some cycle is a certificate that is not a boundary, that goes around a hole, in exactly the way that a parity check certifies that a board can never be switched off.

Linear algebra over the Smith normal form

Everything so far relied on a field: we divided freely, for instance to turn pivots into 1s. But homology is most informative with integer coefficients. Chains will be with whole-number coefficients, elements of the free abelian groups of §1.4 Abelian Groups and Formal Sums, and boundary matrices will have integer entries. In we may not divide, and that changes the story.

The smallest example says it all: the matrix the map “multiply by 2”.

  • Over it is invertible, since its inverse multiplies by kernel 0, image everything.
  • Over it is the zero map, because there: kernel everything, image 0.
  • Over it is neither. The map is injective, but its image is the even numbers and the leftover is not zero. That leftover is a group: it has a nonzero element, the class of 1, which becomes zero when doubled.

Torsion is information that division destroys. To keep it, we must work with integer operations only.

Which operations are allowed? The integer versions of the row operations, and now the same operations on columns as well:

  1. swap two rows, or two columns;
  2. multiply a row, or a column, by (the only integers with integer reciprocals are
  3. add an integer multiple of one row to another, or of one column to another.

Each of these can be undone by an operation of the same kind. Row operations change the basis of the codomain and column operations change the basis of the domain Why allow columns now? Because we are no longer solving one particular equation. We want the structure of the map, its kernel and its cokernel, and we are free to choose convenient bases at both ends. The cokernel of is the quotient the codomain with the image collapsed, “what is left over”.

This diagonal form is the Smith normal form, after the Oxford mathematician Henry John Stephen Smith, who introduced it in 1861 while studying systems of linear equations to be solved in whole numbers (Smith 1861). We abbreviate a diagonal matrix by listing its diagonal, as in the symbol is the of §1.4 Abelian Groups and Formal Sums, and is the group with one element. Reading off the answer is easy once the matrix is diagonal, because the map then does independent things to independent coordinates: it multiplies the -th coordinate by A factor leaves nothing behind, since A factor leaves the torsion And each of the rows without a diagonal entry leaves a whole free copy of

The algorithm imitates row reduction, with division replaced by division with remainder. Move the smallest nonzero entry to the top-left corner. Subtract whole multiples of its row and column to shrink the other entries of that row and column to their remainders. If any remainder is nonzero, it is smaller than the pivot: make it the new pivot and repeat. Since the entries keep shrinking, this stops, leaving the pivot alone in its row and column. Then make sure that the pivot divides every remaining entry (if not, add a row to bring an offending entry into play and clear again), and move on to the rest of the matrix.

The Smith normal form, step by step Step through
start
11
1−1

The starting integer matrix. Only integer row and column operations are allowed: no dividing.

Start
Figure 1.5.13 Only integer operations: each step is shown above the matrix, remainders become new pivots, and finished diagonal entries turn teal: in the new bases they generate the image. At the end the figure reads off the kernel and the cokernel, with its torsion. Try the example, where the divisibility rule turns into and the example, whose cokernel has elements.

This is the algorithm behind the of §1.4 Abelian Groups and Formal Sums: every finitely generated abelian group is with (There is the rank of the group, which is minus the rank of the relation matrix, and only the factors are listed.) Describe the group by generators and relations, write the relations as the columns of a matrix, and the Smith normal form reads off the decomposition. For instance, the group integer pairs modulo the subgroup generated by and comes from the matrix with those two columns. Its Smith form is so the group is with elements.

It is also how homology finds torsion. In §2.2 Gluing Spaces Together the Klein bottle is made from a square by gluing its sides according to the word and in §3.6 Exact Sequences and Mayer–Vietoris it is rebuilt from one vertex, two edges and one face. Walking around the face’s rim reads so the boundary matrix is the single column already in Smith form with With only one vertex, every combination of edges is a cycle, so the first homology, cycles modulo boundaries, is one ordinary loop, and one loop that becomes a boundary when it is traversed twice. The real projective plane, glued by the word gives the matrix and the torsion

Finally, the Smith form explains the puzzle of the triangle matrix. Over the rank of an integer matrix is the number of its invariant factors, since each can be divided away. Over the even factors become 0, so the rank is the number of odd invariant factors. The triangle matrix has invariant factors rank 3 over rank 2 over Ranks over and over differ exactly when some is even, that is, when there is 2-torsion around. That is why mod-2 homology and rational homology can disagree, and why integer homology, which sees the themselves, knows more than either.

Exercises

Summary

Further reading

  • Essence of Linear Algebra — 3Blue1Brown (Grant Sanderson) free
    Sixteen short animated lessons that think of matrices as transformations of a grid. Chapter 7 (column space and null space) and chapter 9 (dot products and duality) match this chapter almost picture for picture. The best first stop.
  • Immersive Linear Algebra — J. Ström, K. Åström and T. Akenine-Möller free
    An online textbook in which every figure can be dragged and rotated. Excellent for building geometric intuition in two and three dimensions.
  • Interactive Linear Algebra — Dan Margalit and Joseph Rabinoff free
    A complete first course with many small demonstrations. Particularly clear on row reduction and on solution sets as translated null spaces.
  • A clean, proof-based treatment, open access since its fourth edition. Read it after this chapter for full proofs of the exchange lemma, quotient spaces and duality.
  • MIT 18.06 Linear Algebra — Gilbert Strang free
    Strang's famous lecture course. His picture of the 'four fundamental subspaces' of a matrix is the duality theorem of this chapter, drawn as a diagram.
  • Turning Lights Out with Linear Algebra — Marlow Anderson and Todd Feil, Mathematics Magazine 71 (1998)
    The short classic article behind our Lights Out section: the puzzle as a linear system over ℤ/2, quiet patterns and all.
  • Computing Homology — Jeremy Kun free
    A programmer's walk from boundary matrices to Betti numbers by row and column reduction: this chapter, put to work. Best read alongside Part III.
  • Hodge Laplacians on graphs — Lek-Heng Lim free
    An elementary introduction that builds cohomology and Hodge theory on graphs out of nothing but matrices and their transposes. A rewarding read after Part IV.
  • Graphical Linear Algebra — Paweł Sobociński free
    A playful blog that rebuilds linear algebra from string diagrams. A very different and eye-opening angle on matrices, kernels and duality.

References

  1. Irving Kaplansky (1991). Reminiscences. in J. H. Ewing and F. W. Gehring (eds.), Paul Halmos: Celebrating 50 Years of Mathematics, Springer, 87–89. doi
  2. Sheldon Axler (2024). Linear Algebra Done Right (4th edition). Springer, Undergraduate Texts in Mathematics (open access). free online
  3. Jacques Hadamard (1893). Résolution d’une question relative aux déterminants. Bulletin des Sciences Mathématiques 17 (1893), 240–246.
  4. Raymond E. A. C. Paley (1933). On orthogonal matrices. Journal of Mathematics and Physics 12 (1933), 311–320. doi
  5. The OEIS Foundation (2026). Sequence A007299: Hadamard matrices of order 4n. The On-Line Encyclopedia of Integer Sequences, with links to the matrices of orders 668 to 1964 found in August 2026. free online
  6. John J. O’Connor and Edmund F. Robertson (2003). Nine Chapters on the Mathematical Art. MacTutor History of Mathematics Archive, University of St Andrews. free online
  7. Joseph F. Grcar (2011). How ordinary elimination became Gaussian elimination. Historia Mathematica 38(2), 163–218. free online
  8. Bruno Vallet and others (2009). A159257: Rank deficiency of the Lights Out problem of size n. The On-Line Encyclopedia of Integer Sequences. free online
  9. Marlow Anderson and Todd Feil (1998). Turning Lights Out with linear algebra. Mathematics Magazine 71(4), 300–303. doi
  10. Gilbert Strang (1993). The fundamental theorem of linear algebra. The American Mathematical Monthly 100(9), 848–855. doi
  11. Henry John Stephen Smith (1861). On systems of linear indeterminate equations and congruences. Philosophical Transactions of the Royal Society of London 151, 293–326. doi