Solving two equations in two unknowns is school algebra, and solving two thousand equations in two thousand unknowns is a different activity entirely, which is what this subject exists to make possible.
This course assumes the material of Mathematical Foundations: manipulating algebraic expressions, functions and their graphs, coordinates in the plane, and enough trigonometry to read and off a unit circle. Nothing else is assumed. In particular, calculus is never used, and where a connection to it exists it is signposted and skippable.
What makes an equation linear
An equation is linear in the unknowns when it can be written as
with the coefficients and the constant being fixed numbers. Every unknown appears to the first power, alone, multiplied only by a number. That rules out , it rules out , and it rules out , and . Note that qualifies, and so does , and so does , where the missing unknown is present with coefficient zero.
This looks like a severe restriction, and it is worth being clear that it is one. Most equations that describe the world are not linear. What makes the restricted class worth an entire subject is a combination of three facts. Linear systems can actually be solved, exactly, by a procedure that always terminates. Many genuinely non-linear problems are linear when examined closely enough, which is why a bridge deflecting slightly under load, a circuit at small signal, and a chemical mixture at low concentration are all handled linearly. And problems that are hopelessly non-linear are usually attacked by solving a linear system repeatedly, which is what Newton's method, every finite element package and every step of training a neural network are doing underneath.
A system of linear equations is several of them at once, sharing their unknowns. A solution is an assignment of numbers to the unknowns that satisfies every equation simultaneously, not merely one of them. The entire difficulty is that word: simultaneously.
Two unknowns, and two lines
With two unknowns the whole situation is visible. The equation is satisfied by infinitely many pairs , and plotted in the plane they form a straight line, which is why the equations are called linear in the first place. A second equation gives a second line. A solution of the system is a point on both lines, so solving the system means intersecting them.
Two distinct lines in a plane intersect in exactly one point unless they are parallel, in which case they meet nowhere, unless they are the same line, in which case they meet everywhere along it. Those are the only three possibilities, and no fourth case exists: two lines cannot meet in exactly two points. That fact is worth holding on to, because it survives intact into two thousand dimensions where nothing can be drawn.
Example. Solve and .
Multiply the second equation by to get , and add it to the first, so that the terms cancel: , giving . Substituting back into the second equation, , so . Check both original equations: and . The lines cross at .
Now you. Solve and .
Answer
Multiply the second by to get and add: , so , and then . Check: and . The solution is .
Elimination
The method in that example, adding a multiple of one equation to another so that an unknown vanishes, is the whole of it. Scaled up and made systematic it is called Gaussian elimination, though it appears in the Chinese Nine Chapters on the Mathematical Art around two thousand years before Gauss, worked with counting rods on a board.
Three operations are permitted, and each is reversible, which is what guarantees that they never gain or lose a solution. Any equation may be multiplied by a non-zero number. Any multiple of one equation may be added to another. Any two equations may be swapped. The goal is to reach a triangular form, in which the first equation involves all the unknowns, the second has lost the first unknown, the third has lost the first two, and so on down, at which point the last equation contains one unknown and the rest fall out by back substitution.
Take a system of three:
Use the first equation to remove from the other two. Adding times the first to the second gives . Adding the first to the third gives . The first unknown is now confined to the first equation.
Now use the new second equation to remove from the third. Subtracting times from gives , so .
Back substitute. From with : , so . From the first equation, , so and . The solution is , and substituting it into all three original equations gives , and as required.
Two features of that calculation matter more than the answer. It was mechanical: at no point was ingenuity required, only a decision about which equation to use to clear which unknown. And it terminated: there is no possibility of the procedure wandering, because each step permanently removes one unknown from one equation and the supply of both is finite.
Example. Solve , and by elimination.
Subtract times the first from the second: . Subtract the first from the third: . Now subtract the second of these from the third: , so . Then , so , and . Check the second equation: , as required.
Now you. Solve , and .
Answer
Subtract times the first from the third: , so . Combine with : substituting gives , so and . Then and . The solution is , which satisfies all three.
The three outcomes
Elimination cannot fail, but it can end somewhere other than a triangle, and there are exactly two ways for that to happen.
Take and . Subtracting twice the first from the second gives , which no assignment of and can satisfy. The system is inconsistent and has no solution. Geometrically the two lines have the same slope and different intercepts: they are parallel, and never meet.
Now change one digit: and . The same step gives , which every pair satisfies. The second equation was the first one in disguise, carrying no information, and the system is left with one genuine equation in two unknowns. Setting to any value gives , so the solutions form a whole line: , , and infinitely many more. The system is underdetermined.
So a linear system has no solution, exactly one, or infinitely many. It can never have exactly two, or exactly seventeen. The reason is easy to see and worth seeing now: if and are both solutions then so is every point on the line joining them, because averaging two solutions of in any weighted way that sums to one gives again. Two solutions therefore drag a continuum in with them. Later lessons make this precise, and give the solution set a name and a dimension.
Example. Classify and .
Add times the second to the first: . The second equation is times the first, so there is one genuine equation, , and infinitely many solutions: , . Two of them are and , and both satisfy the original pair.
Now you. Classify and .
Answer
Multiply the first by : . Adding the second gives , which is false, so the system is inconsistent and has no solution. The two lines both have slope and different intercepts.
What it costs
The reason a subject is needed rather than a technique is that grows. Clearing the first unknown from equations of numbers each costs roughly multiplications, and repeating for each unknown in turn totals about multiplications and as many additions. For that is operations, a fraction of a second on any laptop. For it is , about forty seconds at a billion operations per second. For , the size of system a serious engineering simulation produces, it is , which is out of reach by brute force and is solved instead by methods that exploit the structure of the particular matrix, most of whose entries are zero.
Compare the alternative that school sometimes teaches for small systems, Cramer's rule, which expresses each unknown as a ratio of determinants. Computing an by determinant by the naive expansion costs about multiplications. For that is operations, seventy-seven years at a billion per second, against operations for elimination. Cramer's rule is a theoretical statement, not an algorithm, and this course will treat it as one.
Example. Roughly how many multiplications does elimination need for , and how does that compare with ?
Using : for it is . For it is . Ten times the unknowns costs a thousand times the work, because the count is cubic.
Now you. A solver manages multiplications per second. Roughly how long does it take on a system with ?
Answer
multiplications, so about seconds. Doubling to would take eight times as long, near three minutes.
The unknowns were never used
Look back at the elimination worked above and ask which symbols did any work. The letters , and were carried through every line and never once entered a calculation. All the arithmetic happened to the coefficients, and the letters were placeholders keeping the columns aligned. Written without them, the first system is nothing but a rectangle of numbers, with rows , and , together with the right hand side .
That rectangle is a matrix, and the course to come is largely about taking it seriously as an object in its own right rather than as shorthand for a system. Two conventions are fixed now and used for the rest of the subject. A vector is a column of numbers, written in round brackets as . A matrix is written as the list of its columns, so is the coefficient matrix of that system, whose first column collects the coefficients of from all three equations. When elimination needs to talk about a row it will say so explicitly.
Writing the system by columns exposes something the row form hides. The three equations, taken together, say precisely that
where the multiplications and additions happen component by component. Solving is therefore asking what amounts of the three column vectors, added together, produce the target vector. That reading is the door into the geometry, and it turns the three outcomes above into three pictures rather than three algebraic accidents.
Honest limits
Exact arithmetic makes elimination flawless, and computers do not have exact arithmetic. If a pivot, the coefficient being divided by, is very small, dividing by it magnifies whatever rounding error the entry already carried, and the answer can come out wrong in every digit while the procedure reports no difficulty. The standard defence is partial pivoting: before clearing a column, swap in the row whose entry in that column is largest in absolute value. This costs almost nothing and, as James Wilkinson established in his backward error analysis around 1961, makes elimination reliable in practice, though contrived matrices that defeat it do exist. Every numerical library performs the swap by default.
There is also a limit worth naming at the start. Everything in this subject is exact and complete for the linear class, and the class really is a restriction. Nothing here will solve . What the subject offers in exchange is that within its class, questions have answers and the answers can be computed and checked.
The next lesson takes up the column vectors that the coefficient matrix turned out to consist of, and asks what they are and what can be done to them.