# 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)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)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)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)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.