CERN openlab notes

CERN openlab · Project note

What happens when you let the rounding vary?

A program can print ten digits even when some depend on a rounding choice made several operations earlier. During my openlab project, I used CADNA to vary those choices and see how much the answer moved. The output looks considerably less self-assured once you give it a second opinion.

Try it with five significant digits

Subtract 1.23454 from 1.23456. The exact difference is 0.00002. If you first round both inputs to five significant digits, you subtract 1.2345 from 1.2346 and get 0.0001. If you round both inputs down to that precision, you get zero. Both calculations start from the same values. The difference is small enough that changing how you round the inputs changes the answer considerably.

That example uses decimal arithmetic to make the cancellation visible. In a real program, rounding happens in binary and can accumulate over a long chain of operations. CADNA runs several copies of the arithmetic with different rounding choices and uses the spread of the results to estimate how many significant digits are stable under those perturbations. CADNA for C and C++.

What to do when a number moves

In PEPPER I looked for rounding sensitivity in matrix elements and event weights. When a weight moves, intermediate values help locate where the two calculations first diverge. It could be a subtraction of nearly equal numbers or a threshold that sends the calculation down a different branch.

Read a warning as a pointer to an operation. One event can raise several, and the estimate of stable digits describes that calculation under those test conditions. For the physics check, compare the overall rate and the regions of the distribution that the analysis uses.