Generator

Fitting the same degree-11 polynomial in two bases

One function in the lsq library, called 20 times across 3 essays. Below: what it draws at its defaults, what it draws at every value an essay asks for, the 39 claims it put to the test while drawing them, and where it stands against the rule this site is named for.

At its defaults it draws fitting the same degree-11 polynomial in two bases. On the left, the data and two fitted curves that lie on top of each other. On the right, the condition numbers of the two design matrices, ten orders of magnitude apart.

basis-conditioning is one function in lib/figures/lsq.js — least squares — the projection, the road not to take, and the valley with no bottom. Everything below came out of it during this build, at arguments taken from the essays rather than invented for this page. A figure here is the figure a reader meets in an essay, and if the generator changes, this page changes with it.

At its defaults

Drawn even though every essay passes arguments — which on this site is every essay, at 100% of placements since the standard pass. A default nothing exercises is a trap for the next essay to call this with none, and this is the page where a default that has drifted from the figures around it becomes visible.

Fitting the same degree-11 polynomial in two basesOn the left, the data and two fitted curves that lie on top of each other. On the right, the condition numbers of the two design matrices, ten orders of magnitude apart.00.10.20.30.40.50.60.70.80.910.20.40.60.81xyboth fits, drawn on top of one anothercondition number of the design matrixmonomial1.2·10⁸Chebyshev2.5largest fitted coefficientmonomial113Chebyshev0.51rms residual: 3.9·10⁻⁶ and 2.9·10⁻⁷ — the data is fitted either way.30 points, degree 11, single precisionthe basis is part of the problem

On the left, the data and two fitted curves that lie on top of each other. On the right, the condition numbers of the two design matrices, ten orders of magnitude apart.

show: "kappa", points: "gap"

The arguments are the ones A basis built from the points passes. A value nobody placed would be a picture no essay asked for and no claim was ever checked against.

Condition number of the least-squares matrix against the degree, three bases, 200 two intervals with a gap between themThree bases for the polynomials of each degree, on a logarithmic axis. The monomial design matrix reaches 1.5·10¹⁷ by degree 48; Chebyshev polynomials reach 1.55·10⁷; the basis built from the sample points by Arnoldi's process is orthonormal on them and its condition number is 1 to rounding at every degree. The dashed line is 1/u, past which a double cannot hold the matrix's conditioning at all.08162432404810⁻¹10²10⁵10⁸10¹¹10¹⁴10¹⁷10²⁰degreeκ of the design matrix1/u: past this a double holds nothingmonomialsChebyshevArnoldi on the pointsκ at degree 48monomials1.5·10¹⁷Chebyshev1.6·10⁷Arnoldi on the points1200 two intervals with a gap between themthree bases for one space of polynomials

Three bases for the polynomials of each degree, on a logarithmic axis. The monomial design matrix reaches 1.5·10¹⁷ by degree 48; Chebyshev polynomials reach 1.55·10⁷; the basis built from the sample points by Arnoldi's process is orthonormal on them and its condition number is 1 to rounding at every degree. The dashed line is 1/u, past which a double cannot hold the matrix's conditioning at all.

deg: 11

The arguments are the ones A basis built from the points passes. A value nobody placed would be a picture no essay asked for and no claim was ever checked against.

Fitting the same degree-11 polynomial in two basesOn the left, the data and two fitted curves that lie on top of each other. On the right, the condition numbers of the two design matrices, ten orders of magnitude apart.00.10.20.30.40.50.60.70.80.910.20.40.60.81xyboth fits, drawn on top of one anothercondition number of the design matrixmonomial1.2·10⁸Chebyshev2.5largest fitted coefficientmonomial113Chebyshev0.51rms residual: 3.9·10⁻⁶ and 2.9·10⁻⁷ — the data is fitted either way.30 points, degree 11, single precisionthe basis is part of the problem

On the left, the data and two fitted curves that lie on top of each other. On the right, the condition numbers of the two design matrices, ten orders of magnitude apart.

show: "noise"

The arguments are the ones A basis built from the points passes. A value nobody placed would be a picture no essay asked for and no claim was ever checked against.

How far a fitted curve moves with the basis it is computed in, 200 equispaced points, noise 0.001The largest distance, at the sample points, between the least-squares curve computed in monomials or in Chebyshev polynomials and the same fit computed in the basis Arnoldi builds from the points, on a logarithmic axis against the degree. With noise of 0.001 the residual is 8.3·10⁻⁴, and each basis's curve is off by about its condition number times the unit roundoff times that residual — the dashed line of the same colour. At degree 48 the monomial curve is off by 0.004 and the Chebyshev curve by 2.4·10⁻¹⁵.08162432404810⁻¹⁸10⁻¹⁵10⁻¹²10⁻⁹10⁻⁶10⁻³degreegap between the fitted curvesmonomialsChebyshevsolid: measured · dashed: κ·u·rms(r)degree 48, noise 0.001rms residual8.3·10⁻⁴monomial curve, off by0.004Chebyshev curve, off by2.4·10⁻¹⁵against the fit in the basis orthogonal on the noisy datanoise: the basis costs κ·u·rms(r)

The largest distance, at the sample points, between the least-squares curve computed in monomials or in Chebyshev polynomials and the same fit computed in the basis Arnoldi builds from the points, on a logarithmic axis against the degree. With noise of 0.001 the residual is 8.3·10⁻⁴, and each basis's curve is off by about its condition number times the unit roundoff times that residual — the dashed line of the same colour. At degree 48 the monomial curve is off by 0.004 and the Chebyshev curve by 2.4·10⁻¹⁵.

show: "noise", noise: 0.1

The arguments are the ones A basis built from the points passes. A value nobody placed would be a picture no essay asked for and no claim was ever checked against.

How far a fitted curve moves with the basis it is computed in, 200 equispaced points, noise 0.1The largest distance, at the sample points, between the least-squares curve computed in monomials or in Chebyshev polynomials and the same fit computed in the basis Arnoldi builds from the points, on a logarithmic axis against the degree. With noise of 0.1 the residual is 0.083, and each basis's curve is off by about its condition number times the unit roundoff times that residual — the dashed line of the same colour. At degree 48 the monomial curve is off by 0.4 and the Chebyshev curve by 2.9·10⁻¹⁵.08162432404810⁻¹⁸10⁻¹⁵10⁻¹²10⁻⁹10⁻⁶10⁻³1degreegap between the fitted curvesmonomialsChebyshevsolid: measured · dashed: κ·u·rms(r)degree 48, noise 0.1rms residual0.083monomial curve, off by0.4Chebyshev curve, off by2.9·10⁻¹⁵against the fit in the basis orthogonal on the noisy datanoise: the basis costs κ·u·rms(r)

The largest distance, at the sample points, between the least-squares curve computed in monomials or in Chebyshev polynomials and the same fit computed in the basis Arnoldi builds from the points, on a logarithmic axis against the degree. With noise of 0.1 the residual is 0.083, and each basis's curve is off by about its condition number times the unit roundoff times that residual — the dashed line of the same colour. At degree 48 the monomial curve is off by 0.4 and the Chebyshev curve by 2.9·10⁻¹⁵.

show: "noise", points: "clustered"

The arguments are the ones A basis built from the points passes. A value nobody placed would be a picture no essay asked for and no claim was ever checked against.

How far a fitted curve moves with the basis it is computed in, 200 points clustered towards −1, noise 0.001The largest distance, at the sample points, between the least-squares curve computed in monomials or in Chebyshev polynomials and the same fit computed in the basis Arnoldi builds from the points, on a logarithmic axis against the degree. With noise of 0.001 the residual is 8.5·10⁻⁴, and each basis's curve is off by about its condition number times the unit roundoff times that residual — the dashed line of the same colour. At degree 48 the monomial curve is off by 6.6·10⁻⁴ and the Chebyshev curve by 2.9·10⁻¹³.08162432404810⁻¹⁸10⁻¹⁵10⁻¹²10⁻⁹10⁻⁶10⁻³degreegap between the fitted curvesmonomialsChebyshevsolid: measured · dashed: κ·u·rms(r)degree 48, noise 0.001rms residual8.5·10⁻⁴monomial curve, off by6.6·10⁻⁴Chebyshev curve, off by2.9·10⁻¹³against the fit in the basis orthogonal on the noisy datanoise: the basis costs κ·u·rms(r)

The largest distance, at the sample points, between the least-squares curve computed in monomials or in Chebyshev polynomials and the same fit computed in the basis Arnoldi builds from the points, on a logarithmic axis against the degree. With noise of 0.001 the residual is 8.5·10⁻⁴, and each basis's curve is off by about its condition number times the unit roundoff times that residual — the dashed line of the same colour. At degree 48 the monomial curve is off by 6.6·10⁻⁴ and the Chebyshev curve by 2.9·10⁻¹³.

What it checked while drawing

Every figure above checked its own claims on the way to being drawn, and a claim that failed would have stopped the picture rather than shipped a wrong one. Those checks used to leave no trace at all: a passing one returned true and the only evidence the figure had checked anything was that nothing crashed. The list below is what they actually said, collected by running this generator with an observer installed — not a description of what it is believed to check.

39 distinct claims across 6 sets of arguments, grouped below by shape — because most of them are one sentence with a different number in it, and how many separate times that sentence was put to the test is the informative part.

the basis built from the points is orthonormal on them at degree 4 — checked 12 times

the monomial curve's distance from the orthogonal one is κ·u·rms(r) to within the constant at degree 20 — checked 8 times

a new direction to add at this degree

a noise level the dial draws

a noise level the study draws

a point set the sweep defines

a point set this file defines

a reading of the basis this generator draws

a sample the dense least squares is affordable on

a top degree the sweep reaches in steps of four

and the 1/u label has room above its line

and the badly conditioned one still fits the data

and the monomials are not

at enough degrees for the relation to be read

every ratio fits the axis

no noise, or a noise level between 10⁻⁹ and 10⁻¹

the badge sits clear of every line

the legend clears the axis label on their shared line

the monomial basis is far worse conditioned

the well-conditioned fit is excellent

while its coefficients have blown up

Against the rule

It draws a decomposition and prints its residual. It calls lstsqQR, and every figure above carries the badge — which residualcheck verifies by looking for it in the emitted SVG rather than by finding the call that builds one. A badge that is constructed and then left out of the body is the failure that check exists for.

Across the library: the rule bites on 217 of 397 generators — 199 print a residual and 18 are exempt with a published reason; 180 factorise nothing. Read from lib/residual-rule.js, which is the same body the gate enforces from, and the gate's last check fails the build if this page and it disagree about any generator.

Where it is called

Changing this generator changes every figure on this list. That is what makes the list worth publishing rather than keeping in a check script.

Least squares, and the road not to take

A basis built from the points

A polynomial fit computed in monomials and in an orthogonal basis gives the same curve on exact data, and the valley essay drew the two lying on top of each other. Add 0.1% noise and they separate — by 1.7·10⁻⁵ at degree 40 and 0.004 at degree 48 — because the fitted curve moves with the basis by its condition number times the rounding times the residual. Chebyshev polynomials keep that small only on points spread like their weight; on a sample with a hole in it they reach κ = 1.55·10⁷. A basis orthogonalised against the sample points themselves stays at 1 on every set.

Least squares, and the road not to take

The degree that is safe to overshoot

The rules that choose a Tikhonov parameter miss by factors of millions on one draw in twenty. Transplanted to the degree of a polynomial fit, in a basis orthonormal on the data, the same rules never cost more than 2.7 times the best degree's error in three hundred draws. The reason is the shape of the valley they search: six degrees too few costs from 44 to 16,000 times the best error, forty degrees too many costs about twice it. The one rule with a tail, the discrepancy principle, has its threshold half a standard deviation above the residual it is waiting for.

Least squares, and the road not to take

The valley with no bottom

A degree-nine fit's coefficients can be moved by a third of their own size before the residual changes in the sixth significant figure. The arithmetic did not lose those digits. The data never contained them.

The whole library · All essays · What must fail