Skip to content

Elimination

Subtract one equation from another until the system is a staircase, solve it from the bottom up, and watch the crossing point never move.

Helps to know first
This topic

First, the picture

Elimination solves equations by taking one from another. Watch what that does to the lines: one turns, and the crossing stays.

Elimination keeps the crossing point

One step: the second equation minus a multiple of the first.

Two lines, 2x − y = 4 and x + y = 5, crossing at (3, 2). The step: take one half of the first equation from the second.

second equation now
x + y = 5
0.00 / 6.00 s
Describe this picture

One panel with a grid and the two lines 2x−y=42x-y=4 and x+y=5x+y=5, crossing at the marked point (3,2)(3,2). A caption names the step: take one half of the first equation from the second. As the step plays, the line x+y=5x+y=5 turns about the crossing point until it lies flat, as the line 1.5y=31.5y=3, which is y=2y=2; a dashed copy shows where it started, and a readout gives the second equation as it changes. The crossing point never moves, and the first line stays where it is. A transport plays the step, pauses it and steps back; there is no other control.

Clear one unknown

Here are the two equations from Two pictures of a linear system:

2x−y=4,x+y=5.\begin{aligned} 2x-y&=4,\\ x+y&=5. \end{aligned}

If the second equation had no xx in it, it would give yy at once. So take a multiple of the first equation away from the second, chosen to remove the xx. The first equation has 2x2x and the second has 1x1x, so take away one half of the first:

(x+y)−12(2x−y)=5−12⋅4⟹1.5 y=3.(x+y)-\tfrac12(2x-y)=5-\tfrac12\cdot4 \quad\Longrightarrow\quad 1.5\,y=3 .

The 22 that we divided by is the pivot: the first number in the row we keep. The 12\tfrac12 is the multiplier: the number below the pivot, divided by the pivot. I’ll write the multiplier that clears row pp using row qq as

ℓpq=apqaqq,row p←row p−ℓpq⋅row q.\ell_{pq}=\frac{a_{pq}}{a_{qq}},\qquad \text{row } p \leftarrow \text{row } p-\ell_{pq}\cdot\text{row } q .

Here ℓ21=1/2\ell_{21}=1/2. The new second row starts with 0, and its first nonzero number, 1.51.5, is the second pivot.

Back substitution

The system now looks like a staircase:

2x−y=4,1.5 y=3.\begin{aligned} 2x-y&=4,\\ 1.5\,y&=3. \end{aligned}

Solve from the bottom up. The last equation gives y=2y=2. Put it into the first: 2x−2=42x-2=4, so x=3x=3. Solving from the bottom row upwards like this is back substitution.

Why the answer never moves

Look at the picture at the top of the page again. The second line turned, but it turned about the crossing point, so the answer stayed (3,2)(3,2).

That is no accident. Any pair that makes both old equations true also makes the new one true, because the new equation is the old second one minus half the old first one. And we can go back: adding half of the first equation to the new one gives the old second equation again. So the old system and the new system have exactly the same solutions. Elimination does not change the problem. It changes how the problem is written, until the answer can be read off.

Three equations

The same steps work for any size. Take three equations in three unknowns:

x+2y+z=2,3x+8y+z=12,4y+z=2.\begin{aligned} x+2y+z&=2,\\ 3x+8y+z&=12,\\ 4y+z&=2. \end{aligned}

The first pivot is the 1 in front of xx. The second row has 3x3x, so ℓ21=3\ell_{21}=3: take 3 times row 1 from row 2, which leaves 2y−2z=62y-2z=6. The third row has no xx, so ℓ31=0\ell_{31}=0. Now the second pivot is the 2 in front of yy. The third row has 4y4y, so ℓ32=4/2=2\ell_{32}=4/2=2: take 2 times the new row 2 from row 3, which leaves 5z=−105z=-10.

Watch the same steps on the table of numbers.

Steps on a grid of cells

Elimination clears every number below a pivot, row by row.

The three equations as cells, one row each, with the right-hand sides after the bar.

0.00 / 10.80 s
Describe this picture

The numbers of the three equations as a grid of cells, [A∣b][\mathbf{A}\mid\mathbf{b}]: three rows of xx, yy and zz numbers, with the right-hand sides after a dashed bar. Each cell is shaded by its number. The pivot in use is outlined. As each row is cleared, its multiplier appears beside it, ℓ21=3\ell_{21}=3, then ℓ31=0\ell_{31}=0, then ℓ32=2\ell_{32}=2, set out in the shape of a lower triangle; the row lights up and its cells change to their new numbers, with 0 below the pivot. At the end all three pivots are outlined and the grid reads 1,2,11,2,1 over 0,2,−20,2,-2 over 0,0,50,0,5, with right-hand sides 2, 6 and −10-10. The picture has no control.

Every number below the diagonal is now zero. A matrix like that is upper triangular, and I’ll call it U\mathbf{U}:

U=[12102−2005].\mathbf{U}=\begin{bmatrix}1&2&1\\0&2&-2\\0&0&5\end{bmatrix}.

Its diagonal holds the three pivots, 1, 2 and 5. Back substitution then runs from the bottom: 5z=−105z=-10 gives z=−2z=-2; 2y−2(−2)=62y-2(-2)=6 gives y=1y=1; and x+2(1)+(−2)=2x+2(1)+(-2)=2 gives x=2x=2. Check in the original equations: 2+2−2=22+2-2=2, 6+8−2=126+8-2=12 and 4−2=24-2=2.

When elimination breaks

A zero pivot. Take 2y=42y=4 and 3x+y=53x+y=5. The first equation has no xx, so the first pivot is 0, and dividing by it is impossible. The fix is to swap the two equations, a row exchange. Now the system is 3x+y=53x+y=5 and 2y=42y=4: already a staircase. So y=2y=2 and 3x+2=53x+2=5, which gives x=1x=1.

No fix. Take x+y=2x+y=2 and 2x+2y=52x+2y=5. The multiplier is 2, and taking twice the first from the second leaves 0=10=1. That is false whatever xx and yy are, so there is no solution: the lines are parallel. With 2x+2y=42x+2y=4 instead, the same step leaves 0=00=0. That is always true, so it puts no limit on anything, and there are infinitely many solutions: both equations are the same line. In both cases a pivot came out 0 and no lower row could replace it. A system like that is called singular.

Steps as matrices

Each step is itself a matrix. Taking 3 times row 1 from row 2 is the same as multiplying on the left by

E21=[100−310001].\mathbf{E}_{21}=\begin{bmatrix}1&0&0\\-3&1&0\\0&0&1\end{bmatrix}.

It is the identity with −ℓ21-\ell_{21} placed in row 2, column 1. Row 2 of E21A\mathbf{E}_{21}\mathbf{A} is −3-3 times row 1 of A\mathbf{A} plus row 2, exactly the step. Multiplying matrices comes from Matrix multiplication. With one such matrix for each step, the whole of elimination is

E32 E31 E21 A=U,\mathbf{E}_{32}\,\mathbf{E}_{31}\,\mathbf{E}_{21}\,\mathbf{A}=\mathbf{U},

where here E31\mathbf{E}_{31} is the identity, because ℓ31=0\ell_{31}=0, and E32\mathbf{E}_{32} holds −2-2 in row 3, column 2. The page LU factorisation runs these steps backwards.

How much work it takes

How long does elimination take on a big system? Count the multiply-and-subtract steps. With nn equations, clearing the first column changes about nn numbers in each of about nn rows, so about n2n^2 steps. The next column needs about (n−1)2(n-1)^2, then (n−2)2(n-2)^2, and so on. Added up, that is about

12+22+⋯+n2 ≈ n33.1^2+2^2+\cdots+n^2\ \approx\ \frac{n^3}{3}.

For n=1000n=1000 equations, that is about 3.3×1083.3\times10^8 multiply-and-subtract steps: a fraction of a second on a laptop. But double nn and the work grows eight times.

Worked example

  1. Two equations. 2x−y=42x-y=4, x+y=5x+y=5. Pivot 2, multiplier 12\tfrac12, second pivot 1.51.5. So 1.5y=31.5y=3, y=2y=2, then x=3x=3.
  2. Three equations. Multipliers 3, 0 and 2; pivots 1, 2 and 5; z=−2z=-2, y=1y=1, x=2x=2.
  3. A multiplier. What multiplier clears a 6 below a pivot of 2? 6/2=36/2=3.
  4. A zero pivot. 2y=42y=4, 3x+y=53x+y=5: exchange the rows, then y=2y=2 and x=1x=1.
  5. A zero row. If a step leaves 0=00=0, one unknown is free and there are infinitely many solutions. If it leaves 0=10=1, there are none.
  6. Predict. Does the crossing point move while elimination runs? No: each step keeps exactly the same solutions.

Where you’ll meet this

Most programs that solve a dense system run elimination, usually in the form of the page LU factorisation. A circuit simulator solves one system for the voltages at all the junctions of a chip. Programs that work out how a bridge or an aircraft wing bends cut the shape into small pieces and solve a system with one equation per piece, often hundreds of thousands. The solver in SciPy, a free Python library, does the same.

Reference card

QuantityFormulaNotes
Pivotaqqa_{qq} when row qq is usedmust not be 0
Multiplierℓpq=apq/aqq\ell_{pq}=a_{pq}/a_{qq}number to clear, over the pivot
Steprow p←p\leftarrow row p−ℓpq⋅p-\ell_{pq}\cdot row qqkeeps every solution
Resultupper triangular U\mathbf{U}, pivots on its diagonalthen back substitution
As matricesE32E31E21A=U\mathbf{E}_{32}\mathbf{E}_{31}\mathbf{E}_{21}\mathbf{A}=\mathbf{U}Epq\mathbf{E}_{pq} holds −ℓpq-\ell_{pq}
Zero pivotexchange with a lower rowif none: singular
Singulara row 0=10=1: none; 0=00=0: infinitely many
Costabout n3/3n^3/3 stepsnn equations

Keep reading with a free account.

By creating an account you accept the terms of use.

Sign in

Already have an account? Use the service you signed up with.

Or keep reading: get new lessons by email

Are you 13 or over?

Accounts and email updates are for people aged 13 or over. We keep only your answer, never your date of birth.

End of the lesson

Where to go next.

Phasorium

Account

Sign inKeep your place on any device

Subjects

Site

Look