# Why does relative error give number of correct digits?

I learnt that if the relative error is 5*$10^{-s}$ then the number of correct digits the result has $s$. Why is this so? Can you illustrate with an example and/or a proof?

Another way to put it appears to be that $n$ correct digits means a relative error with order of $10^{-n}$. Is it a definition?

• For example, 3.142 is said to have three correct decimals when the true value is 3.1416. Commented Aug 10, 2012 at 6:43

## 1 Answer

Let y be a real number whose expansion is given by $$y = \pm(0.d_{1}d_{2}d_{3}...d_{k}d_{k+1}...)_{\beta}\times\beta^{e}$$ with $d_{1}\neq 0$ and $m\le e\le M$ where $\beta$ = the base, $k$ = the number of digits in the base $\beta$ expansion, $m$ = the minimum exponent and $M$ = the maximum exponent, and let $fl(y)$ be the floating point equivalent of y. When the number chopped, the floating point equivalent is given by $$fl_{chop}(y) = \pm(0.d_{1}d_{2}d_{3}...d_{k})_{\beta}\times\beta^{e}$$ when the number is rounded, $$fl_{round}(y)=\pm(0.d_{1}d_{2}d_{3}...d_{k})_{\beta}\times\beta^{e}\qquad for \qquad d_{k+1}<\frac{\beta}{2}$$ $$fl_{round}(y)=\pm[(0.d_{1}d_{2}d_{3}...d_{k})_{\beta}+\beta^{-k}]\times\beta^{e}\qquad for \qquad d_{k+1} \ge \frac{\beta}{2}$$ We have $$|fl_{chop}(y)-y|=(0.d_{k+1}d_{k+2}d_{k+3}...)_{\beta}\times\beta^{e-k}\le(1.0)_{\beta}\times\beta^{e-k}=\beta^{e-k}$$ also $$|y|=(0.d_{1}d_{2}d_{3}...)_{\beta}\times\beta^{e}\ge(0.1)_{\beta}\times\beta^{e}=\beta^{e-1}$$ therefore $$\frac{|fl_{chop}(y)-y|}{|y|}\leq \frac{\beta^{e-k}}{\beta^{e-1}}=\beta^{1-k}$$ By proceeding in a similar manner, it can be shown that when a number is rounded, the bounds on both the absolute and relative error due to roundoff are one-half the bounds obtained when a number is chopped. That is $$|fl_{round}(y)-y|\le \frac{1}{2} \beta^{e-k}$$ and $$\frac{|fl_{round}(y)-y|}{|y|}\le \frac{1}{2} \beta^{1-k}$$ Now we are ready to the following definition,

Definition. Suppose that $x\neq 0$ and that $$\beta^{-(t+1)}<\frac{|x-y|}{|x|}\le \beta^{-t}$$ for some positive integer $t$. Then we say that $x$ and $y$ agree to at least $t$ and at most $t+1$ SIGNIFICANT base $\beta$ DIGITS.

Source: A Friendly Introduction to Numerical Analysis by Brian Bradie.