Elimination, and the swap

A factorisation with nothing to pivot for

Cholesky's growth factor is not bounded by one. It is equal to one, at every size and every condition number, and the two-line reason is why the algorithm needs no pivoting at all — not "usually gets away without it". Its only failure is the square root of a non-positive number, which is exactly the test for definiteness, and in floating point that test moves with the precision.

Worth reading first: Elimination is a sequence of choices · The bound that is never attained.

Everything this site has said about elimination so far has had a pivot in it. The interchange is what makes it stable, the growth factor is what says how much it could still cost, and Wilkinson’s matrix is what shows the bound being attained under the rule that was supposed to prevent it.

For a symmetric positive definite matrix all of that goes away, and it goes away for a reason that takes two lines.

The two lines

One. In a positive definite matrix the largest entry in absolute value is on the diagonal. If some |a_ij| > max_k a_kk with i ≠ j, take the vector with ±1 in positions i and j and zeros elsewhere; the quadratic form it produces is a_ii + a_jj ∓ 2|a_ij| < 0, contradicting definiteness.

Two. Every Schur complement of a positive definite matrix is positive definite, and its diagonal entries are no larger than the ones it came from: eliminating with pivot a_kk replaces a_ii by a_ii − a_ik²/a_kk, and the subtracted quantity is non-negative.

Put them together. Every entry anywhere in the elimination is bounded by the largest diagonal entry of the current Schur complement, which is bounded by the largest diagonal entry of A, which is the largest entry of A.

So the growth factor is at most 1. And it is at least 1, because the first step has not changed anything yet. It is exactly 1.

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. 1 The growth factor of a 12×12 elimination against the condition number of the matrix, over eleven decades. Cholesky’s is 1 at every point — an equality, not a bound. Partial pivoting on the same matrices reaches the same growth, and reaches it by making up to nine row interchanges. The 2ⁿ⁻¹ the general theory allows is drawn above them both. Drag the size.
The growth factor of a 24×24 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 19 row interchanges, each of which destroys the symmetry that was the reason to use a symmetric factorisation. The bound the general theory allows, 2^23 = 8.4·10⁶, is drawn above them both.10¹10³10⁵10⁷10⁹10¹¹110¹10²10³10⁴10⁵10⁶10⁷10⁸condition number of the matrixgrowth factorbound 2^23partial pivotingCholeskyno pivot to gain fromCholesky growth, every κ1Cholesky interchanges0partial pivoting, worst19the bound, 2^238.4·10⁶both eliminations reach the same growthand only one of them had to swap to get there
Fig. 2 The same measurement at n = 24, where partial pivoting makes nineteen interchanges to reach the growth factor Cholesky gets for nothing, and the bound the general theory allows is 8.4·10⁶.

What the second curve is for

Partial pivoting on these matrices also has a growth factor of 1. That is not a coincidence and it is not a reason to shrug: it is the same theorem, since partial pivoting on an SPD matrix is doing the same eliminations in a different order.

What separates the two is underneath the curves and is in the badge: the interchanges. Cholesky makes zero. Partial pivoting makes up to nineteen at n = 24, and every one of them destroys the symmetry that was the reason for using a symmetric factorisation in the first place.

That is the honest cost of the general routine on this class of matrix. Half the storage, half the arithmetic, and no permutation to record — all three lost to a search that finds nothing, at a growth factor identical to the one the symmetric routine gets for free.

The site’s own same arithmetic at a different price is the same shape of argument reached through memory traffic rather than through pivots.

Wilkinson's 12×12 matrix and its upper triangular factorThe matrix on the left has ones on the diagonal, minus ones below it and a column of ones at the right. On the right, its U factor, whose last column doubles down the rows to sixty-four.1··········1-11·········1-1-11········1-1-1-11·······1-1-1-1-11······1-1-1-1-1-11·····1-1-1-1-1-1-11····1-1-1-1-1-1-1-11···1-1-1-1-1-1-1-1-11··1-1-1-1-1-1-1-1-1-11·1-1-1-1-1-1-1-1-1-1-111-1-1-1-1-1-1-1-1-1-1-11A1··········1·1·········2··1········4···1·······8····1······16·····1·····32······1····64·······1···128········1··256·········1·512··········11024···········2048U‖PA − LU‖/‖A‖0growth factor2048the 2ⁿ⁻¹ bound2048Row interchanges performed: 0.Partial pivoting had nothing to choose.every entry is 0, 1 or −1the bound is attained here
Fig. 3 The matrix that attains partial pivoting’s bound exactly. There is no positive definite matrix anywhere on this curve, and the two-line argument at the top of this essay is why.

No pivot to gain from, not “no pivot needed”

The distinction is worth pressing on, because the two sentences suggest different things about risk.

Cholesky does not need pivoting reads as a claim about typical behaviour, of the kind that has an unstated exception somewhere. What is true is stronger and has no exception: there is no interchange that would improve anything, because the quantity pivoting exists to control is already at its minimum possible value. A pivot search on an SPD matrix is a search whose best possible outcome is the answer it already has.

The one thing a symmetric permutation does buy on an SPD matrix is sparsity, which is a different objective entirely and is the order decides the memory. A sparse Cholesky permutes heavily, chooses the permutation from the graph before looking at a single value, and gets the same growth factor of 1 whatever it chooses. That the two objectives do not interfere is exactly why sparse SPD solvers are the easiest kind to write, and it is the property that structure and stability stop being separable shows disappearing the moment the matrix stops being definite.

The growth factor of a 5×5 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 2 row interchanges, each of which destroys the symmetry that was the reason to use a symmetric factorisation. The bound the general theory allows, 2^4 = 16, is drawn above them both.10¹10³10⁵10⁷10⁹10¹¹110¹10²condition number of the matrixgrowth factorbound 2^4partial pivotingCholeskyno pivot to gain fromCholesky growth, every κ1Cholesky interchanges0partial pivoting, worst2the bound, 2^416both eliminations reach the same growthand only one of them had to swap to get there
Fig. 4 The smallest size drawn. Cholesky’s growth is 1 here as well — the argument for it does not mention n — while the bound the general theory allows is 16.

The failure, which is the test

Cholesky fails in exactly one way. At step k it asks for the square root of the current a_kk, and if that is not positive there is no real square root and the algorithm stops.

And it fails if and only if the matrix is not positive definite. That is not a coincidence either: the pivots of a Cholesky factorisation are the diagonal of D in LDLᵀ, their product over the first k is the k-th leading principal minor, and Sylvester’s criterion says a symmetric matrix is positive definite exactly when all of those are positive.

So the factorisation is the standard test. It costs n³/3 operations against 4n³/3 for an eigenvalue decomposition, it answers the same yes-or-no question, and it is what every library does when asked isposdef.

In floating point the “if and only if” moves

assertTheDefinitenessTestMovesWithThePrecision builds QΛQᵀ with Λ = (1, …, 1, δ), so δ is λ_min/λ_max and the true answer is an input rather than a measurement. Then it asks, at each of three precisions, how small δ can be before the test starts saying no.

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. 5 The share of sixteen seeded matrices on which Cholesky still succeeds, against λ_min/λ_max measured in units of each format’s own unit roundoff. Three precisions, nine orders of magnitude apart in absolute terms, lying almost on top of each other on this axis. Drag the size.

The edge — the smallest ratio at which every seed succeeds — is at 1.0·u, 1.0·u and 1.8·u at 24, 32 and 53 bits. The absolute thresholds are 6.0·10⁻⁸, 2.3·10⁻¹⁰ and 2.0·10⁻¹⁶: nine orders of magnitude apart, and the same number in each format’s own units.

That is the site’s precision knob applied to a question whose output is a yes or a no rather than a number of digits, and it is the same shape as the mixed-precision threshold at κu ≈ 1 which buying the accuracy back measured.

Why a share and not a verdict

The figure plots a share of seeds rather than a single edge per precision, and the reason is a finding rather than a presentational choice.

Far below the edge the outcome is not a function of δ at all. The matrix is assembled and stored before the factorisation begins, and assembling it rounds — so the smallest eigenvalue the routine is actually handed is δ plus a rounding error of size about u, whose sign depends on the seed. Three decades below u the share settles at about a half and stays there: a coin flip, at every δ.

A bisection on one seed would have returned a number to fourteen digits, and that number would have been a property of that seed’s rounding. The site has recorded this before — near a threshold the outcome is genuinely erratic, from the mixed-precision phase, and a refusal that waits for a rare event is not a refusal from the expansion. The honest measurement is the share, which is smooth.

How often Cholesky still calls a 4×4 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.8, 1.0 times u. The absolute thresholds are 6·10⁻⁸, 4.1·10⁻¹⁰ and 1.1·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, absolute4.1·10⁻¹⁰53-bit edge, absolute1.1·10⁻¹⁶in units of u, at 53 bits1a yes-or-no question with a precision in itand a coin flip three decades below the edge
Fig. 6 The definiteness test at n = 4. The edge moves with the size because a factorisation’s error grows with the number of operations, and it moves by a factor of a few against the 2²⁹ between binary32 and binary64.

The jitter, and what it actually costs

There is a piece of folklore attached to this threshold that is worth measuring rather than repeating.

Kernel and covariance matrices are positive semi-definite by construction and positive definite only if the data says so. In practice they arrive with a smallest eigenvalue near zero — duplicated observations, a kernel width larger than the spread of the points, a covariance estimated from fewer samples than dimensions — and chol throws. The standard response is to add jitter·I and try again, doubling the jitter until it works.

What the figure above says is that the loop terminates when the jitter reaches about u·λ_max, and what it does not say is what has been bought. Adding εI to a matrix whose smallest eigenvalue is zero does not recover the missing direction; it replaces it with a direction of size ε, which is a statement about arithmetic and not about the data. The factorisation then succeeds, the residual ‖A + εI − LLᵀ‖ is at rounding, and every quantity a solver can see says the computation went perfectly.

The honest summary is that jitter converts a factorisation that fails into a factorisation of a different matrix, and the difference is exactly the thing the failure was reporting. That is the same move as a modified Cholesky, performed by the caller rather than by the library, usually without the record of how far the matrix was moved.

How often Cholesky still calls a 20×20 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.0 times u. The absolute thresholds are 6·10⁻⁸, 2.3·10⁻¹⁰ and 1.1·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, absolute1.1·10⁻¹⁶in units of u, at 53 bits1a yes-or-no question with a precision in itand a coin flip three decades below the edge
Fig. 7 And at n = 20. Three precisions, nine orders of magnitude apart in absolute terms, and the same small multiple of u in each format’s own units.

What Cholesky’s backward error actually promises

Growth factor 1 is a statement about the intermediate quantities. The statement about the answer is Wilkinson’s, and it has a condition in it that is worth reading.

The computed factors satisfy L̂L̂ᵀ = A + ΔA with ‖ΔA‖ ≤ c(n)·u·‖A‖ — backward stable, with a modest polynomial in n and no growth factor anywhere, which is the payoff of the two lines at the top of this essay. And the theorem’s hypothesis is that the algorithm runs to completion: if c(n)·u·κ₂(A) < 1 it does, and past that it may not.

So the failure mode and the stability statement are the same boundary seen from two sides. Below it, Cholesky is as stable as an elimination gets; above it, it does not return an answer at all. There is no region in which it returns a bad one.

That is unusual and it is worth naming, because almost nothing else on this site behaves that way. The road that squares the problem degrades smoothly and silently; the swap that is not optional returns an answer of the right shape that is wrong; the normal equations lose digits without comment.

What the solver reported, and what it achievedFinal relative residual and final relative error against the working precision, on a logarithmic vertical axis. The residual sits at the stopping tolerance at every precision — the method converged, by every test available to it. The error runs from 5.26·10⁻¹⁴ at 53 bits to 0.00804 at 8, tracking the unit roundoff, which is drawn beside it.614223038465410⁻¹³10⁻¹⁰10⁻⁷10⁻⁴working significand bitsrelative sizeerrorresidualuthe gap the solver cannot seeerror ÷ residual at 24 bits4.1·10⁵error ÷ residual at 16 bits3.6·10⁷error ÷ residual at 8 bits1.9·10¹⁰every convergence test passesand the answer is wrong in proportion to u
Fig. 8 The usual case on this site: a computation whose output looks fine and is not. Cholesky is the exception — it refuses rather than degrading, and the refusal is the same event as the theorem’s hypothesis failing.
Forward error of a 8×8 Hilbert solve at eight precisionsA bar for each significand width from 12 to 53 bits showing the relative error in the computed solution, with the condition number times the unit roundoff marked as a prediction.κ = 1.5·10¹⁰ · the exact answer is (1, 2, …, 8)12 bits4.116 bits1.620 bits1024 bits0.530 bits0.5636 bits0.005943 bits5.5·10⁻⁶53 bits3.2·10⁻⁸dashed: κ · unit roundoffone matrix, eight arithmeticsmeasured against a known answer
Fig. 9 The site’s precision knob, on a solve. The definiteness test is the same knob applied to a question whose answer is a yes or a no.

The square root, and the variant without it

LDLᵀ with D diagonal and L unit lower triangular is the same factorisation with the square roots pulled out: L_chol = L·D^{1/2}. Everything above applies to it unchanged — same growth, same pivots, same failure condition, with the failure now a non-positive d_kk rather than a square root of one.

Two reasons it gets used. Square roots are slow, historically much more so than they are now, and there are n of them. And it extends: LDLᵀ makes sense for an indefinite symmetric matrix, where D is allowed negative entries, and Cholesky does not. That extension is the whole of the next essay, and the D that comes out of it is not diagonal.

There is a third reason, and it is the one that survives modern hardware. In a Kalman filter or a square-root information filter the quantity being propagated is a factorisation rather than a matrix, and a step that requires the covariance to be re-formed and re-factorised loses the guarantee that it stays definite at all. LDLᵀ can be updated in place, and its definiteness is then a property of the signs in D rather than of an arithmetic that might have drifted.

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. 10 What the next essay does instead of perturbing: a factorisation that does not need the diagonal to be nonzero. Here the diagonal is as large as the coupling and the block rule takes almost no blocks, which is the case where the two agree.

What a library does when the test says no

Two things, and they answer different questions.

A modified Cholesky perturbs the matrix until it is definite and factorises that — replacing a non-positive pivot by something small and positive, or adding a multiple of the identity — and returns the factors of a different matrix, along with how far away it is. That is what an optimisation code does inside a Newton step, where the Hessian may be indefinite and a descent direction is wanted rather than the exact Newton one.

A symmetric indefinite factorisation does not perturb anything and does not need definiteness at all, at the cost of a pivot rule that can take two variables at once. That is when symmetry is not enough, and it is the essay after this one.

The distinction matters more than it looks. The first changes the problem and says so; the second solves the problem given. A code that silently did the first would be returning an answer to a question its caller did not ask, and the reason chol throws rather than repairing is that there is no repair that is right for every caller.

Two condition numbers of one 8×8 system, as its rows are put into different unitsFour curves against the spread of the row units, in decades. κ_∞ of the scaled matrix rises from 9.83 to 1.9·10⁶ while the componentwise condition number stays at 6.98 throughout — the same system, the same solution, and one of the two numbers is a fact about the units. Hilbert's two numbers are drawn flat beside them at 3.4·10¹⁰ and 1.2·10¹⁰: a matrix whose sensitivity no scaling repairs.0123456110²10⁴10⁶10⁸10¹⁰10¹²spread of the row units (decades)condition numberκ_∞(DA)cond(DA)Hilbert κ_∞Hilbert condone system, two numbersκ_∞ at no spread9.8κ_∞ at 6 decades1.9·10⁶cond, either end7Hilbert, equilibrated1.3·10¹⁰the solution is the same at every spreadand one of these curves knows it
Fig. 11 One thing a positive definite matrix does not escape. Definiteness is invariant under a symmetric scaling and the condition number is not, so a badly scaled SPD matrix still reports a κ that is mostly about its units.

What “positive definite” is, computationally

A last observation about the word, because it is used in two ways that come apart exactly at the threshold this essay measures.

Mathematically, positive definite means xᵀAx > 0 for every nonzero x, which is a statement about infinitely many vectors and is equivalent to every eigenvalue being positive.

Computationally, it means the matrix a routine was handed factorises. Those agree above the edge and not below it, and below it the second is not even a property of the matrix — it is a property of the matrix, the format, and the seed that generated it.

The consequence for a caller is small and specific: isposdef is not a predicate. It is a test whose answer is a fact about the arithmetic as much as about the argument, and two libraries can disagree about the same matrix without either being wrong.

That is unusual and it is worth being clear that it is the matrix rather than the test that is at fault. A matrix whose smallest eigenvalue is 10⁻¹⁸ of its largest is, for every computational purpose, indistinguishable from one whose smallest is −10⁻¹⁸, and no test that reads the stored entries can distinguish them because the stored entries are the same.

What is worth carrying

Growth factor exactly one, at every size and every conditioning. Not bounded — equal, with a two-line proof and nine measurements. That is the strongest stability statement anywhere on this site, and it belongs to the algorithm with no pivot rule in it.

The generality of partial pivoting is not free on this class, and what it costs is not accuracy. It is the symmetry, and with it half the work, half the storage, and the permutation nobody has to record.

The failure is the test, and it is the cheapest definiteness test there is.

And in floating point the test’s boundary is a small multiple of the unit roundoff, at every precision — so “is this matrix positive definite” is a question whose answer depends on the format it is asked in, and three decades below the boundary the answer is a coin flip.

What links here

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

Reads more easily once this is understood

Essays that name this one as worth reading first.

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.

CholeskyFactorisationGaussian eliminationGrowth factorLDLᵀ factorisationPartial pivotingPositive definiteSymmetric indefiniteUnit roundoff