Skip to content
The Lumenary

Each worksheet prints cleanly on A4 or Letter. Answer keys are on a separate page.

The Lumenary · First-year graduate

Computational reproducibility

Name: ______________________

Date: ______________________

You will learn to

  • Package a computation with version control, a pinned environment, tests and a single command that regenerates its results
  • Classify a computational claim as exact, numerical, statistical or experimental, and state what it does not establish
  • Prove the standard error bound for floating-point summation and use it to choose and justify tolerances
  • Turn numerical results into theorems with interval arithmetic, and make results checkable with certificates
  • Archive code and data with persistent identifiers and cite software properly
  1. 1.

    Which of these reports state their evidence honestly? (Choose all that apply.)

    • A."With seed 7, NumPy 1.26.4 and 10610^6 samples, our Monte Carlo estimate is 0.7466±0.00110.7466 \pm 0.0011 (95% confidence interval)."
    • B."We checked the conjecture for all n≤109n \le 10^9; it is therefore true."
    • C."Interval arithmetic with outward rounding shows 1.41421356<2<1.414213571.41421356 \lt \sqrt 2 \lt 1.41421357."
    • D."Our formula agrees with the computed value to 15 digits, which proves it."
    • E."Summed in double precision; the result is exact because floating point is deterministic."
  2. 2.

    In IEEE double precision (p=53p = 53), let x = 1e16. What does (x + 1) - x evaluate to?

  3. 3.

    In double precision, 1 - math.cos(1e-8) evaluates to 0.0, although 1−cos⁡(10−8)≈5×10−171 - \cos(10^{-8}) \approx 5 \times 10^{-17}. Which explanation is correct?

    • A.math.cos(1e-8) is correctly rounded to 1.0, because doubles next to 11 are about 10−1610^{-16} apart; the subtraction is then exact and reveals that earlier rounding.
    • B.Subtracting two nearly equal numbers is itself an inaccurate floating-point operation.
    • C.The library's cosine function has a bug.
    • D.No floating-point formula can compute this quantity accurately.
  4. 4.

    Theorem 2 bounds the error of recursive summation by γn∑∣xi∣\gamma_n \sum |x_i|, not by γn∣∑xi∣\gamma_n |\sum x_i|. Why can the bound not be improved to a multiple of ∣∑xi∣|\sum x_i|?

    • A.Because of cancellation: the exact sum can be 00 while the partial sums, and hence the rounding errors, are large.
    • B.Because absolute values make the proof easier, but the stronger bound is also true.
    • C.Because the bound must also hold for complex numbers.
    • D.Because the rounding errors δk\delta_k might all have the same sign.
  5. 5.

    Using interval multiplication, compute [−1,2]⋅[−1,2][-1, 2] \cdot [-1, 2]. What is the lower endpoint of the result?

  6. 6.

    A program you do not trust outputs: gcd⁡(1071,462)=21\gcd(1071, 462) = 21, with certificate x=−3x = -3, y=7y = 7. What can you conclude?

    • A.The claim is proved: 1071⋅(−3)+462⋅7=211071\cdot(-3) + 462\cdot 7 = 21, and 2121 divides both 1071=51⋅211071 = 51 \cdot 21 and 462=22⋅21462 = 22 \cdot 21.
    • B.Nothing, unless we rerun Euclid's algorithm ourselves.
    • C.The certificate is invalid, because Bézout coefficients must be positive.
    • D.The certificate only shows that 2121 is a common divisor.
  7. 7.

    In the Lean module, fsum x δ n is the floating-point recursive sum of x 0, …, x n with rounding errors δ. Which statement correctly formalises Theorem 2?

    • A.∀ u, 0 ≤ u → (∀ k, |δ k| ≤ u) → |fsum x δ n - ∑ i ∈ range (n+1), x i| ≤ ((1+u)^n - 1) * ∑ i ∈ range (n+1), |x i|
    • B.|fsum x δ n - ∑ i ∈ range (n+1), x i| ≤ ((1+u)^n - 1) * ∑ i ∈ range (n+1), |x i| with no hypothesis on δ
    • C.∀ u, 0 ≤ u → (∀ k, |δ k| ≤ u) → |fsum x δ n - ∑ i ∈ range (n+1), x i| ≤ u * |∑ i ∈ range (n+1), x i|
    • D.∃ δ, fsum x δ n = ∑ i ∈ range (n+1), x i
  8. 8.

    You want a colleague to be able to regenerate every figure of your paper in five years' time. Which is the best plan?

    • A.A versioned repository with a lock file of exact dependency versions, recorded seeds, tests, one command that rebuilds everything, and a release archived with a DOI.
    • B.A requirements.txt saying numpy>=1.20 and the notebook as it was last run.
    • C.High-resolution images of all the figures in the supplementary material.
    • D.A detailed description of the algorithms in the paper; the code is not needed.
  9. 9.

    Implement Kahan's compensated summation kahan_sum(xs). Keep a running sum s and a compensation c for the low-order bits lost so far: for each x, set y = x - c, t = s + y, c = (t - s) - y, s = t. The tests compare your result with the exact rational sum.

    Computational — Practice

Code: Apache-2.0 · Content: CC BY-SA 4.0