Orthogonality, measured

The tree the resistances choose

On a network every basic set is a spanning tree and every null-space basis is a set of loops with entries 0 and ±1, so no tree can make Z badly conditioned. The tree with the best-conditioned Z still gives loop equations 4.8 times worse than the tree of least resistance: the basis has to be chosen against the Hessian, and pivoting finds it only when it pivots on the resistances too.

Worth reading first: The basis nobody chose on purpose · The spectrum is not the graph · A matrix with no numbers in it.

The basis nobody chose on purpose found that a null-space method’s basis can be arbitrarily badly conditioned while the constraint it describes is fine, and it found the repair: choose the basic columns by a column-pivoted QR of the constraint matrix instead of taking the first ones listed. The pivoted basis had the orthonormal basis’s conditioning to within a factor of 1.25 and the naive basis’s sparsity exactly.

That repair reads the constraint and nothing else, and on the problem it was measured on nothing else mattered — the Hessian had a condition number of 100 and the naive basis had one of 10⁸. This essay takes a constraint on which the naive failure cannot happen at all, and a Hessian whose entries span four decades, and asks which basis is best when the basis is no longer the thing that can go wrong.

The constraint is conservation of flow on a network, and the answer is a spanning tree. It is not the tree that makes Z best conditioned, and it is not the tree a column-pivoted QR of the constraint picks.

Every tree is a basis, and every entry is a whole number

The network is a square grid of 64 nodes joined by 112 arcs, each arc with a resistance. The constraint says that flow is conserved at every node: A is the incidence matrix, one column per arc, with +1 where the arc leaves a node and −1 where it enters, and one node — a corner — grounded, which removes its row and leaves 63 independent constraints on 112 unknowns. The null space has dimension 49, and a flow in it is a pattern of circulation that enters every node exactly as fast as it leaves.

A set of basic columns is a set of arcs, and those columns are independent exactly when the arcs contain no loop. A basic set of full size is therefore a spanning tree: 63 arcs reaching every node with no loop among them. The fundamental basis the tree gives has one column for each of the 49 arcs left off it, and each column is a loop — +1 on the off-tree arc, and ±1 along the unique path through the tree that closes it. Every entry of Z is 0, 1 or −1, and AZ = 0 holds in integers, for every tree.

That is the structural difference from a general constraint. There the fundamental basis carried the block −AB⁻¹AN, and a nearly singular basic block made its entries as large as twice the block’s condition number. On a network the basic block is a tree’s incidence matrix, its inverse holds only 0 and ±1, and no choice of tree can put a large entry into Z. The failure the pivoted rule was invented to prevent is absent.

An 8 × 8 grid of resistances, its centre breadth-first spanning tree, and the loop that tree serves worstThe 64 nodes and 112 arcs of a grid network with resistances drawn over 4 decades, one corner node grounded. Each of the 49 arcs off the centre breadth-first tree closes one loop through it, and those loops are a basis for the null space of the incidence matrix with every entry 0 or ±1. The loop marked is the one whose tree path carries the largest resistance against its own arc's, 5010 times it. Across the basis κ(Z) = 5.82 and κ(ZᵀHZ) = 683, or 548 once scaled to a unit diagonal, with 310 nonzeros and loops up to 10 arcs long.groundarcs of the treearcs off the treethe loop worst servedcentre breadth-firstκ(Z)5.8κ(ZᵀHZ)683κ, unit diagonal548nonzeros in Z310longest loop, arcs10worst path ÷ own arc5010every tree gives a basis of whole numbersthe resistances decide which one to want
Fig. 1 The same network with a breadth-first tree grown from its centre. Its loops are short — the longest has 10 arcs — and κ(Z) is 5.82, the best of six trees. The loop marked runs through a tree path whose heaviest resistance is 5,010 times its own arc’s, and the loop equations sit at κ(ZᵀHZ) = 683.

The tree that conditions Z best

Different trees still give different bases, and the difference in Z is a matter of how long the loops are. A column of Z is a loop, so its squared length is the number of arcs on the loop, and two columns overlap wherever their loops share tree arcs. Short loops that share little make columns that are short and nearly orthogonal; long loops through a common trunk make columns that are long and nearly parallel.

A breadth-first tree grown from the centre of the grid makes the loops as short as a tree on this grid allows: 310 nonzeros in Z, a mean loop of 6.3 arcs, the longest 10, and κ(Z) = 5.82. The same search grown from a corner makes every loop reach back towards that corner, and gives 490 nonzeros, loops up to 16 arcs and κ(Z) = 9.56. The tree a column-pivoted QR of the incidence matrix selects has loops up to 32 arcs and κ(Z) = 13.7. Among the six trees measured on this grid the centre breadth-first tree has the best-conditioned Z at every draw of resistances, since Z does not see them. The others follow their loop lengths only loosely: the longest loop decides a column’s length, and how many loops share a trunk decides how parallel the columns are, and the two need not agree.

Were the resistances all equal, that would be the end of it. With H a multiple of the identity, ZᵀHZ is a multiple of ZᵀZ and its condition number is exactly κ(Z)² — the square the normal equations take of any factor they are built from — and the tree with the shortest loops is the tree with the best reduced problem. Measured on the same grid with every resistance equal to one, the centre breadth-first tree gives κ(ZᵀHZ) = 33.9, the best of the six, and the column-pivoted QR of the incidence matrix gives 187.

Six spanning trees of one 8 × 8 network: the conditioning of each loop basis and of its loop equationsOn one 8 × 8 grid with resistances all equal, six spanning trees each give a basis of loops for the same null space: breadth-first from the centre and from a corner, the tree a column-pivoted QR of the incidence matrix A selects, the tree the same pivoting selects on A scaled by the inverse square roots of the resistances, and the trees of least and greatest total resistance. For each, the upper bar is κ(Z) and the lower κ(ZᵀHZ), on a logarithmic scale. The best-conditioned Z is the centre breadth-first tree's, at 5.82, whose loop equations sit at 33.9. The best-conditioned loop equations are the centre breadth-first tree's, at 33.9, from a Z at 5.82. Pivoting on A gives 187 and pivoting on the scaled matrix 187; the greatest-resistance tree gives 91.5.8 × 8 grid · resistances all equal · one null space, six basescentre breadth-first — κ(Z)5.82κ(ZᵀHZ)33.9corner breadth-first — κ(Z)9.56κ(ZᵀHZ)91.5pivoted-QR — κ(Z)13.7κ(ZᵀHZ)187weighted pivoted-QR — κ(Z)13.7κ(ZᵀHZ)187least-resistance — κ(Z)9.56κ(ZᵀHZ)91.5greatest-resistance — κ(Z)9.56κ(ZᵀHZ)91.5the two bestsbest κ(Z)5.8its κ(ZᵀHZ)34best κ(ZᵀHZ)34node equations, κ590the tree that suits Zis not the tree that suits ZᵀHZ
Fig. 2 Six trees of the grid with every resistance equal. The centre breadth-first tree has both the best κ(Z), 5.82, and the best κ(ZᵀHZ), 33.9 — its square, exactly. Pivoting on A gives 187; the tree built by adding arcs in order of resistance, with every resistance tied, gives 91.5.

Spread the resistances and the ranking turns over

Now give each arc its own resistance, drawn at random over four decades, as a network of pipes or conductors of different sizes has. The constraint is unchanged, so every tree gives the same integer basis it gave before and the same κ(Z). What changes is H, and with it the reduced problem.

Six spanning trees of one 8 × 8 network: the conditioning of each loop basis and of its loop equationsOn one 8 × 8 grid with resistances drawn over 4 decades, six spanning trees each give a basis of loops for the same null space: breadth-first from the centre and from a corner, the tree a column-pivoted QR of the incidence matrix A selects, the tree the same pivoting selects on A scaled by the inverse square roots of the resistances, and the trees of least and greatest total resistance. For each, the upper bar is κ(Z) and the lower κ(ZᵀHZ), on a logarithmic scale. The best-conditioned Z is the centre breadth-first tree's, at 5.82, whose loop equations sit at 683. The best-conditioned loop equations are the least-resistance tree's, at 143, from a Z at 11.2. Pivoting on A gives 4100 and pivoting on the scaled matrix 143; the greatest-resistance tree gives 4040.8 × 8 grid · resistances drawn over 4 decades · one null space, six basescentre breadth-first — κ(Z)5.82κ(ZᵀHZ)683corner breadth-first — κ(Z)9.56κ(ZᵀHZ)3530pivoted-QR — κ(Z)13.7κ(ZᵀHZ)4100weighted pivoted-QR — κ(Z)11.2κ(ZᵀHZ)143least-resistance — κ(Z)11.2κ(ZᵀHZ)143greatest-resistance — κ(Z)7.41κ(ZᵀHZ)4040the two bestsbest κ(Z)5.8its κ(ZᵀHZ)683best κ(ZᵀHZ)143node equations, κ2.5·10⁴the tree that suits Zis not the tree that suits ZᵀHZ
Fig. 3 The same six trees with resistances over four decades. κ(Z) is as before; κ(ZᵀHZ) is not. The centre breadth-first tree, still best in Z at 5.82, gives loop equations at 683. The least-resistance tree, at κ(Z) = 11.2, gives 143. Pivoting on A gives 4,100.

The centre breadth-first tree still has the best Z, at 5.82, and its loop equations now sit at 683. The tree of least total resistance — built by taking arcs cheapest first and skipping any that would close a loop — has a Z nearly twice as badly conditioned, κ(Z) = 11.2, and loop equations at 143, 4.8 times better. The column-pivoted QR of A, the repair recommended for a general constraint, gives 4,100. The tree of greatest resistance gives 4,040, and the corner breadth-first tree 3,530.

The standard bound κ(ZᵀHZ) ≤ κ(H)·κ(Z)² ranks those two trees the wrong way round. The factor κ(H) is common to both, so the bound’s verdict is decided by κ(Z)², and (11.2/5.82)² says the breadth-first tree should be better by a factor of 3.7. It is worse by a factor of 4.8. A bound that multiplies the Hessian’s condition number by the basis’s cannot see how the two are aligned, and here the alignment is the whole effect: the least-resistance tree has a worse basis that H happens to suit.

The effect is not an accident of one draw. On three further draws of resistances over the same four decades the centre breadth-first tree’s loop equations are worse than the least-resistance tree’s by factors of 5.8, 20.4 and 13.7, beside the 4.8 above. On none of the four does the breadth-first tree come within a factor of four, and on one it loses by more than twenty.

Six spanning trees of one 8 × 8 network: the conditioning of each loop basis and of its loop equationsOn one 8 × 8 grid with resistances drawn over 4 decades, six spanning trees each give a basis of loops for the same null space: breadth-first from the centre and from a corner, the tree a column-pivoted QR of the incidence matrix A selects, the tree the same pivoting selects on A scaled by the inverse square roots of the resistances, and the trees of least and greatest total resistance. For each, the upper bar is κ(Z) and the lower κ(ZᵀHZ), on a logarithmic scale. The best-conditioned Z is the centre breadth-first tree's, at 5.82, whose loop equations sit at 7310. The best-conditioned loop equations are the least-resistance tree's, at 358, from a Z at 10.1. Pivoting on A gives 1.77·10⁴ and pivoting on the scaled matrix 358; the greatest-resistance tree gives 3.64·10⁴.8 × 8 grid · resistances drawn over 4 decades · one null space, six basescentre breadth-first — κ(Z)5.82κ(ZᵀHZ)7310corner breadth-first — κ(Z)9.56κ(ZᵀHZ)7150pivoted-QR — κ(Z)13.7κ(ZᵀHZ)1.77·10⁴weighted pivoted-QR — κ(Z)10.1κ(ZᵀHZ)358least-resistance — κ(Z)10.1κ(ZᵀHZ)358greatest-resistance — κ(Z)11.9κ(ZᵀHZ)3.64·10⁴the two bestsbest κ(Z)5.8its κ(ZᵀHZ)7314best κ(ZᵀHZ)358node equations, κ5.2·10⁴the tree that suits Zis not the tree that suits ZᵀHZ
Fig. 4 A second draw of resistances over four decades on the same grid. The centre breadth-first tree’s Z is unchanged at 5.82 and its loop equations are at 7,310; the least-resistance tree’s are at 358, from a Z at 10.1. Pivoting on A gives 1.77·10⁴.

On that draw the least-resistance tree’s Z is a little better than on the first, 10.1 against 11.2, while its loop equations are worse, 358 against 143 — the two quantities move independently from one draw to the next, which is the same finding read across draws instead of across trees. Pivoting on the incidence matrix, which sees no draw at all, picks the same tree both times and lands at 4,100 on one and 1.77·10⁴ on the other.

Every loop of the least-resistance tree is closed by its heaviest arc

The reason is a property of the tree that has nothing to do with conditioning and everything to do with how ZᵀHZ is assembled.

The diagonal entry of ZᵀHZ for a loop is the total resistance around it: its own arc plus every tree arc on the path back. The off-diagonal entry between two loops is the total resistance of the tree arcs they share. So a loop whose tree path carries a heavy arc has a diagonal entry dominated by that arc — and every other loop passing through the same arc has one dominated by it too, and all of those loops are coupled through it with an off-diagonal entry of nearly the same size. Rows that share one dominant term are nearly parallel, and nearly parallel rows are what an ill-conditioned matrix is. That is a mechanism rather than a measurement, and the measurement it predicts is the one below: whether each loop’s tree path carries an arc heavier than the loop’s own.

The tree built cheapest-first cannot put a heavy arc on a loop’s path unless that loop’s own arc is heavier still. That is the cycle property of a minimum spanning tree: every arc off the tree is the heaviest arc on the loop it closes, because had any tree arc on that loop been heavier, the cheapest-first construction would have taken the off-tree arc instead of it. So every diagonal entry of the least-resistance tree’s loop equations is led by an arc that belongs to that loop alone.

Each loop's heaviest tree resistance against its own arc's, for centre breadth-first and least-resistance treesOn an 8 × 8 grid with resistances drawn over 4 decades, every loop of each tree, sorted: the largest resistance on the loop's tree path divided by the resistance of the arc that closes it, on a logarithmic axis. For the centre breadth-first tree the ratio runs from 5010 down to 0.043, above one on 39 of 49 loops. For the least-resistance tree the ratio runs from 0.975 down to 0.00976, above one on 0 of 49 loops. A ratio below one means the arc that closes the loop is the heaviest arc on it.0102030405010⁻²10⁻¹110¹10²10³10⁴loops, sortedheaviest tree arc ÷ own arcown arc heaviestcentre breadth-firstleast-resistancethe least-resistance tree puts every loop's weight on its own arcwhich is what makes its diagonal honest
Fig. 5 For every loop of two trees, the heaviest resistance on its tree path divided by its own arc’s. On the centre breadth-first tree the ratio runs from 5,010 down to 0.043 and exceeds one on 39 of 49 loops. On the least-resistance tree it runs from 0.975 down to 0.00976 and exceeds one on none.

Measured loop by loop, the ratio of the heaviest resistance on the tree path to the loop’s own resistance is at most 0.975 on the least-resistance tree — below one on all 49 loops, as the cycle property requires — and falls to 0.00976. On the centre breadth-first tree it reaches 5,010 and exceeds one on 39 of the 49 loops. The breadth-first tree was grown without looking at the resistances, so it routes loops closed by light arcs through heavy tree arcs about as often as not, and each such loop is a row of ZᵀHZ led by a term it shares with its neighbours.

Pivoting works, on the matrix that includes the resistances

The repair for a general constraint was a greedy rule: take as the next basic column the one with the largest component not yet spanned. Applied to A, the rule sees only the incidence pattern. Every column of an incidence matrix has the same length, 2\sqrt{2}, apart from the arcs at the grounded node, so the greedy choice is decided by projections among columns that all look alike, and it lands on a tree with loops up to 32 arcs long and κ(ZᵀHZ) = 4,100 — the worst of the six.

Apply the same rule to A scaled by the inverse square roots of the resistances, AH^(−1/2), and the column lengths become 2/r\sqrt{2/r}: the least resistant arc has the longest column and is taken first. That is the first step of the cheapest-first construction, and the rest of the greedy pass follows it closely. On this network the two rules produce the identical tree, and so the identical κ(ZᵀHZ) of 143.

Over a wider sample — grids of side 6, 8 and 10, resistances spread over two to six decades, five draws each, seventy-five networks — the pivoted QR of AH^(−1/2) produced the identical tree in 66. In the other nine it differed by at most three arcs, and its loop equations were within a factor of 1.54 of the least-resistance tree’s, while the centre breadth-first tree on those same nine networks was worse by factors from 1.2 to 31.8. The pivoted rule was never the wrong idea. It was applied to the wrong matrix: the reduced problem is ZᵀHZ, and a basis chosen by looking at A alone is chosen for ZᵀZ.

That is the general form of the finding, and it holds beyond networks. The quantity a null-space method factorises is the Hessian restricted to the null space, and a rule that selects the basis by examining the constraint optimises the conditioning of a matrix nobody factorises. Scaling the constraint by the Hessian’s inverse square root before pivoting is the smallest change that makes the rule look at the right thing, and when the Hessian is diagonal it costs nothing.

Where the ranking turns

With every resistance equal the breadth-first tree wins, and with resistances over four decades it loses by 4.8. Between those there is a crossing, and sweeping the spread locates it.

The loop equations for three trees and the node equations, against the spread of resistances on an 8 × 8 gridOn an 8 × 8 grid whose resistances are drawn over a range widened from nothing to 6 decades, κ(ZᵀHZ), and κ(AH⁻¹Aᵀ) for the nodes, on logarithmic axes. For the least-resistance tree it runs from 91.5 to 1860. For the breadth-first tree it runs from 33.9 to 6140. For the greatest-resistance tree it runs from 91.5 to 3.72·10⁴. For the node equations it runs from 590 to 3·10⁵. The least-resistance tree overtakes the breadth-first one from a spread of 10².110¹10²10³10⁴10⁵10⁶10²10³10⁴10⁵spread of resistances, largest ÷ smallest possiblecondition numberleast-resistance treebreadth-first treegreatest-resistance treenode equationsthe unscaled loop equations still growonly more slowly than the others
Fig. 6 κ(ZᵀHZ) for three trees and κ(AH⁻¹Aᵀ) for the node equations, as the resistances spread from equal to six decades. The least-resistance tree overtakes the breadth-first one between a spread of ten and a hundred, and ends at 1,860 against 6,140.

At a spread of one the centre breadth-first tree’s loop equations are at 33.9 and the least-resistance tree’s at 91.5 — though with every resistance tied that second tree is simply the one the construction reaches by taking arcs in the order they are numbered, and it has none of the property the spread gives it. At a spread of ten the two are level, at 56.8 and 59.7. At a hundred the least-resistance tree is ahead, 48.2 against 123, and from there the gap widens with every decade, to 1,860 against 6,140 at a spread of a million. The greatest-resistance tree, which puts the heaviest arcs on the paths on purpose, climbs from 91.5 to 3.72·10⁴.

So the crossing is at about one decade of spread, which is less variation than almost any physical network has: two pipes in laminar flow whose diameters differ by a factor of two already differ in resistance by a factor of sixteen. For practical purposes a network whose arcs are not all alike is a network on which the tree should be chosen by resistance.

Two further readings of that sweep are left for a separate measurement. The node equations AH⁻¹Aᵀ — the range-space formulation of the same flow, which two ways to remove a constraint set beside the null-space one, and which on a network is a weighted graph Laplacian with its grounded row removed, one of the two Laplacians a graph carries — climb from 590 to 3.0·10⁵, worse than every tree at every spread. And even the least-resistance tree’s loop equations still grow, twenty-fold over six decades. Whether that growth is intrinsic or a matter of scale is a question about diagonal scaling, and the answer is not the one the unscaled numbers suggest.

What choosing the tree costs, and what it is not

Building the least-resistance tree is a sort of the arcs by resistance and one pass with a union–find structure to skip arcs that would close a loop: O(n log n) for n arcs, against O(m²n) for a column-pivoted QR of an m × n constraint. On a network the pivoted rule on the scaled matrix is an expensive way of reaching nearly the same tree, and the cheap way reaches it exactly.

This is not the use of spanning trees in a preconditioner that is a tree, though the object is the same. There a tree’s Laplacian stands in for the whole graph’s inside an iteration on the node equations, its quality is measured by the stretch of the arcs off it, and on a uniform grid it made the conditioning worse by a factor of 1.85. Here the tree does not approximate anything: it selects a basis, the reduced problem is solved exactly, and what the tree decides is the condition number of that exact problem. The two uses reward different trees for different reasons, and the resistances enter this one through the cycle property rather than through stretch.

Nor does the choice of tree touch what the null-space method computes in exact arithmetic. Any two bases of one null space differ by an invertible matrix, and the spectrum of a constraint preconditioner is invariant under that change; every tree here gives the same flow to the last digit a rational solve would print. What the tree decides is only how many of those digits floating point keeps, which is the whole of the difference and none of the algebra.

It is also a sharper version of a pattern that keeps recurring in this field: a combinatorial choice made before any arithmetic decides a number the arithmetic then inherits, as the order that decides the memory does for fill. Eliminating a vertex is a graph operation, and the order in which vertices are eliminated fixes the fill before a single entry is computed; a spanning tree is a graph object too, and choosing it fixes the conditioning of the loop equations before a single loop is assembled. The difference is that the fill depends only on the graph, while the conditioning here depends on the graph and the weights together — which is exactly why a rule that reads only the graph gets it wrong.

Still open: whether the loops or the nodes are the easier system

The sweep above leaves two numbers unexplained. The node equations are worse than every tree’s loop equations, by two to three orders at a spread of a million, and the least-resistance tree’s loop equations still grow with the spread. Both readings are of unscaled matrices, and a diagonal of resistances spread over six decades is exactly what an unscaled condition number over-reports.

Scaled to a unit diagonal — the cheapest preconditioner there is, and the one any iterative solver applies first — the two systems part company in a way the unscaled sweep does not hint at, and the grid’s size stops mattering to one of them. That is measured in spread resistances make the loops easy. Beyond it lie a Hessian that is not diagonal, where no tree reads the weights directly, and a sparse reduced problem whose fill depends on how many loops share each tree arc — a second thing the tree decides, and one that pulls the opposite way, since the least-resistance tree’s loops are longer.

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.

Column pivotingCondition numberGraph laplacianGroundingNull-spaceNull-space basisNull-space methodReduced hessianSpanning tree