Refining the solution alone refines nothing
Worth reading first: The projection and the right angle · Orthogonal is a number · Buying the accuracy back.
Where QR pays the square measured Householder QR’s least-squares solution against the exact solution of the stored data, which fraction-free elimination over the integers can compute, and found that QR’s error grows as the square of the condition number whenever the data lie at an angle to the column space and the solution is ordinary in size: a slope of 1.98 at a tangent of one. Wedin’s perturbation theory says that term belongs to the problem and not the method, times the roundoff, and the measurement confirmed that no algorithm working in binary64 on the stored data escapes it.
It also found that the residual, unlike the solution, is computed with an error of slope one, , at every angle: QR returns an accurate residual and an inaccurate solution from the same factors. The projection and the right angle had set the two quantities side by side as the foot of a perpendicular and the perpendicular itself, and the measurement says the factorisation knows the second far better than the first.
That essay ended on the obvious repair. For a square linear system, iterative refinement, computing the residual and solving for a correction with the factorisation already in hand, reduces the error to its forward limit, and with the residual computed in higher precision it reduces it further. The prediction with a sign was in two parts: that one or two steps of refinement in working precision would not lower QR’s error at by more than a factor of three, because the error is in the stored data and not in the factorisation; and that with the residual computed in twice the working precision the term would fall by a factor of at least , since then the stored data would be refined against rather than absorbed.
The first part holds. The second fails as completely as a prediction can, and then holds with room to spare for a different refinement, which is the more useful finding.
Four refinements of one answer
The problems are the earlier essay’s: 24 by 6, singular values spread geometrically down to , the data at a tangent to the column space, and the solution random so that the fit lies along the top singular vectors. The reference is the exact solution of the stored doubles. Every refinement starts from QR’s answer and reuses the same Householder factors.
Two refinements are tried, each in two precisions. The first refines the solution alone: compute , solve the least-squares problem with the factors, and add to . That is what iterative refinement for a square system does, applied to a rectangular one. The second is Björck’s refinement of the augmented system,
which is the least-squares problem written as a square system in the residual and the solution together. Its residuals are $f = b
- r - Ax$ and , and the same QR solves for corrections to both. In each case the residuals are computed either in binary64 or exactly, from the doubles’ exact values in integer arithmetic, and rounded once; anything of at least twice the working precision gives the same result on problems this size.
At , QR’s error is . Refining the solution alone with the residual in binary64 leaves it at after one, two and three steps. Refining the solution alone with the residual computed exactly leaves it at after one, two and three steps. Refining both together in binary64 moves it to , and . Refining both together with the residuals computed exactly takes it to after one step and to zero after two: the refined solution is the exact solution of the stored data, rounded to the nearest double in every component.
The dial shows the same shape at every condition number. At and three of the routes sit on QR’s error and the fourth reaches zero in one step.
The prediction’s first half
The first part of the prediction was that refinement in working precision changes nothing of consequence, and on both refinements it holds within its factor of three. The solution refined alone in binary64 does not move at all. The augmented refinement in binary64 wanders: up to from at after three steps, down to at , never far from where it started. That is the expected behaviour of fixed-precision refinement: it can improve a solver whose factorisation was unstable, and Householder QR is not unstable, so there is nothing for it to improve. The error is the stored problem’s sensitivity times the roundoff in forming the residual, and computing that residual in the same precision gives it back.
The reason given for the prediction was that “the error is in the problem’s stored data and not in the factorisation”. That is the right diagnosis. What it implies about the second half is where the reasoning slipped.
An exact residual, and the same error
Against the condition number the picture is stark. Three of the four routes lie on QR’s own line after a step, from at to at , and the exact residual on the solution alone is one of the three. It does not lower the error at any condition number by any factor worth recording. The fourth route, both refined with exact residuals, is at zero or within a few units of the roundoff at every condition number.
The failure has a clean explanation, and it is one that Golub and Wilkinson gave in 1966. The exact residual of the current solution is , where and are the true solution and residual. The correction step solves a least-squares problem with as its data. Its exact answer would be , because is orthogonal to the column space and contributes nothing. But the correction is computed by the same QR in binary64, and a least-squares solve in binary64 of data with a large component orthogonal to the column space has an error of order — which is the error the original solve made, and for the same reason. The exact residual hands the correction step a problem with exactly the same angle to the column space as the original one. Computing it exactly has removed the rounding in , and the rounding in was never what put the square into the answer.
On a square system the true residual is zero, so the correction’s data are all in the range, and an exact residual is exactly what is needed. For a least-squares problem the true residual is the largest part of , and refining the solution alone keeps feeding it back through the solver.
The angle decides when the solution alone is enough
That explanation predicts when refining the solution alone does work, and the measurement agrees.
With a zero residual, a consistent system, the exact residual on the solution alone takes QR’s to zero in one step, exactly as for a square system, because there is no to feed back. At a tangent of it does nothing: QR’s stays at . At a tangent of the error is , the solution has almost no correct digit, and refining it alone leaves it at . Over every condition number and angle measured, wherever is a hundred or more, so that the square’s term dominates the error, one step of the solution alone is within half again of QR’s own error. Where is small, the error is QR’s ordinary term and the exact residual removes it, as it does at and , where the error falls from to .
The augmented refinement with exact residuals takes every one of the four angles to under in one step, including the tangent of , where it goes from to , and to the exact solution in two.
Why refining the residual works
The augmented matrix is a saddle-point matrix: an identity block, a zero block, and the constraint coupling them. The zero that is not a missing entry met the same shape as the system a constrained minimisation produces, where the zero block is a theorem and not sparsity, and here the theorem is the right angle: the residual must be orthogonal to the columns. Writing least squares this way makes the orthogonality an equation the refinement can correct, rather than a property the solver is trusted to deliver, and that is the whole of the difference between the two refinements.
The augmented system’s correction step has right-hand sides and . The first is small when the current and fit the data, and the second is small when the current is orthogonal to the columns. Neither contains the large true residual itself: is carried as an unknown, so its bulk is subtracted out before the correction is solved, and what is passed to the factors is only the part of each equation the current iterate gets wrong. The square in QR’s error came from solving data with a large component outside the column space. The augmented correction never asks the factors to solve such data, because the large component has been moved to the left-hand side as a variable.
That is also why it needs the extra precision. In binary64, is the difference of , and , quantities of order one whose difference is of order , and the subtraction loses that difference to rounding. Computed exactly, and are exactly what the current iterate gets wrong, and the factors, solving a problem with no large residual, solve it to their ordinary accuracy. One step multiplies the error by about , which is at ; the second step finishes it.
The slopes say the same thing in one number each. Before refinement it is 1.94. After one step and after three, the solution alone gives 1.95 with either residual, and the augmented refinement in binary64 gives 1.94 to 1.98. No step of any of those three moves the square. The fourth has no slope to fit: its error is zero after two steps at every condition number.
A large solution, and a step that does not hurt
The earlier essay’s second kind of problem has the fit drawn at random in the range, so that the solution is about as long as the condition number and QR’s error has slope one, because the square’s term is small relative to so large a solution. There is no square to remove, and the question is only whether any refinement makes things worse.
Two of them do, slightly. At QR’s error is and the solution refined alone gives or , by either residual, and the augmented refinement in binary64 ; at , QR’s becomes to refined alone. These are factors of a few, the cost of adding a correction computed with the error the original solve had. The augmented refinement with exact residuals is zero after one step at all three condition numbers. It does not care which kind of problem it is given, because it solves the stored problem rather than one of its perturbation terms.
What this changes about mixed precision
Buying the accuracy back and the part of a solver that may be rounded describe iterative refinement for square systems, where a factorisation in low precision and a residual in high precision buy back the digits the factorisation lost. The same strategy for least squares is used in practice, and these measurements say exactly how it must be written. Refining the solution alone, with any precision of residual, cannot remove the term, and on a consistent or nearly consistent problem it is not needed for that purpose anyway. Refining through the augmented system with the residuals in extended precision removes it entirely, in one step on these problems.
The same measurements also say something about trust. A small residual is not a small error for square systems, and for least squares the distinction is sharper still: QR’s residual here is accurate to while its solution carries , so a code that checks its answer by recomputing the residual sees a good residual and learns nothing about the solution. The residual the solution cannot hold found a related gap between a fitted residual and the solution that produced it. The augmented refinement’s first correction is the one quantity in this computation that is computed against the right reference, and it is the natural place to read the solution’s accuracy from.
The cost is small: two residual computations of operations each, in extended precision, and a correction solved with factors already in hand. The augmented system’s square matrix is never formed, since the QR of solves it, and the road that squares the problem is not taken at any point. What was paid for in the earlier essay’s account, that “no algorithm working on the stored data escapes the square”, remains true of every single solve in binary64. Two solves and two exact residuals escape it.
Where these numbers come from
Every problem is 24 by 6, which is small enough for the exact reference and large enough for the slopes to be clean. Five draws at each setting give medians, and every claim above holds on the medians rather than draw by draw. The exact residuals are exact, which is more than a code would use; twice the working precision rounds each component to relative, far below anything measured here, but a code using a double-double residual rather than an exact one could meet cancellations this setup does not contain. Björck’s refinement is implemented with the full orthogonal factor formed explicitly, which a code would not do; the reflectors give the same products. And the larger system the earlier essay asked about, 200 by 50 at the same condition and angle, was not measured, because the exact reference grows as the cube of the column count in integer digits.
What is settled is the shape. In working precision no refinement moves QR’s square. With exact residuals the solution alone still does not, wherever the residual is large; the residual and solution together do, at once.
Still open: how much precision the residual needs, and a refinement that stops itself
The residual’s precision, as a number. The augmented step multiplies the error by about when its residuals are exact. The prediction with a sign is that with the residuals computed in a precision of bits instead, rounded to that precision after each operation, one step reaches to within a factor of ten, so that 80-bit extended precision suffices at and a tangent of one, and binary128 suffices at every setting here, while a double-double residual matches the exact one on every problem measured.
A refinement that knows when to stop. The second augmented step took every problem here to its exact solution. The prediction is that the norm of the first correction, , is within a factor of three of QR’s true error on every draw, so that the first step’s correction measures the error it removes, and a code can report the original solution’s accuracy for the price of the refinement, at every condition number and angle here.
Shares its objects with
Essays that name at least two of the same things, and that neither author linked.
- A constraint is a weight at infinity — both name condition number, exact ground truth, least squares, qr factorisation, saddle-point systems
- Feasible and wrong — both name condition number, exact ground truth, qr factorisation, residual, saddle-point systems
- The condition number that does not know — both name condition number, exact ground truth, qr factorisation, saddle-point systems
- The factor a sparse code keeps anyway — both name condition number, least squares, qr factorisation, residual
- The half of a problem a sketch may touch — both name condition number, exact ground truth, least squares, saddle-point systems
- The reference was a method — both name condition number, exact ground truth, qr factorisation, saddle-point systems
Named objects
A flat tag is an object no other essay names yet.
Condition numberExact ground truthIterative refinementLeast squaresQR factorisationResidualSaddle-point systems