NLA-lib Explorer

Residual, solve and update as operations

Implementation of Iterative refinement

This page describes the library's certified refinement program. The residual, the correction solve and the update are operations of the model, each with its own accuracy contract, so each may be implemented in a different precision. The program performs no scalar arithmetic of its own, so its theorem applies to any implementation of the three operations. The three-precision program is one such implementation, in scalar arithmetic.

Mathematical method

Algorithm

input: right-hand side b; start x (updated in place); scratch r, d, all of length n
repeat k times:
    r := residual(b, x)
    d := solve(r)
    x := update(d, x)
output: x

The number of steps k is fixed: the program has no stopping test. It is the routine LinearSystems.Refinement.solve. The matrix is in no buffer, and is reached only through residual and solve.

Buffer Content
0 The n words of \mathbf{b}, read only
1 The n words of \mathbf{x}_0, overwritten by the output
2 Room for n words: the residual, not reported
3 Room for n words: the correction, not reported

Model of arithmetic

All statements on this page are for

Prescribed accuracy of each operation

Definitions of the arithmetic models · Other programs of this algorithm: Cholesky refinement in three precisions (Standard rounding at three precisions)

The model has three operations and no query. For the matrix \mathbf{A} of the input and fixed \theta,\eta,\zeta,\varepsilon\ge0, on decoded blocks in the Euclidean norm:

Operation Contract
residual \|\mathbf{b}-\mathbf{A}\mathbf{x}-\mathbf{r}\|\le\zeta\|\mathbf{b}-\mathbf{A}\mathbf{x}\|+\eta(\|\mathbf{b}\|+\|\mathbf{A}\|_2\|\mathbf{x}\|)
solve \|\mathbf{A}^{-1}\mathbf{r}-\mathbf{d}\|\le\theta\|\mathbf{A}^{-1}\mathbf{r}\|
update \|\mathbf{x}+\mathbf{d}-\mathbf{x}'\|\le\varepsilon\|\mathbf{x}+\mathbf{d}\|

residual and solve are declared oracles for \mathbf{A}: their contracts depend on the input only through the matrix. update has one contract at every size and input. The model is confined, and exact arithmetic satisfies the three contracts jointly, so they are not vacuous. These contracts are assumptions of the model. In particular, a solve meeting its contract is assumed here, not built from a factorization.

Operations and Storage

With unit weights, each call of residual, solve or update and each structural instruction counts one. The work and span are at most

25k+15

instructions, independent of n because the three vector operations are primitives. There are 3k operation calls. This is not a count of scalar operations: the cost of a factorization, of a residual and of an update is not included. The supplied buffers hold 4n words and the routine allocates nothing.

Accuracy

Theorem (Forward error of the stored output). Let \mathbf{A} be invertible of order n, with

\varphi=(1+\varepsilon)\bigl(\theta+(1+\theta)\kappa_2(\mathbf{A})(\zeta+\eta)\bigr)<1,\qquad\xi=(1+\varepsilon)(1+\theta)\,2\kappa_2(\mathbf{A})\eta+\varepsilon.

For every \mathbf{b} and \mathbf{x}_0, every interpretation satisfying the three contracts and every tape, the run of the fixed program from \mathbf{b}, \mathbf{x}_0 and two blank vectors succeeds within 25k+15 instructions, and buffer 1 then holds \hat{\mathbf{x}} with, for \mathbf{A}\mathbf{x}_\star=\mathbf{b},

\|\mathbf{x}_\star-\hat{\mathbf{x}}\|\le\varphi^k\|\mathbf{x}_\star-\mathbf{x}_0\|+\frac{\xi}{1-\varphi}\|\mathbf{x}_\star\|.

Lean statement and details
NLAlib.LinearSystems.Refinement.Certification.algorithm_checked (θ η ζ ε : ℝ)
  (domain : (Fin 2 → ℕ) → Prop) (admitted : ∃ d, domain d)
  (supply :
    ∀ (d : Fin 2 → ℕ), domain d → ∃ x, LinearSystems.Refinement.Certification.accepts θ η ζ ε d x)
  (hθ : 0 ≤ θ) (hη : 0 ≤ η) (hζ : 0 ≤ ζ) (hε : 0 ≤ ε) (d : Fin 2 → ℕ) (hd : domain d)
  (A : Matrix (Fin (d 0)) (Fin (d 0)) ℝ) (rhs x₀ : Fin (d 0) → ℝ) (hA : IsUnit A)
  (hφ : refinementContractionFactor (pseudoConditionNumber A) θ η ζ ε < 1)
  (I : Ops.Interp Ops.RefinementOp Empty ℝ)
  (hI :
    (LinearSystems.Refinement.Certification.model θ η ζ ε domain admitted supply hθ hη hζ
          hε).contracts
      d
      ((LinearSystems.Refinement.Certification.inputs θ η ζ ε domain admitted supply).input d
        (A, rhs, x₀) ⋯)
      I)
  (τ : Ops.Tape ℝ) :
  ∃ st,
    Ops.Reference.Execution LinearSystems.Refinement.Certification.program I
        (LinearSystems.Refinement.Certification.model θ η ζ ε domain admitted supply hθ hη hζ
            hε).resources
        (LinearSystems.Refinement.Certification.inputs θ η ζ ε domain admitted supply).formats τ d
        ((LinearSystems.Refinement.Certification.inputs θ η ζ ε domain admitted supply).memory d
          (A, rhs, x₀))
        st ∧
      (LinearSystems.Refinement.Certification.model θ η ζ ε domain admitted supply hθ hη hζ
                  hε).resources.work
            st.cost ≤
          25 * d 1 + 15 ∧
        (LinearSystems.Refinement.Certification.inputs θ η ζ ε domain admitted supply).bytes d +
              st.peak ≤
            (LinearSystems.Refinement.Certification.inputs θ η ζ ε domain admitted supply).bytes d +
              Ops.staticPeak
                (LinearSystems.Refinement.Certification.model θ η ζ ε domain admitted supply hθ hη
                    hζ hε).resources
                LinearSystems.Refinement.Certification.program d ∧
          ∃ x,
            st.mem.Holds (Ops.Codec.vector (d 0)) 1 x ∧
              ∀ (xstar : Fin (d 0) → ℝ),
                A *ᵥ xstar = rhs →
                  ‖WithLp.toLp 2 (xstar - x)‖ ≤
                    refinementContractionFactor (pseudoConditionNumber A) θ η ζ ε ^ d 1 *
                        ‖WithLp.toLp 2 (xstar - x₀)‖ +
                      refinementAccuracyBound (pseudoConditionNumber A) θ η ε /
                          (1 - refinementContractionFactor (pseudoConditionNumber A) θ η ζ ε) *
                        ‖WithLp.toLp 2 xstar‖

Full source on GitHub

Copy link

The condition \varphi<1 is part of the admitted inputs. The stored iterates form a refinement run, so every theorem about a run applies to them.

Not yet presented

  • A stopping test, and the backward-error results of Carson and Higham.