$a$ and $b$ are the floating point representation of two real numbers with no constraints (they can be both negative or both positive or one positive and the other negative and so on).
I read in the Armadillo codebase, a linear algebra library, that the "robust" mean of the two $a$ and $b$ is computed as $a+\frac{b-a}{2}$ and not as the (naïve) $\frac{a+b}{2}$.
I imagine that it is more robust for what regard the overflow that it can happen when $a$ and $b$ are similar to half the largest representable value; moreover I feel that if $a\approx b$ then the cancellation error incurring in their subtraction will not be a problem.
But, how one can rigorously prove these intuitions?
INT_MAX = 2147483647
(or any maximum integer allowed) when calculatinga+b
. $\endgroup$ – VIVID Aug 5 '20 at 12:35