Topic

Nonlinear solving

Nonlinear solvers keep returning to linear algebra. Newton's method solves a linear system with the Jacobian at every step. Proving that a root exists, and that there is only one, needs linear algebra with intervals.

Newton and the Krawczyk test

Newton's method converges fast but proves nothing. Running it in exact rationals proves nothing either, and the denominators roughly double each step. The Krawczyk test turns an approximate root into a certificate. Take a box X around it, its midpoint m and Y ≈ J(m)⁻¹. Then compute K(X) = m − Y·f(m) + (I − Y·J(X))(X − m) in exact interval arithmetic. If K(X) lies inside X, X contains exactly one root. If K(X) misses X, there is no root there. Repeating the step shrinks the box quadratically.

certifyRoot does this for systems: you give f (exact at rational points) and an interval enclosure of the Jacobian over a box. The preview is float Newton; the exact stage is the certified box.

Uncertain coefficients

When the entries of A and b are only known to lie in ranges, solveIntervals returns a box that contains the solution of every system in the range, and proves that every matrix in the range is invertible. This is the same Krawczyk test with f(x) = A·x − b.

In code

import { certifyRoot } from "@ratmath/linalg";
import { Rational, RationalInterval } from "@ratmath/core";

// The circle x² + y² = 4 and the line y = x/2
const half = new Rational(1, 2), two = new RationalInterval(2, 2);
const r = certifyRoot({
  f: ([x, y]) => [x.multiply(x).add(y.multiply(y)).subtract(new Rational(4)), y.subtract(half.multiply(x))],
  jacobian: ([X, Y]) => [[X.multiply(two), Y.multiply(two)],
                         [new RationalInterval(half.negate(), half.negate()), new RationalInterval(1, 1)]],
  guess: [1, 1],
  bits: 30,
}).exact();
r.status;   // "unique": the box holds exactly one zero
r.box;      // two RationalIntervals around x = 4/√5, y = 2/√5
Try itEdit the code and run it with @ratmath/linalg and Core's Rational, RationalInterval in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs