Justification for the definition of relative error, why is it not a metric?

129 Views Asked by At

The absolute error and relative error operators are very commonly encountered while reading about topics from the fields of floating-point arithmetics or approximation theory.

Absolute error is ${ae(a, b)} = {\left\lvert{a - b}\right\rvert}$, where the first argument, $a$, is an approximation of the second argument, $b$.

Relative error is ${re(a, b)} = {\left\lvert{1 - \frac{a}{b}}\right\rvert}$, where the first argument, $a$, is an approximation of the second argument, $b$.

Interestingly, relative error loses the symmetry apparent in the definition of absolute error. I can tell that this has something to do with putting more weight on the accurate value than on its approximation, however I wonder about a clearer explanation.

Mark S. noted below that the definition of relative error follows if we take "relative error" to be short for "absolute error relative to the magnitude of $b$". But this still doesn't show why would this particular description or definition be desirable compared to other possible definitions.

One thing I've noticed is that this simple function behaves very similarly to relative error, but is symmetric: ${f(a, b)} = {\left\lvert{ln{\left(\frac{a}{b}\right)}}\right\rvert} = {ae{\left(ln{\left(a\right)}, ln{\left(b\right)}\right)}}$. How appropriate is it as an alternative definition of relative error?

The symmetric function $f$ is, sadly, not defined when $a$ and $b$ are of opposite sign. For example, for $a = 0.1$ and $b = -0.1$, the relative error takes the value of two, but $f$ is undefined. I'm not sure if $f$ can be appropriately extended, but, in any case, this doesn't seem too important, as such huge values of relative error can usually be special-cased.

EDIT: this plot of floating-point round-to-nearest rounding "error" from $\frac{1}{2}$ to $9$, for a floating-point format with a three-bit significand, might be interesting:

precision 3

Relative error is red, while the symmetric function $f$ is blue. So it seems that $f$ results in slightly higher maximal rounding "errors", but the two functions nonetheless behave very alike. This discrepancy seems to vanish as the significand grows in length, though; this is a similar plot for 16-bit floating-point precision (the two functions line up perfectly):

precision 16