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.
Which of these reports state their evidence honestly? (Choose all that apply.)
- A."With seed 7, NumPy 1.26.4 and samples, our Monte Carlo estimate is (95% confidence interval)."
- B."We checked the conjecture for all ; it is therefore true."
- C."Interval arithmetic with outward rounding shows ."
- 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.
In IEEE double precision (), let
x = 1e16. What does(x + 1) - xevaluate to? - 3.
In double precision,
1 - math.cos(1e-8)evaluates to0.0, although . Which explanation is correct?- A.
math.cos(1e-8)is correctly rounded to1.0, because doubles next to are about 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.
- A.
- 4.
Theorem 2 bounds the error of recursive summation by , not by . Why can the bound not be improved to a multiple of ?
- A.Because of cancellation: the exact sum can be 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 might all have the same sign.
- 5.
Using interval multiplication, compute . What is the lower endpoint of the result?
- 6.
A program you do not trust outputs: , with certificate , . What can you conclude?
- A.The claim is proved: , and divides both and .
- 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 is a common divisor.
- 7.
In the Lean module,
fsum x δ nis the floating-point recursive sum ofx 0, …, x nwith 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
- A.
- 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.txtsayingnumpy>=1.20and 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.
Implement Kahan's compensated summation
kahan_sum(xs). Keep a running sumsand a compensationcfor the low-order bits lost so far: for eachx, sety = x - c,t = s + y,c = (t - s) - y,s = t. The tests compare your result with the exact rational sum.Computational — Practice