Why a Pivot in Every Row Means Consistency Is Guaranteed

Part 3 of 5 in Matrix Algebra: Systems, Pivots, and Inverses

The idea

When you row-reduce an augmented matrix [A | b], the system Ax = b is inconsistent if and only if a new pivot lands in the last column (the b-column). That pivot represents a contradictory equation like [0 0 ... 0 | nonzero]. But here is the thing that often gets glossed over: a new pivot can only appear in the b-column when A itself runs out of pivots.

If A has a pivot in every one of its rows, then every row already carries a leading entry before we even look at the augmented column. There is no room for the b-column to steal a pivot position. The system is consistent regardless of what numbers sit in b.

The code

This script implements Gaussian elimination from scratch, tracking exactly which columns become pivots. It runs two scenarios side by side: a matrix with three pivots in three rows (three different b vectors, all consistent) and a matrix with only two pivots where one choice of b produces an inconsistent system.

def gaussian_elimination_with_pivots(A_aug):
    M = A_aug.copy().astype(float)
    m, n = M.shape

    pivot_row = 0
    pivot_cols = []

    for col in range(n):
        if pivot_row >= m:
            break

        max_idx = np.argmax(np.abs(M[pivot_row:, col])) + pivot_row
        if abs(M[max_idx, col]) < 1e-10:
            continue

        M[[pivot_row, max_idx]] = M[[max_idx, pivot_row]]

        for row in range(pivot_row + 1, m):
            if abs(M[row, col]) > 1e-10:
                factor = M[row, col] / M[pivot_row, col]
                M[row, col:] -= factor * M[pivot_row, col:]

        pivot_cols.append(col)
        pivot_row += 1

    rank = len(pivot_cols)
    return rank, pivot_cols
def test_system(A, b, label):
    n_rows, n_cols = A.shape
    augmented = np.column_stack([A, b])

    rank_A_pivots, _ = gaussian_elimination_with_pivots(A)
    rank_aug, pivot_cols = gaussian_elimination_with_pivots(augmented)

    aug_col_index = n_cols
    augmented_has_new_pivot = aug_col_index in pivot_cols

    if augmented_has_new_pivot:
        print(f"INCONSISTENT -- pivot appears in the augmented column")
    else:
        print(f"CONSISTENT -- rank(A) == rank([A | b])")

The full script is available in gaussian_demo.py — it constructs two coefficient matrices, runs elimination on each with multiple right-hand sides, and prints the ranks of A and [A | b] together with a verdict.

Running it

Case A uses a nearly-identity-friendly 3x3 matrix that has full rank (three pivots). We tried three wildly different b vectors — one tiny, one alternating sign, one dominated by 1000 — and all three came out consistent. The ranks of A and [A | b] both stayed at 3 for every single run.

Case B uses a matrix whose third row is exactly twice the first row, so only two pivots emerge. With a carefully chosen b that respects that dependency ([1, 2, 2]), the augmented column brings in nothing new and the system stays consistent. Change just one entry to 5, and rank([A | b]) jumps to 3 while rank(A) stays at 2 — the augmented column picked up a pivot, meaning a contradiction row appeared.

The pattern is clean: inconsistency requires rank([A | b]) > rank(A). That gap can only open when b injects information that A’s rows don’t already span — which is impossible when those rows already produce a pivot in every row.

Takeaway

A pivot in every row of A means rank(A) equals the number of rows, so there are no zero rows for b to hide behind. The augmented column can never become a pivot column, and the system is consistent for any right-hand side — period.