Catastrophic Cancellation — Naive versus Stable Formulas (.csv)
Five computations done twice, once with the obvious formula and once with the numerically stable one, with the relative error of the naive version alongside. The one-pass variance row is the memorable one: five values a millisecond apart near 1e8 can produce a negative variance.
case,a,b,naive_result,stable_result,relative_error_of_naive,technique
1e+16 - 9999999999999998.0,1e+16,9999999999999998.0,2.0,2.0,0,direct subtraction of near-equal values
1.0 - 0.999999999999,1.0,0.999999999999,9.999778782798785e-13,9.999778782798785e-13,0,direct subtraction of near-equal values
100000000.0 - 99999999.9999,100000000.0,99999999.9999,0.00010000169277191162,0.00010000169277191162,0,direct subtraction of near-equal values
"quadratic small root, b=1e8",100000000.0,1.0,-7.450580596923828e-09,-1e-08,2.549e-01,use 2c / (-b - sqrt(disc)) instead of (-b + sqrt(disc)) / 2a
variance of 5 values near 1e8,100000000.001,100000000.005,2.0,1.9999902249434596e-06,1.000e+06,two-pass variance instead of E[x^2] - E[x]^2
Specifications
- Rows
- 5
- Columns
- 7
- Cases
- near-equal subtraction, quadratic small root, one-pass variance
- Worst Relative Error
- the one-pass variance row
- Naive Variance Result
- 2.0
- Stable Variance Result
- 1.9999902249434596e-06
Testing contract
Reference control- Scenario
- Implement both the naive and the stable formula for each row and compare your two results with the columns here.
- Expected result
- Your stable results match stable_result to full double precision while the naive quadratic root and one-pass variance rows show relative errors of order 1e-1 or worse.
What is a .csv file?
CSV (Comma-Separated Values) is a plain-text tabular format where rows are lines and fields are separated by commas, with quoting rules for values that contain delimiters, quotes, or newlines. It has no formal type system and depends on encoding and dialect conventions. It is the most portable format for tabular data exchange.
How to use this file
Use an example CSV to test parsers against quoting and embedded-delimiter edge cases, header handling, encoding detection, and import pipelines into databases or spreadsheets.
How to use this file for testing
“Catastrophic Cancellation — Naive versus Stable Formulas (.csv)” is a deterministic Novus Examples fixture for Scientific data, CSV parsing, Editor testing. Citation catalogs (BibTeX, RIS), chemistry structures (MDL Molfile, PDB), and gridded binary data (NetCDF, FITS) — for testing reference managers, molecule viewers, and scientific-data loaders.
Documented properties for this file: 5 rows · 7 columns. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.
Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.
Scientific fixtures are small, valid, and fully synthetic — no real organism, patient, sample, or observation. Point your parser or loader at the file and check it reads the documented records, variables, or headers; binary formats ship a readable twin or metadata listing for comparison.
Code examples
import pandas as pd
df = pd.read_csv("catastrophic-cancellation.csv")
print(df.head())
print(df.dtypes)Related files
- csvCalibration Certificate — Error and Expanded Uncertainty (.csv)Five calibration points with the nominal value, the measured value, the signed error and the expanded uncertainty at k=2 with its confidence level stated. It is a synthetic illustration of the layout, not an accredited certificate, and nothing in it refers to a real instrument or laboratory.

- csvCensored Values and Detection Limits — Non-Numeric Results (.csv)Nine laboratory results where only four are plain numbers: two are below the detection limit, one is above range, two are missing in different spellings, and one is a legitimate small negative near the blank. Coercing the censored strings to numbers or to NaN both bias the summary, and the file distinguishes every case explicitly.

- csvGUM-Style Uncertainty Budget — Sources Combined in Quadrature (.csv)A five-source uncertainty budget laid out the way the GUM prescribes: each source with its distribution, its divisor, its sensitivity coefficient and its contribution, then the combined and expanded values. Rectangular sources are divided by the square root of three, which is the step budget spreadsheets most often get wrong.

- csvInterlaboratory Comparison — z-Scores and En Numbers (.csv)Six fictional laboratories reporting the same measurand, scored both by z-score against a fixed sigma and by En number against each lab's own claimed uncertainty. The two statistics disagree about which labs are acceptable, which is the point: En rewards an honest uncertainty claim and z does not.

- csvSignificant Figures Lost to Float Parsing (.csv)Eight written measurements where the trailing zeros carry the precision of the measurement, alongside what a float parse leaves behind. Parsing 1.200 to the double 1.2 is not a rounding error, it is the loss of the claim that the value is known to four figures.

- csvSpectrometer Absorbance With Expanded Uncertainty (.csv)A synthetic absorbance scan from 400 to 630 nm with a Gaussian band at 520 nm, carrying its expanded uncertainty at k=2 in a dedicated column and a per-row quality flag. The unit and the coverage factor live in the column names, which is the convention most instrument exports actually use.

Generated by generation/scientific.py. Free for any use, no attribution required — license.