skip to content

Rank and Linear Systems

The structure behind Ax = b: how many independent directions a matrix really carries, when a solution exists, and when it is unique. Rank deficiency is behind most unstable fits.

on this pageshow

explore

questions

10

When does the linear system Ax = b have no solution, exactly one, or infinitely many?

level: juniorimportance: must knowfreq 62%

answer

  1. read the augmented column, not just A
  2. a vanished row tells two different stories
  3. 0 = 1 versus 0 = 0
  4. pivot columns versus free columns
  5. never exactly two solutions

basics

~20 s

Run Gaussian elimination on the augmented matrix. A row that is all zeros on the left but nonzero on the right means no solution. Otherwise, one pivot per unknown means exactly one solution; any free unknown means infinitely many.

solid answer

~40 s

Put the augmented matrix `[A | b]` into row echelon form by Gaussian elimination and read the answer off the pivots. If elimination produces a row that is all zeros in the coefficient part but nonzero in the augmented column - a row asserting `0 = 1` - the equations contradict each other and there is no solution. If no such row appears the system is consistent, and then you count pivots: if every unknown sits in a pivot column there are no free variables and the solution is unique. If some column carries no pivot, that unknown is free, you can set it to anything and back-substitute, so there are infinitely many solutions. Over the real numbers there is no fourth case - zero, one, or infinitely many, never exactly two.

go deeper

for a junior

Be ready to eliminate a small system by hand and say out loud which of the three outcomes you reached and why. Knowing that a zero row means different things depending on the right-hand entry is the whole ask.

for a middle

Explain the mechanics: row operations preserve the solution set, pivots versus free columns decide uniqueness, and consistency is about whether b agrees with the columns of A. Expect to justify why exactly two solutions is impossible.

for a senior

Connect the cases to real failures - a solver reporting singularity, a fit that will not converge, duplicated feature columns. Show how you diagnose which case you are in from the data rather than from the error message.

for a principal

Own the modelling call. When a system is structurally under-determined, decide whether to gather more independent measurements, drop redundant unknowns, or accept a family of answers with an explicit tie-breaking rule - and be able to defend the choice to non-specialists.

## What the question is really asking `Ax = b` is a compact way of writing m linear equations in n unknowns. `A` is the m-by-n matrix of coefficients, `x` is the vector of unknowns, and `b` is the vector of right-hand sides. Before you compute anything, an interviewer wants to know whether you understand that such a system has exactly three possible fates: no solution, one solution, or an infinite family of solutions. ## The mechanical procedure: elimination on the augmented matrix Write the coefficients and the right-hand side side by side as the augmented matrix `[A | b]`, then use the three row operations - swap two rows, scale a row by a nonzero number, add a multiple of one row to another - to reach row echelon form. None of these operations changes the solution set, which is the whole reason the method works. In echelon form each nonzero row starts with a leading nonzero entry called a **pivot**, and pivots move strictly rightward as you go down. ## Case 1 - no solution (inconsistent) Take ``` x + y + z = 3 x + 2y + 3z = 6 2x + 3y + 4z = 10 ``` Subtracting row 1 from row 2 gives `(0, 1, 2 | 3)`. Subtracting twice row 1 from row 3 gives `(0, 1, 2 | 4)`. Subtracting the new row 2 from the new row 3 gives `(0, 0, 0 | 1)`, which reads `0x + 0y + 0z = 1`. No numbers can satisfy that, so the original system has no solution. Notice the third equation was, on the left, exactly the sum of the first two - but its right-hand side was not the sum of the first two right-hand sides. The equations disagree about a quantity they jointly determine. ## Case 2 - infinitely many solutions Change the last right-hand side from 10 to 9: ``` x + y + z = 3 x + 2y + 3z = 6 2x + 3y + 4z = 9 ``` The same elimination now ends with `(0, 0, 0 | 0)`, a row that says `0 = 0`. That is not a contradiction, just a redundant equation. Two pivots survive, in the columns for `x` and `y`, and the column for `z` has no pivot - `z` is a **free variable**. Setting `z = t` and back-substituting gives `y = 3 - 2t` and `x = t`, so every vector `(t, 3 - 2t, t)` solves the system. Geometrically the three planes meet in a line rather than a point, and the line is the entire solution set. ## Case 3 - exactly one solution If elimination leaves a pivot in every one of the n columns of `A` and produces no contradictory row, back-substitution pins each unknown to a single value. The three planes meet in a single point. ## The compact statement A system is **consistent** exactly when `b` can be written as a combination of the columns of `A`; equivalently, elimination never produces a zero coefficient row with a nonzero right-hand entry. This consistency criterion is also stated as: the coefficient matrix and the augmented matrix must have the same number of pivots. Given consistency, the solution is unique precisely when the columns of `A` are linearly independent, so that every column earns a pivot and no free variable exists. ## Why exactly two solutions is impossible Suppose `x1` and `x2` both solve `Ax = b` and are different. For any number t, the vector `x1 + t(x2 - x1)` satisfies `A(x1 + t(x2 - x1)) = b + t(b - b) = b`. Every point on the line through the two solutions is also a solution, so as soon as you have two you have infinitely many. This is a favourite quick check in interviews and follows purely from linearity. ## Shape intuition, and its limits More equations than unknowns (`m > n`, overdetermined) usually means no exact solution, and fewer equations than unknowns (`m < n`, underdetermined) usually means infinitely many - but *usually* is not *always*. A tall system whose right-hand side happens to be consistent has an exact solution; a wide system can still be inconsistent if two of its rows contradict each other. Never answer from the shape alone; the pivots decide. ## Where this shows up in practice When a fitted model blows up or a solver reports a singular matrix, it is almost always case 1 or case 2 in disguise: duplicated or derived columns leave an unknown free, or noisy measurements make equations that should agree disagree. Recognising which case you are in tells you whether to add information, remove a redundant unknown, or move from exact solving to a best-fit formulation.

  • You are told a system of 5 equations in 5 unknowns has two different solutions. What can you conclude?
    That it has infinitely many. If `x1` and `x2` both solve `Ax = b`, then so does `x1 + t(x2 - x1)` for every t, because `A` applied to that vector gives `b + t(b - b) = b`. So a whole line of solutions exists, which also tells you the columns of `A` are not independent - elimination must leave at least one free variable.
  • Does having more equations than unknowns guarantee that Ax = b has no solution?
    No. It makes an exact solution unlikely once the right-hand side carries noise, but a tall system is perfectly solvable when `b` is consistent with the columns of `A` - for example when the extra equations are exact copies or exact combinations of the others. Only elimination settles it: look for a zero coefficient row paired with a nonzero right-hand entry.
  • During elimination you hit a zero row. What do you look at next?
    The augmented entry on that same row. Zero on the right means the equation was redundant and the system stays consistent, with the missing pivot creating a free variable and an infinite family of solutions. Nonzero on the right means the equations contradict each other and no solution exists. The coefficient part alone cannot distinguish the two cases.

Think of each equation as a constraint on a suspect's whereabouts. Contradictory statements mean no suspect fits at all; consistent but incomplete statements leave a whole street of suspects.

saying these in an interview costs you the question

  • Claiming a system can have exactly two distinct solutions
  • Deciding solvability from the shape of A without eliminating
  • Treating any zero row as proof of infinitely many solutions
  • Eliminating on A alone and ignoring the augmented column
  • Saying square systems always have exactly one solution

context

open as a page

In a feature matrix, what does it mean for the columns to be linearly dependent?

level: juniorimportance: must knowfreq 60%

basics

~20 s

Linearly dependent columns means one column equals a weighted combination of the others, adding no new direction. A table holding hours_weekday, hours_weekend and their exact total is the classic case; that matrix is rank deficient.

open as a page

How do you solve an overdetermined system Ax = b when no exact solution exists?

level: middleimportance: must knowfreq 66%

basics

~20 s

Choose the x that makes the residual b - Ax as short as possible instead of demanding equality. That least-squares x satisfies A transpose A x = A transpose b, a small square system that always has a solution.

open as a page

What does the rank-nullity theorem give for a 5x3 matrix of rank 2?

level: middleimportance: must knowfreq 55%

basics

~20 s

Rank-nullity says rank plus nullity equals the number of columns. A 5x3 matrix of rank 2 therefore has nullity 3 - 2 = 1: the vectors it sends to zero form a line through the origin in three-dimensional space.

open as a page

Why solve Ax = b with an LU factorization instead of computing the inverse of A?

level: middleimportance: should knowfreq 48%

basics

~20 s

Factoring A into lower and upper triangular factors costs about a third of what forming the inverse costs and is more accurate. It is also reusable: each new right-hand side then needs only two cheap triangular solves.

open as a page

Solving Ax = b gives wildly different x for tiny changes in b - what is going on?

level: seniorimportance: should knowfreq 44%

basics

~20 s

The matrix is ill-conditioned, not the solver buggy. Its condition number - how much a relative change in b is magnified in x - is large, so noise in the last digits swings the answer.

open as a page

Two feature columns correlate at 0.999 - is that matrix rank deficient?

level: seniorimportance: should knowfreq 38%

basics

~20 s

No. A correlation of 0.999 is not an exact linear identity, so the two columns stay independent and the matrix is full rank. It sits a hair from rank deficiency, so arithmetic on it behaves almost as badly.

open as a page

For a 3x3 matrix whose columns span only a plane, what does its nullspace say about solutions of Ax = b?

level: seniorimportance: should knowfreq 42%

basics

~20 s

A 3x3 matrix whose columns span only a plane has rank 2 and a one-dimensional nullspace. If b lies in that plane, solutions form a line: one particular solution plus any multiple of the nullspace vector. Otherwise none exist.

open as a page

Why does one vector in R^2 have different coordinates in the standard basis and a rotated basis?

level: middleimportance: nice to knowfreq 32%

basics

~20 s

Coordinates are the weights that rebuild a vector from a chosen basis, so they belong to the basis, not to the vector. Rotate the basis and the arrow is unchanged while the list of weights describing it changes.

open as a page

Why solve a least-squares system by QR factorization rather than forming A transpose A?

level: seniorimportance: nice to knowfreq 28%

basics

~20 s

Forming the cross-product matrix squares the condition number, so you lose twice as many digits and can turn a full-rank problem into a numerically singular one. QR instead factors the original matrix with length-preserving transformations.

open as a page