Back to the on-screen lesson ·

Absolute and relative error

The two ways of saying how wrong an answer is, why only one of them compares across scales, and how a relative error becomes a count of correct digits.

Paper packet. Every task here also exists on screen, where it is checked automatically; answers written on paper are not assessed by Nydus. When you are back at a device, enter your answers there.

1. What you will learn

By the end of this lesson you will be able to compute the absolute and relative error of a result, convert a relative error into a count of correct significant digits, and say which of the two to quote and why.

2. What you already know

You know that a floating-point format stores a value to a fixed number of significant bits, so the error it makes is proportional to the size of the number rather than a fixed amount. This lesson gives that idea its two names and settles which one to quote.

3. The words this lesson uses

The absolute error is $|x - \hat{x}|$, in the units of the quantity. The relative error is $\dfrac{|x - \hat{x}|}{|x|}$, a pure number. A value is correct to $k$ significant digits when its relative error is about $10^{-k}$. A bound on an error is a statement that it is no larger than something; it is not a claim about how large it actually is.

4. Absolute and relative error

There are two honest ways to say how wrong an answer is, and they answer different questions. The absolute error $|x - \hat{x}|$ answers by how much, in the units of the thing; it is what you want when the units matter — a bridge out by three centimetres. The relative error $\dfrac{|x - \hat{x}|}{|x|}$ answers by what proportion; it is what you want when you are comparing accuracies, because it means the same thing at every scale. Floating point controls the second and says nothing about the first: storing a number costs a relative error of at most $\varepsilon/2$, whether the number is a millionth or a million. The bridge between the relative error and ordinary speech is the significant digit: a relative error near $10^{-k}$ and about $k$ correct significant digits are the same statement. Errors of a product or quotient add relatively; errors of a sum or difference add absolutely, which is the crack the next lesson prises open.

Another way: steps

  1. Subtract to get the absolute error, keeping the units.
  2. Divide by the true value to get the relative error, which has none.
  3. Multiply by $100$ for a percentage, or read $10^{-k}$ as $k$ correct digits.
  4. When combining: add relative errors for products, absolute errors for sums.

Another way: example

Storing $\pi$ as $3.1416$ leaves an absolute error of about $7.3 \times 10^{-6}$ and a relative error of about $2.3 \times 10^{-6}$ — so about five and a half correct significant digits, which is what the five printed digits promised.

5. The mistake to watch for

Two answers that are out by the same amount are not equally accurate. This sounds obvious written down and is hard to hold on to in practice, because an error message reports one number and does not say which kind it is. When a tolerance is quoted with no units, it is relative; when it has units, it is absolute; and a routine that takes both is asking you to decide which matters here — near zero, where the relative error of everything is enormous, the absolute one is usually the only sane test.

6. Reporting one error three ways

  1. A true value of $1000$ is computed as $1003$, so the absolute error is $3$.

    Subtract first.

  2. The relative error is $\dfrac{3}{1000} = 0.003$, which is $0.3$ per cent.

    Divide, then scale.

  3. A relative error near $10^{-3}$ is about three correct significant digits, and indeed $1003$ agrees with $1000$ in its first three.

    The digit count is the same fact.

7. Which input limits the answer

  1. A radius is known to eight digits and a density to two; the mass needs both.

    Relative errors of a product add.

  2. The relative error of the mass is about $10^{-2}$, because the density's error swamps the radius's.

    The larger term wins.

  3. Measuring the radius to sixteen digits instead would not change the answer's accuracy at all.

    Spend the effort on the weak input.

8. Your turn: a length of $200$ measured as $199$

  1. The absolute error is $1$, in whatever units the length is in.

  2. The relative error is $\dfrac{1}{200} = 0.005$, or half a per cent.

  3. Your turn: work this step out. Its working is at the end of the packet.

    That is a relative error a little above $10^{-3}$, so between two and three correct significant digits.

9. Guided practice

A quantity whose true value is $100$ is computed as $102$. Report the error three ways.

Absolute errorRelative errorPer cent
This computation

10. Guided practice

A journey of $24$ kilometres is measured $1$ metre out, and a rod of $8$ metres is measured $1$ metre out. Which statement is right?

11. Practice

A computation has returned a value and you know the true one. Put the five steps of reporting the error to $5$ digits into the order you carry them out.

Number the steps in order (write the number in the box):

12. Practice

Match each way of reporting an error to what it is.

An absolute error, in the units of the thing measuredA relative error, written as a count of digitsA relative error, written as a proportionA relative error of at most half a machine epsilon
Out by $3$ millimetres
Correct to $7$ significant figures
Out by $3$ parts in a thousand
Rounded to the nearer stored number

13. Somewhere new

Two lengths are each known to within $1$: one is $31$ and the other is $27$. What is the largest the relative error of their difference can be? Give a fraction.

Answer:

14. Lesson test

Lesson test: one question per skill, one attempt each, no hints. Your answers are checked when you submit.

15. Test question

A value is computed with a relative error of about $10^{-10}$, and is then multiplied by a quantity known only to a relative error of $10^{-5}$. About how many correct significant decimal digits does the product have?

Answer:

16. What you can do now

You can report an error in units, in proportion and in digits, and you know which input limits the accuracy of a product. Say in your own words why two answers out by the same amount need not be equally accurate.

Working for the steps left to you

8. Your turn: a length of $200$ measured as $199$, step 3