Detect (catastrophic) cancellation in sums

476 Views Asked by At

In finite precision arithmetic, what are ways to detect (catastrophic) cancellation when adding $N\in\mathbb{N}$ numbers?

Example ($N=2$): When adding two numbers $a$ and $b$ the result $a+b$ might be inaccurate due to cancellation if $a\approx -b$, which can be verified by checking if $|1+\frac{a}{b}| < \varepsilon$ for a sufficiently small $\varepsilon>0$.

Is it similarly possible to check if the result of adding $N\ge 3$ numbers in any given order is likely to be inaccurate?

1

There are 1 best solutions below

0
On BEST ANSWER

To get a rough estimate, compare the sum $S = \sum a_i$ with sum of the absolute values $A = \sum |a_i|$ or the maximum $M=\mathrm{max}\; |a_i|,$ i.e. look at the quotients $A/|S|$ or $M/|S|.$ You can get a more accurarate sum and better estimates, if you use compensated summation algorithms like Kahan summation.