One, none or infinitely many
The system of lesson 3.3.1 had exactly one solution, the point where two lines cross. Lesson 1.2.1 found two other ways two lines can sit: parallel, or one line written twice.
Keep the first equation, , and change the second:
- : the lines cross once, at . One solution.
- : halved, this is , a parallel line. No solution.
- : halved, this is the first equation again. Every point of the line solves both. Infinitely many solutions.
One first equation, three second equations. Crossing lines share one point, parallel lines share none, and a line written twice shares all its points.
Rule: How many solutions
A linear system never has exactly two solutions. If two different points solve it, so does every point on the line through them.
What elimination shows
Run elimination (lesson 3.3.1) on the three systems. In each, clears the first column and leaves one new row.
| second equation | new row 2 | reads | solutions |
|---|---|---|---|
| one: | |||
| none | |||
| infinitely many |
A row is false whatever the unknowns are, so the system has no solution. A row is true for every choice: it adds no condition, so only is left.
In that last case can be anything. Call it ; then . Every value of gives a solution:
| 0 | 1 | 2 | ||
|---|---|---|---|---|
The column picture
Lesson 3.3.1 read as a question: which combination of the columns gives ? Here the columns are and . The second is twice the first, so both point along the same line through 0.
Every combination is a multiple of and stays on that line. The point lies on it and is reached in many ways: , or , or . The point is off the line, and no combination reaches it.
Columns pointing in different directions reach every point of the plane. Columns along one line reach only that line: on it, in many ways, and off it, never.
Try it
Each loop pass builds one augmented matrix, does and prints the new row 2.
The second loop checks the four solutions of the table in . The last line checks the three combinations that reach .
Rank: the number of pivots
The rank of a matrix is the number of pivots in its row echelon form. It counts the equations that really constrain the unknowns, once repeats and combinations are cleared away.
- has rank 2: elimination leaves pivots 1 and .
- has rank 1: the second row becomes zeros.
- The 3 × 3 matrix of lesson 3.3.1 has rank 3, with pivots 1, 1 and 3.
Rule: Rank
Each pivot needs its own row and its own column. So the rank is at most the number of rows, and at most the number of columns. Count pivots after elimination, not nonzero rows before it.
A square matrix of rank has a pivot in every column. Then has exactly one solution for every , and has an inverse (lesson 3.2.3).
With rank below , some column of is a combination of the others, as above. Such a matrix has no inverse. Lesson 3.4.1 tests for this with the determinant, and lesson 3.5.1 calls the columns dependent.
Free variables and the shape of the solutions
In row echelon form, each column with a pivot gives a pivot variable. The unknowns of the other columns are free variables: they may take any value, and back substitution then fixes the pivot variables.
Rule: Free variables
Here is the number of unknowns, the columns of . When the system has solutions, 0 free variables give a single point, 1 gives a line and 2 give a plane.
A line in space. Take three equations in three unknowns, with :
The steps , and then give
The pivots sit in columns 1 and 3, so the rank is 2 and is free.
Set . Row 2 gives , and row 1 gives . The solutions form a line in , through in the direction :
A plane. In , , , rows 2 and 3 are multiples of row 1. Elimination leaves one pivot, so the rank is 1 and two unknowns are free.
With and , every works. The solutions form a plane, which contains , , and .
Try it
np.linalg.matrix_rank returns the rank. The first line prints it for the four matrices above.
The loops put points of the line and of the plane back into each system. Every product reproduces the right-hand side.
Is there a solution at all?
A system with at least one solution is consistent. Elimination on settles it: the system has no solution exactly when some row reads with . That row has its pivot in the column, so has one more pivot than .
Change the last entry of above from 13 to 12. The same steps now end in the row , which reads . The rank of is still 2, but the rank of is 3.
Rule: Consistency
The two ranks are those of and of ; the second can only be equal or larger by 1. Compare them first. If they are equal, the system is consistent, and the number of free variables, , decides between one solution and infinitely many.
More equations than unknowns, or fewer
The rule works for systems of any shape. A tall system has more equations than unknowns. Take , and : three lines in the plane.
Elimination with , and leaves the row . Both ranks are 2, the number of unknowns, so there is one solution, . Change the 4 to 5 and the last row is : no solution.
Three lines rarely pass through one point, so a tall system usually has no solution. Its rank is at most the number of unknowns, below the number of equations, so some right-hand sides are always out of reach. Case study 3.3.4 meets this with three states of the world and two assets.
A wide system has fewer equations than unknowns. Take and : the rank is 2 and there are 3 unknowns, so one is free.
With , the solutions are , a line. A wide system never has exactly one solution.
Try it
consistent compares the two ranks; np.column_stack puts beside . The cell tests the 3 × 3 system with 13 and with 12, then the tall system with 4 and with 5.
The last line puts two points of the wide system's line back in: both give .
Rank on a computer
On a computer, rounding hides zeros. In the second row is 3 times the first, so the rank is 1. But 0.1, 0.3, 0.7 and 2.1 have no exact binary form, and elimination leaves where a 0 should be.
np.linalg.matrix_rank allows for this: it treats numbers that small, relative to the matrix, as zero, and returns 1. np.linalg.solve is less careful. Here it raises no error and returns numbers as large as , which mean nothing.
Try it
The cell does the elimination step by hand and prints what is left in the second pivot place. Then matrix_rank gives 1.
solve returns two huge numbers, printed to one digit. Check the rank before trusting solve on a matrix that may be singular.
Nearly singular systems
A matrix can have full rank and still behave almost like a singular one. Take and , two lines that are almost parallel. The answer is .
Now move the right-hand side of the second equation a little:
| 2.000 | 2.001 | 2.002 | 2.003 | |
|---|---|---|---|---|
A change of 0.001 in moves each unknown by 1. When two lines are nearly parallel, sliding one a little slides their meeting point a long way.
Such a system is ill-conditioned: small errors in the data, such as rounding or a mistyped price, become large errors in the answer. np.linalg.cond puts a number on it, the condition number, here about 4002. Case study 3.4.3 meets this with assets that are almost copies of each other.
Try it
The rank is 2, so there is one solution for each , but it swings. np.round(…, 4) hides rounding in the last digits.
The explorer shows the cases of this lesson in both pictures. Pick each preset in turn. On "Nearly parallel", move by one step of 0.05 and watch the meeting point jump by a whole unit.
Explore
Each row of the system is a line, and the solution is where the lines meet. The same numbers say how much of each column of A it takes to reach b. Change the entries and watch both pictures.
Rows: row 1 and row 2 as lines.
Columns: x₁ copies of a₁, then x₂ of a₂, dashed.
- System
- Solution
- x₁ = 1, x₂ = 1
- a₁₁a₂₂ − a₁₂a₂₁
- −3
- Sensitivity
- if b₂ moves by 0.01, the solution moves by 0.0075
- So
- One solution: the lines cross at one point.
Common mistakes
- A row is not a contradiction. It adds no condition; with fewer pivots than unknowns it means free variables.
- A row with means no solution, not that some unknown is 0.
- Count pivots after elimination. has two nonzero rows but rank 1.
- Free variables are unknowns minus rank, , where counts columns, not equations.
- Shape is not the whole story. A tall system can have exactly one solution, as above. A wide one can never have exactly one.
- Do not trust a tiny pivot or a quiet
solve. Checkmatrix_rank, and remember that a nearly singular system can magnify small errors.
Rank and solution sets
0 of 11 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Summary card
- A linear system has no solution, exactly one, or infinitely many. In the plane: parallel lines, crossing lines, or one line written twice.
- Elimination shows which: a row with means none; a row adds no condition.
- The rank of is the number of pivots, at most the number of rows and of columns. A square matrix has an inverse exactly when its rank is .
- Free variables number ; the solutions form a point, a line or a plane for 0, 1 or 2 of them.
- Consistent exactly when . Tall systems usually have no solution; wide ones never have exactly one.
np.linalg.matrix_rankallows for rounding;solvemay not notice a singular matrix. A nearly singular system can turn small changes in into large changes in .