Hyb Error: A Hybrid Metric Combining Absolute and Relative Errors
Peichen Xie
TL;DR
This work introduces Hyb Error, a single error metric defined by $\mathrm{HybErr}(x,y)=\frac{|x-y|}{1+|y|}$ that blends absolute and relative errors. By showing HybErr is the half-harmonic-mean of the absolute and relative errors, the authors demonstrate how the metric interpolates between absolute error for small $|y|$ and relative error for large $|y|$, while remaining well-defined at $y=0$ and aligning with the isclose criterion. The paper extends this metric to vectors and sequences via HybErr for vectors, Mean Hyb Error (MHE), and Maximum Element-wise Hyb Error (MEHE), arguing that these measures retain the advantageous properties of HybErr for high- and low-magnitude components. A worked example illustrates that HybErr avoids the exaggerations inherent to pure absolute or relative errors and that MEHE effectively captures the maximum perturbation consistent with the HybErr framework. Overall, HybErr offers a practical, robust error metric for numerical analysis with clear connections to standard tolerance checks.
Abstract
Suppose $x$ is an approximation of $y$. This paper proposes using $\frac{|x-y|}{1+|y|}$, named Hyb Error, to measure the error. This metric equals half the harmonic mean of absolute error and relative error, effectively combining their advantages while mitigating their limitations. For example, Hyb Error approaches absolute error as $|y|$ approaches 0, thereby avoiding the exaggeration of relative error, and approaches relative error as $|y|$ approaches infinity, thereby avoiding the exaggeration of absolute error. The Hyb Error of $ε$ is equivalent to $|x-y|=ε+ε|y|$, which implies $\mathrm{isclose}(x,y,ε,ε)=\mathrm{True}$, where ``isclose'' is a common floating-point equality check function in numerical libraries. For sequences, this property makes the Maximum Element-wise Hyb Error (MEHE) a pragmatic error metric that reflects the most significant error and equals the decision boundary of the ``isclose'' function.
