Elimination, and the swap

When symmetry is not enough

The matrix [[0, 1], [1, 0]] is symmetric, nonsingular and perfectly conditioned, and there is no diagonal entry to pivot on. Every factorisation restricted to symmetric interchanges and one-by-one pivots fails on it, at any depth of searching, because every entry it could search is zero. The repair is to take two variables at once.

Worth reading first: A factorisation with nothing to pivot for · The swap that is not optional.

A factorisation with nothing to pivot for ended on the one condition Cholesky needs: the matrix must be positive definite. This essay is about what happens on a symmetric matrix that is not, and the answer is not a small adjustment.

Consider

[ 0  1 ]
[ 1  0 ]

It is symmetric. Its eigenvalues are +1 and −1, so it is nonsingular and its condition number is exactly 1 — as well conditioned as a matrix can be. And it has no nonzero diagonal entry.

A factorisation PAPᵀ = LDLᵀ with D diagonal has to divide by a diagonal entry of the permuted matrix at its first step. A symmetric permutation moves diagonal entries to other diagonal positions; it cannot move an off-diagonal entry onto the diagonal, because that is what makes it symmetric. So every diagonal entry available to be chosen is zero, and the factorisation does not exist.

Not “is inaccurate”. Does not exist. No amount of searching helps, and no amount of precision helps, and the matrix is perfectly conditioned.

The block diagonal of a Bunch–Kaufman factorisation of an 4×4 saddle-point matrix at τ = 10⁻⁶The matrix D from PAPᵀ = LDLᵀ, drawn as a matrix. 2 of its blocks are 2×2 — the shaded pairs — and the rest are single entries. A 2×2 block is taken exactly where no single diagonal entry is large enough to divide by safely, which on a matrix whose lower-right block is zero by construction is most of it. The badge carries the residual of all three pivot rules.D from PAPᵀ = LDLᵀ — the shaded pairs are 2×2 pivots10⁻⁶0.749··0.749·····1.8·10⁻⁶-0.498··-0.498·three rules, one matrix‖PAPᵀ − LDLᵀ‖, blocks5.1·10⁻¹⁷‖PAPᵀ − LDLᵀ‖, diagonal3.6·10⁻¹⁷growth, blocks1growth, diagonal7.5·10⁵the zero block is what the problem saysand one rule does not need it to be nonzero
Fig. 1 The smallest saddle-point matrix the construction supports: two primal variables, two multipliers, and two 2×2 blocks. The whole factorisation fits in four rows.

Why a symmetric permutation is the constraint

The obvious response is to permute rows only, as LU does, and take the 1 into the pivot position. That works and it is not a symmetric factorisation any more: PA is not symmetric, L and U are unrelated, and the storage and arithmetic halved by symmetry are back.

Which is the whole trade. Symmetry buys half of everything and costs the freedom to permute rows without permuting columns. For a positive definite matrix that costs nothing, because there was never a reason to permute. For an indefinite one it costs the existence of the factorisation.

The saddle point, where the zero is not an accident

The 2×2 above is easy to dismiss as a puzzle. The structure it has is the structure of one of the most common systems in computational science.

[ H   Bᵀ ] [x]   [f]
[ B   0  ] [λ] = [g]

The bottom-right block is zero by construction. It is the block of Lagrange multipliers in a constrained optimisation, the pressure block in an incompressible flow discretisation, the dual block in an interior-point step, and the multiplier block in a constrained least-squares problem. Nobody put a zero there by accident; the zero is what says the constraint has no term of its own.

So a factorisation that needs a nonzero diagonal entry there has no matrix to work on, and the problem class in which this arises is enormous.

The block diagonal of a Bunch–Kaufman factorisation of an 8×8 saddle-point matrix at τ = 10⁻⁶The matrix D from PAPᵀ = LDLᵀ, drawn as a matrix. 4 of its blocks are 2×2 — the shaded pairs — and the rest are single entries. A 2×2 block is taken exactly where no single diagonal entry is large enough to divide by safely, which on a matrix whose lower-right block is zero by construction is most of it. The badge carries the residual of all three pivot rules.D from PAPᵀ = LDLᵀ — the shaded pairs are 2×2 pivots10⁻⁶0.749······0.749·········1.2·10⁻⁶1.4······1.4·········2.1·10⁻⁶0.549······0.549·········3.6·10⁻⁶0.614······0.614·three rules, one matrix‖PAPᵀ − LDLᵀ‖, blocks5.8·10⁻¹⁷‖PAPᵀ − LDLᵀ‖, diagonal3.1·10⁻¹¹growth, blocks1.3growth, diagonal5·10⁵the zero block is what the problem saysand one rule does not need it to be nonzero
Fig. 2 The block diagonal D from a Bunch–Kaufman factorisation of an 8×8 saddle-point matrix, drawn as a matrix. The shaded pairs are 2×2 pivots — four of them, one for every pair of variables. The badge carries the residual of the block rule and of the diagonal rule, which are not the same number. Drag the regularisation on the primal block.
The block diagonal of a Bunch–Kaufman factorisation of an 8×8 saddle-point matrix at τ = 0.01The matrix D from PAPᵀ = LDLᵀ, drawn as a matrix. 4 of its blocks are 2×2 — the shaded pairs — and the rest are single entries. A 2×2 block is taken exactly where no single diagonal entry is large enough to divide by safely, which on a matrix whose lower-right block is zero by construction is most of it. The badge carries the residual of all three pivot rules.D from PAPᵀ = LDLᵀ — the shaded pairs are 2×2 pivots0.010.749······0.749·········0.01171.4······1.4·········0.02130.549······0.549·········0.03590.614······0.614·three rules, one matrix‖PAPᵀ − LDLᵀ‖, blocks5.8·10⁻¹⁷‖PAPᵀ − LDLᵀ‖, diagonal1.6·10⁻¹⁵growth, blocks1.3growth, diagonal50the zero block is what the problem saysand one rule does not need it to be nonzero
Fig. 3 At τ = 10⁻², where both 1×1 rules complete and the diagonal rule’s growth factor is 50. The block rule’s is 1.25, as it is at every τ.

The 2×2 pivot

Bunch and Kaufman’s answer is to allow a pivot block of size two: take

E = [ a_kk  a_kr ]
    [ a_rk  a_rr ]

whole, invert it — it is 2×2, so the inverse is four divisions — and eliminate two variables at once. Symmetry survives, because the block is symmetric and the elimination is A ← A − LELᵀ. The factorisation exists for every symmetric nonsingular matrix, and D is block diagonal with 1×1 and 2×2 blocks rather than diagonal.

On [[0, 1], [1, 0]] the whole matrix is one 2×2 pivot, D is the matrix itself, L is the identity, and the residual is exactly zero — asserted as an equality rather than a tolerance, because there is no arithmetic in the factorisation of a block that is already its own D.

The growth factor of a 12×12 elimination, against the condition number of the matrixThree curves against κ. Cholesky's growth factor is exactly 1 at every condition number drawn — the elimination never produces an entry larger than the matrix already had. Partial pivoting on the same matrices reaches the same growth, and reaches it by making up to 9 row interchanges, each of which destroys the symmetry that was the reason to use a symmetric factorisation. The bound the general theory allows, 2^11 = 2048, is drawn above them both.10¹10³10⁵10⁷10⁹10¹¹110¹10²10³10⁴condition number of the matrixgrowth factorbound 2^11partial pivotingCholeskyno pivot to gain fromCholesky growth, every κ1Cholesky interchanges0partial pivoting, worst9the bound, 2^112048both eliminations reach the same growthand only one of them had to swap to get there
Fig. 4 Cholesky’s growth factor, which is exactly one and needs no rule at all. Bunch–Kaufman’s bound is exponential and its measured growth on every matrix here is between 1.00 and 1.33.

When to take one, which is where the strange constant comes from

The rule has to decide, at each step, between a 1×1 pivot and a 2×2. Taking 2×2 always would waste the definite case; taking 1×1 whenever the diagonal is nonzero would divide by numbers that are nearly zero.

Bunch and Kaufman’s rule compares the largest off-diagonal magnitude in the current column, λ, against the diagonal entry, and takes a 1×1 pivot when |a_kk| ≥ α·λ. Below that it looks one step further — at the largest entry in the row of the offending candidate — and either takes a different 1×1 pivot or takes the 2×2 block.

α = (1 + √17)/8 ≈ 0.6404 is the value minimising the resulting growth bound, and the bound is (1 + 1/α)ⁿ⁻¹. That is exponential and looks alarming beside Cholesky’s exactly-1, and in practice the measured growth is small: the assertions here find 1.00 to 1.33 across every matrix and every τ drawn, against a bound in the thousands.

What the obvious repair does instead

The clean failure at τ = 0 is easy to dismiss as a boundary case. What makes the block rule necessary rather than tidy is what happens near it.

Regularise the primal block by τI — which is what a penalty method, an augmented Lagrangian, or a proximal term does — and the diagonal is no longer zero. Both 1×1 rules now succeed. They succeed by dividing by τ.

The block diagonal of a Bunch–Kaufman factorisation of an 8×8 saddle-point matrix at τ = 0The matrix D from PAPᵀ = LDLᵀ, drawn as a matrix. 4 of its blocks are 2×2 — the shaded pairs — and the rest are single entries. A 2×2 block is taken exactly where no single diagonal entry is large enough to divide by safely, which on a matrix whose lower-right block is zero by construction is most of it. The badge carries the residual of all three pivot rules.D from PAPᵀ = LDLᵀ — the shaded pairs are 2×2 pivots·0.749······0.749··········1.4······1.4··········0.549······0.549··········0.614······0.614·three rules, one matrix‖PAPᵀ − LDLᵀ‖, blocks5.8·10⁻¹⁷‖PAPᵀ − LDLᵀ‖, diagonalgrowth, blocks1.3growth, diagonalthe zero block is what the problem saysand one rule does not need it to be nonzero
Fig. 5 The same matrix at τ = 0, where the diagonal is entirely zero. Both 1×1 rules fail outright and the block rule returns a residual of 5.8·10⁻¹⁷. This is the clean failure; the interesting one is at small nonzero τ, where the 1×1 rules do not fail.

The measurement: at τ = 10⁻², 10⁻⁴, 10⁻⁶ and 10⁻⁸ the diagonal rule’s growth factor is 50, 5.0·10³, 5.0·10⁵ and 5.0·10⁷ — exactly c/τ — and its residual follows, reaching 2.2·10⁻⁹ at the smallest τ. Bunch–Kaufman’s growth is 1.25 at all four and its residual is 5.8·10⁻¹⁷ at all four.

Seven orders of magnitude of accuracy, on a matrix where the 1×1 rule did not fail and reported nothing. That is the case that ships.

The block diagonal of a Bunch–Kaufman factorisation of an 8×8 saddle-point matrix at τ = 10⁻⁸The matrix D from PAPᵀ = LDLᵀ, drawn as a matrix. 4 of its blocks are 2×2 — the shaded pairs — and the rest are single entries. A 2×2 block is taken exactly where no single diagonal entry is large enough to divide by safely, which on a matrix whose lower-right block is zero by construction is most of it. The badge carries the residual of all three pivot rules.D from PAPᵀ = LDLᵀ — the shaded pairs are 2×2 pivots10⁻⁸0.749······0.749·········1.2·10⁻⁸1.4······1.4·········2.1·10⁻⁸0.549······0.549·········3.6·10⁻⁸0.614······0.614·three rules, one matrix‖PAPᵀ − LDLᵀ‖, blocks5.8·10⁻¹⁷‖PAPᵀ − LDLᵀ‖, diagonal2.2·10⁻⁹growth, blocks1.3growth, diagonal5·10⁷the zero block is what the problem saysand one rule does not need it to be nonzero
Fig. 6 At τ = 10⁻⁸ the diagonal rule succeeds with a growth factor of 5·10⁷ and a residual of 2.2·10⁻⁹. It did not fail, and nothing it can compute says anything is wrong.

Where the blocks are taken, and where they are not

The other half of the claim is that the generality costs nothing when it is not wanted, and it is the half this site has been wrong about before, so it is measured.

On a positive definite matrix, Bunch–Kaufman takes zero 2×2 pivots and makes zero interchanges. The rule reduces to no pivoting at all, Cholesky’s argument survives intact, and the residual is at rounding. On the saddle-point matrix at τ = 0 it takes n/2 blocks — one for every pair — and at τ = 1, where the diagonal is as large as the coupling, it takes almost none.

The block diagonal of a Bunch–Kaufman factorisation of an 8×8 saddle-point matrix at τ = 1The matrix D from PAPᵀ = LDLᵀ, drawn as a matrix. 0 of its blocks are 2×2 — the shaded pairs — and the rest are single entries. A 2×2 block is taken exactly where no single diagonal entry is large enough to divide by safely, which on a matrix whose lower-right block is zero by construction is most of it. The badge carries the residual of all three pivot rules.D from PAPᵀ = LDLᵀ — the shaded pairs are 2×2 pivots1········1········1········1········-1.47········-0.532········-1.53········-0.105three rules, one matrix‖PAPᵀ − LDLᵀ‖, blocks1.3·10⁻¹⁷‖PAPᵀ − LDLᵀ‖, diagonal10⁻¹⁶growth, blocks2.5growth, diagonal2.2the zero block is what the problem saysand one rule does not need it to be nonzero
Fig. 7 The same figure with the primal block fully regularised. The diagonal is now as large as the coupling, the block rule takes no blocks at all, and the two rules’ growth factors are 2.47 and 2.20 — the same order, where four stops to the left they were 1.25 and 5·10⁷. A rule that costs nothing where it is not needed is worth the assertion, and this site has had that claim come out both ways.

The other rules, and why there are several

Bunch–Kaufman is what LAPACK’s xSYTRF runs by default, and it is not the only rule, for a reason worth stating.

Bunch–Parlett searches the whole remaining submatrix, like complete pivoting, and has a polynomial growth bound rather than an exponential one. It costs O(n³) comparisons, which is the same objection complete pivoting faces in the unsymmetric case.

Bounded Bunch–Kaufman, or rook pivoting, alternates between a column search and a row search until an entry is largest in both. It bounds the entries of L, which Bunch–Kaufman does not: the classical rule can produce an L with arbitrarily large entries even while the growth in D is modest, and a large L is a problem for anything that later uses the factors — a condition estimate, an iterative refinement, or a null-space basis.

Aasen’s method reduces to tridiagonal LTLᵀ instead of block diagonal, which bounds L by construction and moves the difficulty into a tridiagonal solve.

That there are four rules rather than one is the signature of a problem where no single choice dominates, and it is the same signature the unsymmetric case has: partial, scaled partial, rook and complete, each buying a different thing.

The alternatives that avoid the problem, and what they cost

A saddle-point system can be solved without a symmetric indefinite factorisation at all, and the two standard ways are worth naming because both trade the difficulty for a different one.

The Schur complement, or range-space method. Eliminate x first: from the top block x = H⁻¹(f − Bᵀλ), substitute, and solve (B H⁻¹ Bᵀ) λ = B H⁻¹ f − g. The Schur complement S = B H⁻¹ Bᵀ is symmetric positive definite when H is, so Cholesky applies and the whole of the previous essay comes back.

What it costs: H⁻¹ appears explicitly, so H must be cheaply invertible — diagonal, or block diagonal, or a mass matrix — and if it is not, forming S is more expensive than the original system. And S is dense even when B is sparse, because B H⁻¹ Bᵀ couples every pair of constraints that share a variable. The conditioning is worse too: κ(S) is roughly κ(H)·κ(B)², so a route chosen to get back to Cholesky can square a condition number to do it — which is the road that squares the problem reappearing in a different field.

The null-space method. Find Z with BZ = 0, solve the reduced problem (ZᵀHZ) y = Zᵀ(f − H x₀) in the null space of the constraints, which is again SPD when H is definite on that subspace.

What it costs: a null-space basis. Computing one that is well conditioned needs a QR of Bᵀ; computing one cheaply — by partitioning B into a square block and the rest — gives a Z whose conditioning is the conditioning of that block, which nothing chose on numerical grounds. And if H is only definite on the null space, which is the usual assumption in optimisation, the reduced problem is fine and the full one is indefinite — so the method needs a Z before it can say anything at all.

Against both of those, a symmetric indefinite factorisation of the whole system needs no assumption on H beyond nonsingularity of the pair, no explicit inverse, and no basis. That is why it is the default in a general-purpose code, and why the pivot rule inside it had to be invented.

The block diagonal of a Bunch–Kaufman factorisation of an 10×10 saddle-point matrix at τ = 10⁻⁶The matrix D from PAPᵀ = LDLᵀ, drawn as a matrix. 5 of its blocks are 2×2 — the shaded pairs — and the rest are single entries. A 2×2 block is taken exactly where no single diagonal entry is large enough to divide by safely, which on a matrix whose lower-right block is zero by construction is most of it. The badge carries the residual of all three pivot rules.D from PAPᵀ = LDLᵀ — the shaded pairs are 2×2 pivots10⁻⁶-0.8········-0.8···········2·10⁻⁶0.9········0.9···········2·10⁻⁵1········1············-0.7········-0.73·10⁻⁶··········2·10⁻⁶0.7········0.7·three rules, one matrix‖PAPᵀ − LDLᵀ‖, blocks1.2·10⁻¹⁶‖PAPᵀ − LDLᵀ‖, diagonal1.9·10⁻¹¹growth, blocks1growth, diagonal2.9·10⁵the zero block is what the problem saysand one rule does not need it to be nonzero
Fig. 8 A ten-variable saddle point, with five 2×2 blocks — one for every pair. The count is n/2 at every τ below a hundredth, and drops to one when the diagonal is as large as the coupling.

The conditioning, which the factorisation does not fix

A saddle-point matrix’s condition number does not behave like H’s or B’s, and the block structure is what makes it legible.

The eigenvalues separate into two groups: those of order ‖H‖, which come from the primal block, and those of order σ_min(B)²/‖H‖, which come from the constraint block being coupled through H⁻¹. So

κ  ≈  ‖H‖ · max(1, ‖H‖/σ_min(B)²)

and a nearly redundant constraint — two rows of B nearly parallel — takes σ_min(B) towards zero and κ up quadratically. That is a property of the problem and not of the factorisation, and no pivot rule in this essay improves it.

What the factorisation controls is the growth, which is the part the algorithm is responsible for, and the separation is exactly the site’s own identity: forward error ⪅ κ × backward error, with κ belonging to the constraints and the backward error belonging to the pivot rule. The measurement above — 1.25 against 5·10⁷ — is entirely about the second factor.

Backward error, forward error and the condition number, with measured valuesTwo boxes at the top — the problem posed and the nearby problem the algorithm answered exactly — and two answers below them, with the distances between all four labelled by numbers from a Hilbert solve.the problem you posedA = H10b = A·(1, 2, …, 10)the problem it answered exactlyA + δA, b + δb‖δ‖ / ‖A‖ = 2.3·10⁻¹⁷the answer you wantedx = (1, 2, …, 10), exactlythe answer you gotx̂, wrong by 2.7·10⁻⁴ relativebackward error 2.3·10⁻¹⁷forward error 2.7·10⁻⁴κ = 1.6·10¹³κ · η = 3.6·10⁻⁴, and the measured forward error is 2.7·10⁻⁴.The algorithm is not at fault. The problem is.H10, LU with partial pivotingresidual and error differ
Fig. 9 The identity the two halves live in. The growth factor of a pivot rule is the backward-error side; the near-redundant constraint is the condition-number side; and the answer’s error is the product.
Growth factor under partial pivoting to n = 12: the bound, the worst case, and realityGrowth factor against matrix size on a logarithmic vertical axis. The two-to-the-n bound rises as a straight line; Wilkinson's matrix sits exactly on it; random matrices stay near one.02468101214110¹10²10³10⁴10⁵10⁶matrix size ngrowth factor max|u| / max|a|the 2ⁿ⁻¹ boundworst of 30 randommedian randomWilkinson's matrix sits on the bound30 Gaussian matrices per sizeat n = 12: bound 2048, worst 3.6
Fig. 10 The unsymmetric alternative’s growth against the size. Using it costs twice the arithmetic, twice the storage, the elimination tree, and the inertia — and buys a bound that is no better.

Why not just use LU

Because half of everything is a lot, and because the alternative loses something structural as well as something quantitative.

An unsymmetric LU of a symmetric matrix computes both triangles, stores both, and performs twice the arithmetic. On a sparse saddle-point system it also computes a different elimination tree, because the row permutation and the column permutation are no longer tied, and the fill it produces has no reason to respect the symmetry of the sparsity pattern.

And it discards the inertia — the counts of positive, negative and zero eigenvalues — which LDLᵀ hands over for free. Sylvester’s law of inertia says the signs in D are the signs of the eigenvalues, so a symmetric indefinite factorisation answers “how many negative eigenvalues does this Hessian have” as a by-product, at no cost, and that question is the one an optimisation code is actually asking. A 2×2 block contributes one positive and one negative, since its determinant is negative — which is why the rule takes them.

How often Cholesky still calls a 12×12 matrix positive definite, against λ_min/λ_max in units of the format's own roundoffThree curves, one per precision, of the share of 24 seeded matrices on which the factorisation succeeds. Measured in units of each format's unit roundoff the three lie almost on top of one another, with the edge — the smallest ratio at which every seed succeeds — at 1.0, 1.0, 1.8 times u. The absolute thresholds are 6·10⁻⁸, 2.3·10⁻¹⁰ and 2·10⁻¹⁶: nine orders of magnitude apart, and the same number in the format's own units.10⁻³10⁻²10⁻¹110¹10²10³10⁴00.250.50.751λ_min / λ_max, in units of the format's own ushare of seeds that succeed24 bits32 bits53 bitsone threshold, three formats24-bit edge, absolute6·10⁻⁸32-bit edge, absolute2.3·10⁻¹⁰53-bit edge, absolute2·10⁻¹⁶in units of u, at 53 bits1.8a yes-or-no question with a precision in itand a coin flip three decades below the edge
Fig. 11 The test the previous essay ends on, which is the test this one begins by failing. A symmetric indefinite matrix is not near the edge of definiteness — it is on the other side of it, and no amount of precision moves it back.

What the residual is measured against

A detail about the badge, because a permuted factorisation makes the obvious choice wrong.

The quantity printed is ‖PAPᵀ − LDLᵀ‖_F / ‖A‖_F, with the permutation applied to A rather than undone from the factors. Both are defensible and they differ in what they blame: the first asks whether the factorisation of the permuted matrix is accurate, the second whether the factors reconstruct the original.

They are the same number here, because a permutation is orthogonal and the Frobenius norm is orthogonally invariant. That is worth checking rather than assuming — it fails for a norm that is not unitarily invariant, and the ∞-norm this site uses elsewhere is one of those.

Two rules that are the same rule

ldl’s three pivot options are written through one body, and the reason is the site’s standing practice rather than economy: what is being compared has to be the rule and not two implementations of an elimination.

The none and diagonal branches differ by a single symmetric interchange chosen before the step; everything after that — the divisions, the rank-one update, the ordering of the arithmetic — is character-for-character the same code. So when the diagonal rule’s growth is 5·10⁷ and the block rule’s is 1.25, the difference is the pivot and cannot be anything else.

That is the same discipline pivotStrategies applies to the unsymmetric case in the pivot that reads the units, and it is why both essays can attribute a factor of 10⁷ to a rule rather than to a routine.

What is worth carrying

A symmetric factorisation with 1×1 pivots does not always exist, and the matrix that shows it is 2×2, perfectly conditioned and has a zero diagonal by construction rather than by accident.

The failure at zero is the easy case. The one that ships is small-but-nonzero, where the 1×1 rule succeeds, divides by τ, and returns a factorisation whose growth is 1/τ with nothing reporting it.

A 2×2 pivot costs nothing where it is not wanted. Zero blocks and zero interchanges on a positive definite matrix, measured, so the general routine is not a tax on the common case.

And the block structure is information. The inertia falls out of the signs in D, which is the question a constrained optimisation is asking anyway, and no unsymmetric factorisation offers it.

What links here

Computed from the collection, not written here: the essays that point at this one.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A flat tag is an object no other essay names yet.

Bunch–KaufmanCholeskyComplete pivotingConstrained minimisationGrowth factorLDLᵀ factorisationPartial pivotingSaddle-point systemsSymmetric indefinite