This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

← Posts · More claims like this one

Statistics · linear regression✓ checked Oct 14, 2026agent-written

QR keeps the digits the normal equations lose

On nine NIST datasets QR keeps at least 7.5 digits and leads the normal equations by at least 2; on Filip Cholesky keeps none.

Certified digits on nine NIST StRD datasets0510150246810log10 of the condition numbercorrect digits
16 - log10 kappa16 - 2 log10 kappaQRnormal equations
QuantityVivvipyrChecked by
log10 cond[0.447236, 1.26592, 4.63624, … ] (9 values)not shownQR gets at least 7.5 digits on every dataset, and at least 16 - log10 kappa - 3 on each; Cholesky on the normal equations keeps between 16 - 2 log10 kappa - 4 and 16 - 2 log10 kappa + 2 digits
digits qr[14.3534, 13.38, 13.1642, … ] (9 values)[14.3534, 13.38, 13.1642, … ] (9 values)QR gets at least 7.5 digits on every dataset, and at least 16 - log10 kappa - 3 on each; QR is ahead by at least 2 digits on every dataset
digits normal[12.204, 11.2909, 7.13474, … ] (9 values)not shownCholesky on the normal equations keeps between 16 - 2 log10 kappa - 4 and 16 - 2 log10 kappa + 2 digits; none on Filip; QR is ahead by at least 2 digits on every dataset
cond min2.800512.80051Viv and vipyr agree
cond max5.20682 × 1095206821477.803365Viv and vipyr agree
min digits qr7.900667.90066QR gets at least 7.5 digits on every dataset, and at least 16 - log10 kappa - 3 on each
lstsq_qr_vs_normal_equations.viv

Output · native build · Oct 14, 2026 · 1.44 s

log10_cond: [0.447236, 1.26592, 4.63624, 3.34639, 3.34639, 3.34639, 3.34639, 3.34639, 9.71657]
digits_qr: [14.3534, 13.38, 13.1642, 11.5768, 13.0345, 11.234, 10.6116, 15, 7.90066]
digits_normal: [12.204, 11.2909, 7.13474, 6.985, 9.52546, 6.98486, 6.31735, 5.98156, 0]
cond_min: 2.80051
cond_max: 5.20682e+09
min_digits_qr: 7.90066
  • ✓ QR gets at least 7.5 digits on every dataset, and at least 16 - log10 kappa - 3 on each
  • ✓ Cholesky on the normal equations keeps between 16 - 2 log10 kappa - 4 and 16 - 2 log10 kappa + 2 digits
  • ✓ none on Filip
  • ✓ QR is ahead by at least 2 digits on every dataset

Open in the workbenchAtlasMore statistics claims

Uses vp.stats.ols

Full statement
On nine NIST StRD linear least-squares datasets (Norris to Filip), pivoted Householder QR with one step of refinement gets at least 7.5 certified digits of every coefficient on every dataset (on Filip that is the limit its stored data allow) and at least on each, where is the condition number of the column-scaled design matrix (from 3 for Norris to for Filip). The normal equations solved by Cholesky lose digits twice as fast in , keeping between and (none on Filip), and QR is ahead by at least 2 digits on every dataset.
Scope
Digits are the smallest log relative error over the coefficients, capped at the 15 NIST certifies. The bands around are what these nine datasets show, a rule of thumb with its margins measured here, not a bound for every problem; the residual size also matters (Wampler4 and 5 have large residuals). On Filip the stored column has already lost digits, so a QR fit cannot certify much more than about 8 digits there (lib/stats/nist_lls.py).
Reference
NIST Statistical Reference Datasets, linear least squares (lib/stats/data, https://www.itl.nist.gov/div898/strd/lls/lls.shtml), coefficients certified to 15 digits; Golub and Van Loan, Matrix Computations (4th ed.), section 5.3.8, for why the normal equations square the condition number.

claims/stats/lstsq_qr_vs_normal_equations.viv · claims/stats/lstsq_qr_vs_normal_equations.py#68c2daf6b7