Givens and Householder explorer
A Givens rotation or a Householder reflector is built from one column of the matrix, the pivot column , so that it puts on the first axis. Every other column of the rows it touches is then carried along: the same operator is applied to it, and it rotates or reflects without landing on any axis. The figures in Givens and Householder in pictures show only the pivot column. Here you can move both.
The operator is computed the way MTL5 computes it, in the number format you choose. Each multiply, add, divide and square root is rounded to the format, so the operator you see is the one a factorization in that format would apply. The arrows’ hollow rings show where an exact operator would put each vector.
Drag the arrow tips. ● computed image of x, ○ where an exact operator puts it; ● and ○ the same for y. Ticks on the axes mark the format's values when they are few enough to draw.
What to look at
Section titled “What to look at”The pivot column lands on the axis; the carried one is only moved. The operator is chosen for , so ends at up to rounding. turns through the same angle, or flips across the same mirror, and keeps its length only as well as the operator is orthogonal. The tables report that as , in units of the format’s unit roundoff at 1.
A rounded operator is not orthogonal. For a rotation, is the stretch it applies to every vector. In fp8 E4M3 at the starting position, , rounds to 2.75 against an exact 2.92, so rounds to 0.9375 and . The reflector for the same in the same format has .
Squaring overflows before the answer does. MTL5’s GMRES forms
without scaling. In binary16, set
(view ±400): is beyond the largest binary16
value, 65504, so , , and the “rotation” is the zero
matrix. Both columns vanish. Choose scaled by max(|a|, |b|) first and the
same gives . In fp8 E4M3, which saturates instead of
overflowing, gives against an exact 25. The scaled
form is the one lapy2 and MTL5’s householder() use.
Squaring underflows too. In binary16, set : both squares are below the smallest subnormal, the sum is zero, and the unscaled rotation is the identity. The scaled one rotates correctly.
The reflector can decline. MTL5’s householder() returns the identity
when is below half an ulp of , and when the computed reflector would be
further from orthogonal than leaving alone. In fp8 E4M3,
takes the first exit, while the rotation still turns by
. The readout names the test that fired.
The entry that should be zero. Applying the computed operator to
leaves a small second component. Factorizations do not use it: MTL5’s GMRES
writes and an exact 0, and qr_factor stores the reflector’s vector below
the diagonal in its place. The rest of the row pair, the carried columns,
gets no such repair.
Posit precision tapers. posit<16,2> has 11 fraction bits for magnitudes between 1/16 and 16, and fewer further out: 9 near 2000. Move far from the origin (view ±4000) and compare its error with binary16’s, whose relative precision is the same across its normal range.
How the arithmetic is done
Section titled “How the arithmetic is done”The page holds every value as a JavaScript double and rounds each operation’s result once to the chosen format. For formats of 16 bits or fewer, that gives the correctly rounded result: rounding twice is harmless when the wider format has at least significand bits, and a double has 53. Posits are rounded in their encoding, as the posit standard requires: never to zero, and values beyond the largest posit go to it.
The arithmetic is in docs-site/src/components/gh/. It is checked by
npm test in docs-site/ against test vectors that
tools/givens_householder_svg.py computes in exact rational arithmetic, the
same code that draws the figures. The vectors cover rounding, square roots,
both forms of the rotation, the reflector and eight steps of the drift figure,
in ten formats.
The operation sequences follow MTL5:
- Rotation, from
include/mtl/operation/givens.hpp: , , , and . The scaled variant divides and by before squaring. - Reflector, from
include/mtl/operation/householder.hpp, for : scale by ; Parlett’s for ; ; ; and the identity fallbacks described above. It is applied as .