A zero entry in the first diagonal position can stop an elimination procedure that insists on using that entry as its divisor. It does not prove that the entire matrix is singular. Another equation may supply a usable pivot once the equations are reordered.
The distinction is especially easy to lose when a factorization returns a permutation separately from its triangular factors. Reordering the coefficient matrix without applying the same row ordering to the right-hand side solves a different system.
We will use a fully specified invented linear system and exact rational arithmetic. No numerical library or robot estimator was executed. The example concerns equation solving rather than a claim about the accuracy of an actual calibration model.
Write all three original equations
Let A have rows (0,2,1), (1,1,0), and (2,0,1). Let b = (7,3,5) transpose. The unknown vector x has three coordinates. The first equation is 2x_2 + x_3 = 7, even though its coefficient of x_1 is zero.
Straight elimination beginning with A_11 would attempt to divide by zero. Yet x = (1,2,3) satisfies all three equations: its predicted right-hand side is (7,3,5). We will additionally establish that the solution is unique through nonzero triangular pivots.
LAPACK documents partial pivoting through row interchanges and distinguishes an exactly zero U diagonal from a successful factorization. SciPy's official lu reference states a permutation-times-triangular-factor convention. The factors and permutation below are independently derived, with our convention stated explicitly.
Choose pivots from the remaining rows
For the first column, the largest absolute candidate is two in original row three. Move that row first. The remaining rows are initially original rows two and one. The original second row has first-column elimination multiplier one half; subtracting half of the new first row leaves (0,1,-1/2).
Original row one remains (0,2,1). Among the remaining second-column entries one and two, choose two, moving original row one into the second position. The final equation order is therefore original rows three, one, two.
Subtracting one half of the second pivot row from the remaining row leaves (0,0,-1). The upper triangular matrix U has rows (2,0,1), (0,2,1), and (0,0,-1).
With this final row ordering, the unit-lower-triangular matrix L has rows (1,0,0), (0,1,0), and (1/2,1/2,1). The two lower multipliers record exactly the eliminations needed after accounting for the final permutation.
Define the permutation by its action
Let P have rows (0,0,1), (1,0,0), and (0,1,0). Multiplying P by any three-entry column moves its entries into order three, one, two. Multiplying P by A applies that ordering to equations.
Our factorization is P A = L U. Indeed, L U has rows (2,0,1), (0,2,1), and (1,1,0), exactly the reordered rows of A. Direct multiplication verifies the relationship without relying on a function name.
This permutation is a three-cycle. P is not equal to its transpose, and applying it twice does not restore the original order. That makes it a useful example: a single row swap would be its own inverse and could hide a convention mistake.
SciPy states A = P_library L U, rather than our P A = L U. For these same factors, its permutation matrix would be P_library = P transpose. Both equations can be correct; the symbol's meaning must follow the displayed identity.
Permute the right-hand side before solving
The original equation A x = b becomes L U x = P b. Here P b = (5,7,3) transpose. Introduce y = U x and first solve L y = P b by forward substitution.
The first two rows give y_1 = 5 and y_2 = 7. The last row gives y_3 = 3 - (1/2)5 - (1/2)7 = -3. Thus y = (5,7,-3).
Back substitution in U x = y starts with -x_3 = -3, so x_3 = 3. The second row gives 2x_2 + 3 = 7, hence x_2 = 2. The first gives 2x_1 + 3 = 5, hence x_1 = 1.
The residual against the original equations is exactly zero. Checking only the reordered triangular system would be a weaker check if the permutation had been supplied incorrectly.
See the consequence of forgetting P b
Suppose someone instead solves L U x_wrong = b using the unchanged vector (7,3,5). Forward substitution gives y_wrong = (7,3,0). Back substitution gives x_wrong = (3.5,1.5,0).
Substituting that result into A produces (3,5,7), not (7,3,5). The factors themselves are still valid. The mistake was pairing reordered equations with an unreordered right-hand side.
For several right-hand-side columns, the same permutation must be applied to every column. Reusing a factorization can avoid repeated coefficient elimination, but does not remove this equation-order requirement.
Separate factorization progress from numerical guarantees
The diagonal of U is (2,2,-1), so its determinant is -4. The row permutation is two swaps, with determinant positive one. Thus A also has determinant -4 and is invertible despite its initial zero diagonal entry.
An exactly zero final pivot has a different meaning from a zero unpermuted starting entry. LAPACK documents its singular-factor status explicitly. Conversely, nonzero pivots alone do not establish favorable conditioning or accurate answers for every finite-precision problem.
Partial pivoting chooses a large-magnitude available column entry to avoid an unnecessary small divisor. This example establishes the algebra of that row selection, not a universal bound on all rounding effects. Preserve the original equation order, the precise permutation identity, both triangular factors and the right-hand-side transformation with any reported solve.
Sources checked October 24, 2026:
SciPy: scipy.linalg.lu: https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.lu.html
LAPACK: DGETRF: https://netlib.org/lapack/explore-html/db/d04/group__getrf_gaea332d65e208d833716b405ea2a1ab69.html
Concept illustration: A small desktop robot beside a laptop showing a generic workflow provides robotics context for this analytical model. The image does not depict the article's numerical example, a verified experiment, a product specification, or deployment evidence.