Loss of Significant Digits Error

# Loss of Significant Digits Error

If we do calculations that contain a fixed number of significant digits, then there is a possibility that we could incur some error based on the loss of significant digits.

For example, suppose that consider the following function for $x > 0$:

(1)
\begin{align} f(x) = \log_{10} (x + 1) - \log_{10} (x) \end{align}

And suppose that we compute this function with $5$ significant digits of accuracy. Let's see what happens as we plug in some values to this function. Notice that if $x = 9$, then we get that $\log_{10} (9 + 1) = \log_{10} = 1.0000$, while $\log_{10} (9) = 0.95424$, once again to reiterate, both of these calculations are correct to five significant digits. We then compute their difference to get $f(9)$, that is:

(2)
\begin{align} \quad f(9) = \log_{10} (10) - \log_{10} (9) = 0.045760 = 4.4760 \cdot 10^{-2} \end{align}

Now the question becomes whether or not $f(9)$ is correct to five significant digits. In this particular case, it is not. In fact, the true value that carries $5$ significant digits is $0.045757 = 4.5757 \cdot 10^{-2}$. Notice that in evaluating $\log_{10} (10) - \log_{10} (9)$, we have lost two significant digits of accuracy. In fact, for larger values of $x$, we begin to lose more and more significant digits.

For example, now suppose that $x = 999$. Then we have that $\log_{10} (999 + 1) = \log_{10} (1000) = 3$, while $\log_{10} (999) = 2.9995$ (again, both of these computations are correct to $5$ significant digits) and so in computing their difference we get that:

(3)
\begin{align} \quad \log_{10} (1000) - \log_{10} (999) = 0.00050000 = 5.0000 \cdot 10^{-4} \end{align}

However, the true value of $f(999)$ correct to five significant digits is $0.00043451 = 4.3451 \cdot 10^{-4}$, so in this particular example, we have lost all significant digits in our computation, and in fact, we have incurred a steep relative error of about $15%$!

The loss of accuracy surmounts to the type of calculations we used and the number of significant digits our calculations are limited to. In general, when dealing with extremely small calculations that are subtracted from one another then there will often be a few significant digits lost if we aren't careful. Fortunately, we can sometimes rewrite or express equations differently so that the loss of error is minimal by either using series approximations, getting rid of explicit subtraction, etc…

Once again, take a look at our example $f(x) = \log_{10} (x + 1) - \log_{10} (x)$. Using logarithm rules, we can nicely combine the two "separate" parts of our function, $\log_{10} (x + 1)$ and $- \log_{10} (x)$ into one as:

(4)
\begin{align} \quad f(x) = \log_{10} (x + 1) + \log_{10} (x) = \log_{10} \left ( \frac{x + 1}{x} \right ) = \log_{10} \left ( 1 + \frac{1}{x} \right ) \end{align}

Now let's see if our rewritten formula yields less error. For $x = 999$, we have that $\frac{1} + \frac{1}{999} = 1.0010$ to $5$ significant digits and so $\log_{10} \left ( 1 + \frac{1}{9} \right ) = \log_{10} \left (1.0010 \right) = 0.00043407 = 4.3407 \cdot 10^{-4}$. Now our relative error from the true value $4.3451 \cdot 10^{-4}$ is only about $0.1%$ which is a huge improvement.