Chapter 01.02: Quantifying Errors

Lesson: True Error

Learning Objectives

After successful completion of this lesson, you should be able to:

1)  enumerate reasons why we need to measure errors

2)  find the true and relative true error

  

Introduction

In any numerical analysis, errors will arise during the calculations. To be able to deal with the issue of errors, we

(A) identify where the error is coming from, followed by

(B) quantify the error, and lastly

(C) minimize the error as per our needs.

In this lesson, we concentrate on item (B) called quantifying the error, and specifically the true error.

  

What is true error?

True error denoted by \(E_{t}\) is the difference between the true value (also called the exact value) and the approximate value.

\[E_{t}= \text{True value} - \text{Approximate value} \;\;\;\;\;\;\;\;\;\;\;\; (1)\]

  

Example 1

The derivative of a function \(f(x)\) at a particular value of \(x\) can be approximately calculated by

\[\displaystyle f^{\prime}(x) \approx \frac{f(x + h) - f(x)}{h}\]

For \(\displaystyle f(x) = 7e^{0.5x}\) and \(h = 0.3\), find

a)  the approximate value of \(f^{\prime}(2)\)

b)  the true value of \(f^{\prime}(2)\)

c)  the true error for part (a)

Solution

a) \[\displaystyle f^{\prime}(x) \approx \frac{f(x + h) - f(x)}{h}\]

For\(\ x = 2\) and \(h = 0.3\),

\[\displaystyle \begin{split} f^{\prime}(2) &\approx\frac{f(2 + 0.3) - f(2)}{0.3}\\ &= \frac{f(2.3) - f(2)}{0.3}\\ &= \frac{7e^{0.5(2.3)} - 7e^{0.5(2)}}{0.3}\\ &= \frac{22.107 - 19.028}{0.3}\\ &= 10.263 \end{split}\]

b) The exact value of \(f^{\prime}(2)\) can be calculated by using our knowledge of differential calculus.

\[f(x)\ = 7e^{0.5x}\]

\[\begin{split} f^{\prime}(x) &= 7 \times 0.5 \times e^{0.5x}\\ &= 3.5e^{0.5x} \end{split}\]

So the true value of \(f^{\prime}(2)\) is

\[\begin{split} f^{\prime}(2) &= 3.5e^{0.5(2)}\\ &= 9.5140\end{split}\]

c) True error is calculated as

\[\begin{split} E_{t} &= \text{True value} - \text{Approximate value}\\ &= 9.5140 - 10.263\\ &=- 0.749\end{split}\]

  

The magnitude of true error does not show how bad the error is. A true error of \(E_{t} = - 0.749\) may seem to be small, but if the function given in Example 1 were \(\displaystyle f(x) = 7 \times 10^{- 6}e^{0.5x},\) the true error in calculating \(f^{\prime}(2)\) with \(h = 0.3,\) would be \(E_{t} = - 0.749 \times 10^{- 6}.\) This value of true error is smaller, even when the two problems are similar in that they use the same value of the function argument, \(x = 2\), and the step size, \(h = 0.3\). This recognition brings us to the definition of the relative true error.

  

What is the relative true error?

Relative true error is denoted by \(\epsilon_{t}\) and is defined as the ratio between the true error and the true value.

\[\epsilon_{t} = \frac{\text{True Error}}{\text{True Value}} \;\;\;\;\;\;\;\;\;\;\;\; (2)\]

  

Example 2

The derivative of a function \(f(x)\) at a particular value of \(x\) can be approximately calculated by

\[\displaystyle f^{\prime}(x) \approx \frac{f(x + h) - f(x)}{h}\]

For \(f(x) = 7e^{0.5x}\) and \(h = 0.3\), find the relative true error in finding \(f^\prime(2)\).

Solution

From Example 1,

\[\begin{split} E_{t}&= \text{True value} - \text{Approximate value}\\ &= 9.5140 - 10.263\\ &= - 0.749\end{split}\]

Relative true error is calculated as

\[\begin{split} \displaystyle \epsilon_{t} &= \frac{\text{True Error}}{\text{True Value}}\\ &= \frac{- 0.749}{9.5140}\\ &= - 0.078726\end{split}\]

Relative true errors are also presented as percentages. For this example,

\[\begin{split} \epsilon_{t} &= - 0.078726 \times 100\% \\&= - 7.8726\% \end{split}\]

Absolute relative true errors may also need to be calculated. In such cases,

\[\begin{split} \left| \epsilon_{t} \right| &= | - 0.078726|\\ &= 0.078726\\ &= 7.8726\% \end{split}\]

Lesson: Approximate Errors

Learning Objectives

After successful completion of this lesson, you should be able to:

1)  Calculate the approximate error,

2)  Calculate relative approximate error.

  

Introduction

In any numerical analysis, errors will arise during the calculations. To be able to deal with the issue of errors, we need to

(A) identify where the error is coming from, followed by

(B) quantifying the error, and lastly

(C) minimize the error as per our needs.

In this section of the chapter, we concentrate on item (B) called quantifying the error, and specifically approximate error.

  

What is approximate error?

In the previous lesson, we discussed how to calculate true errors. Such errors are calculated only if true values are known. An example where calculating true errors would be useful is when one is checking if a program is in working order, and you know some examples where the true error is known. But mostly, we will not have the luxury of knowing true values as to why would you want to find the approximate values when you already know the true values. So when we are solving a problem numerically, we will only have access to approximate values. We need to know how to quantify error for such cases, and such an error is appropriately called the approximate error.

Approximate error is denoted by \(E_{a}\), and is defined as the difference between the present approximation and the previous approximation.

\[E_{a} = \text{Present Approximation} - \text{Previous Approximation} \;\;\;\;\;\;\;\;\;\;\;\; (1)\]

  

Example 1

The derivative of a function \(f(x)\) at a particular value of \(x\) can be approximately calculated by

\[\displaystyle f^{\prime}(x) \approx \frac{f(x + h) - f(x)}{h}\]

For \(f(x) = 7e^{0.5x}\) and at \(x = 2\), find the following

a)  \(f^{\prime}(2)\) using \(h = 0.3\)

b)  \(f^{\prime}(2)\) using \(h = 0.15\)

c)  approximate error for the value of \(f^{\prime}(2)\) for part (b)

Solution

The approximate expression for the derivative of a function is

\[\displaystyle f^{\prime}(x) \approx \frac{f(x + h) - f(x)}{h}\]

a) For \(x = 2\) and \(h = 0.3\),

\[\begin{split} \displaystyle f^{\prime}(2) &\approx \frac{f(2 + 0.3) - f(2)}{0.3}\\ &=\frac{f(2.3) - f(2)}{0.3}\\ &= \frac{7e^{0.5(2.3)} - 7e^{0.5(2)}}{0.3}\\ &= \frac{22.107 - 19.028}{0.3}\\ &= 10.263\end{split}\]

b)  Repeating the procedure of part (a) with \(h = 0.15\)

\[\displaystyle f^{\prime}(x) \approx \frac{f(x + h) - f(x)}{h}\]

For \(x = 2\) and \(h = 0.15\),

\[\begin{split} \displaystyle f^{\prime}(2) &\approx \frac{f(2 + 0.15) - f(2)}{0.15}\\ &= \frac{f(2.15) - f(2)}{0.15}\\ &= \frac{7e^{0.5(2.15)} - 7e^{0.5(2)}}{0.15}\\ &= \frac{20.510 - 19.028}{0.15}\\ &= 9.8800\end{split}\]

c)  So the approximate error, \(E_{a}\) is

\[\begin{split} E_{a} &= \text{Present Approximation} - \text{Previous Approximation}\\ &= 9.8800 - 10.263\\ &= - 0.38300 \end{split}\]

  

The magnitude of approximate error does not reflect how bad the error is. An approximate error of \(E_{a} = - 0.38300\) in the above example may seem to be small, but repeating the above example for \(f(x) = 7 \times 10^{- 6}e^{0.5x}\), the approximate error in calculating \(f^{\prime}(2)\) with \(h = 0.15\) would be \(E_{a} = - 0.38300 \times 10^{- 6}\). This value of approximate error is much smaller, even when the two problems are similar in that they use the same value of the function argument, \(x = 2\), and step sizes of \(h = 0.15\) and \(h = 0.3\). This recognition brings us to the definition of the relative approximate error in the next lesson.

  

What is the relative approximate error?

As observed in the previous lesson, approximate errors generally do not reflect how bad or acceptable an error is. We hence define the relative approximate error, denoted by \(\epsilon_{a}\) as the ratio between the approximate error and the present approximation.

\[\displaystyle \epsilon_{a} = \frac{\text{Approximate Error}}{\text{Present Approximation}} \;\;\;\;\;\;\;\;\;\;\;\; (2)\]

where

\[\text{Approximate Error, }E_{a} = \text{Current Approximation} - \text{Previous Approximation}\]

  

Example 2

The derivative of a function \(f(x)\) at a particular value of \(x\) can be approximately calculated by

\[\displaystyle f^{\prime}(x) \approx \frac{f(x + h) - f(x)}{h}\]

For \(f(x) = 7e^{0.5x}\), find the relative approximate error in calculating \(f^{\prime}(2)\) using values from \(h = 0.3\) and \(h = 0.15\).

Solution

From Example 1, the following values are already calculated

\[f^{\prime}(2) \approx 10.263 \text{ using } h = 0.3 \text{ and}\]

\[f^{\prime}(2) \approx 9.8800 \text{ using } h = 0.15.\]

Hence the approximate error

\[\begin{split} E_{a} &= \text{Present Approximation} - \text{Previous Approximation}\\ &= 9.8800 - 10.263\\ &= - 0.38300\end{split}\]

The relative approximate error is calculated as

\[\begin{split} \epsilon_{a} &= \frac{\text{Approximate Error}}{\text{Present Approximation}}\\ &= \frac{- 0.38300}{9.8800}\\ &= - 0.038765\end{split}\]

Relative approximate errors are also can be presented as percentages. For this example,

\[\begin{split} \epsilon_{a} &= - 0.038765 \times 100\%\\ &= - 3.8765\%\end{split}\]

Absolute relative approximate errors may also need to be calculated. In this example

\[\begin{split} \left| \epsilon_{a} \right| &= \ | - 0.038765|\\ &= 0.038765\end{split}\]

Absolute relative approximate errors also can be presented as percentages. For this example,

\[\begin{split} \left| \epsilon_{a} \right| &= 0.038765 \times 100\%\\ &= 3.8765\%\end{split}\]

Lesson: Review of Significant Digits

Learning Objectives

After successful completion of this lesson, you should be able to:

1)  identify how many significant digits a number has, whether given in decimal or scientific format.

  

What do we mean by significant digits?

Significant digits (also called significant figures) are the digits that are known reliably in a reported number.

Let us take an example. You may be asked to give your answer up to a certain number of decimal places. This fixed representation may bode well for items such as US currency, where one is generally interested in 2 decimal places to represent dollars as the integer part and cents as the fractional part. However, in engineering and science calculations, this can create issues. For example, the thermal expansion coefficient of steel at room temperature is \(6.47\ \mu \text{in/in/}^{\circ}\text{F}\) when given up to 2 decimal places. Changing the units of this property of steel to USCS of units, one would write it as \(0.00000647\ \text{in/in/}^{\circ}\text{F}\), and if we were writing the value up to 2 decimal places, it would be written as \(0.00\ \text{in/in/}^{\circ}\text{F}\). Hence, the emphasis in engineering is to write the numbers mostly in the scientific format as it represents the numbers with the proper number of significant digits. The number \(0.00000647\ \text{in/in/}^{\circ}\text{F}\) would be written as \(6.47 \times 10^{- 6}\ \text{in/in/}^{\circ}\text{F}\) with 3 significant digits, while \(6.47\ \mu \text{in/in/}^{\circ}\text{F}\) would be written as \(6.47 \times 10^{0}\ \mu \text{in/in/}^{\circ}\text{F}\) with 3 significant digits.

  

Let’s take another example. If someone asked me what the population of my county is, I would respond, “The population of the Hillsborough County in Florida, USA is \(1,500,000\) (1.5 million).” But if I were going to give \(100\) dollars to every citizen of the county, I would have to find an exact count or at least a census estimate. That count was \(1,471,968\) in the year \(2019\). So, you can see in my statement that the population is \(1.5\) million, and there are only two significant digits. In the statement that the population is \(1,471,968\) there are seven significant digits. So, how do we differentiate the number of digits correct in \(1,500,000\) and \(1,471,968\) if no context was given? Well, for that, one uses scientific notation. For our data, we write as

\[{1,500,000 = 1.5 \times 10^{6} }\]

\[{1,471,968 = 1.471968 \times 10^{6}}\]

to signify the correct number of significant digits in the two numbers that represent the same variable.

  

Example

Give examples to illustrate all the rules of how many significant digits are in a given number.

Solution

\(2.789\) has four significant digits as all nonzero digits are significant.

\(0.0439\) has three significant digits as zeros to the left of the first nonzero number are not significant.

\(4.590\) has four significant digits as all zeros to the right of a decimal point are significant.

\(4008\) has four significant digits as any zero between nonzero digits is significant.

\(4208.07\) has six significant digits as any zero between nonzero digits is significant.

\(4008.0\) has five significant digits as all zeros to the right of a decimal point are significant.

\(4000.0\) has five significant digits as all zeros to the right of a decimal point are significant.

\(15000.0\) has six significant digits as all zeros to the right of a decimal point are significant.

\(15000\) may represent 2, 3, 4, or 5 significant digits. Such vagueness can be addressed by using the scientific (also called floating point) format as given below.

\(1.5 \times 10^{3}\) has two significant digits.

\(1.50 \times 10^{3}\) has three significant digits.

\(1.5000 \times 10^{4}\) has five significant digits.

An exact number has an infinite number of significant digits. If you have \(5\) books in your school bag, then the number can be written with an infinite number of trailing zeros as \(5.000...\)

Lesson: Relationship Between Significant Digits Correct and Relative Approximate Error

Learning Objectives

After successful completion of this lesson, you should be able to:

1)  Relate the absolute relative approximate error to the number of significant digits at least correct in your answer.

  

While solving a mathematical model using numerical methods, how can we use the value of relative approximate error to figure out if we have achieved an acceptable answer?

In a numerical method that uses iterative methods, a user can calculate relative approximate error \(\epsilon_{a}\) at the end of each iteration. The user may pre-specify a minimum acceptable tolerance called the pre-specified tolerance, \(\epsilon_{s}\). If the absolute relative approximate error \(|\epsilon_{a}|\) is less than or equal to the pre-specified tolerance \(\epsilon_{s}\), that is, \({|\epsilon_{a}| \leq \epsilon}_{s}\), then the acceptable error has been reached and no more iterations would be required.

Alternatively, one may pre-specify how many significant digits they would like to be correct in their answer. In that case, if one wants at least \(m\) significant digits to be correct in the answer, then you would need to have the absolute relative approximate error, \(| \epsilon_{a}| \leq 0.5 \times 10^{2 - m}\%\).

  

Example 1

If one chooses 6 terms of the Maclaurin series for \(e^{x}\) to calculate \(e^{0.7}\), how many significant digits can you trust in the solution? Find your answer without knowing or using the exact answer.

Solution

The Maclaurin series for \(e^{x}\) is given by

\[\displaystyle e^{x} = 1 + x + \frac{x^{2}}{2!} + ................. \;\;\;\;\;\;\;\;\;\;\;\; (E1.1)\]

Using 6 terms in Equation (E1.1), we get the current approximation as

\[\begin{split} \displaystyle e^{0.7} &\cong 1 + 0.7 + \frac{0.7^{2}}{2!} + \frac{0.7^{3}}{3!} + \frac{0.7^{4}}{4!} + \frac{0.7^{5}}{5!}\\ &= 2.0136\end{split}\]

Using 5 terms in Equation (E1.1), we get the previous approximation as

\[\begin{split} \displaystyle e^{0.7} &\cong 1 + 0.7 + \frac{0.7^{2}}{2!} + \frac{0.7^{3}}{3!} + \frac{0.7^{4}}{4!}\\ &= 2.0122\end{split}\]

The percentage absolute relative approximate error is

\[\begin{split} \displaystyle \left| \epsilon_{a} \right| &= \left| \frac{\text{Current Approximation - Previous Approximation}}{\text{Present Approximation}} \right| \times 100\\ &= \left| \frac{2.0136 - 2.0122}{2.0136} \right| \times 100\\ &= 0.069527\% \end{split}\]

At least m significant digits are expected to be correct when absolute relative approximate error, \(\left| \epsilon_{a} \right| \leq 0.5 \times 10^{2 - m}\%\). Since \(\left| \epsilon_{a} \right| \leq 0.5 \times 10^{2 - 2}\%=0.5\%\), but \(\left| \epsilon_{a} \right| \geq 0.5 \times 10^{2 - 3}\%=0.05\%\), at least 2 significant digits are correct.

The answer is \(2\) significant digits are at least correct in the estimated value

\[e^{0.7} \approx 2.0136\]

Alternatively, to find the least number of significant digits correct in the answer, \(\left| \epsilon_{a} \right| \leq 0.5 \times 10^{2 - 2}\%\)

\[0.069527 \ \leq\ 0.5 \times 10^{2 - m}\]

\[\displaystyle\frac{0.069527}{0.5}\ \leq \ 10^{2 - m}\]

\[0.1391\ \leq \ \ 10^{2 - m}\]

\[\log_{10}\left( 0.1391 \right)\ \leq \ \log_{10}(10^{2 - m})\]

\[- 0.8567 \leq 2 - m\]

\[m \leq 2.8567\]

Hence \(2\) significant digits are at least correct in the estimated value

\[e^{0.7} \approx 2.0136\]

Multiple Choice Test

(1). True error is defined as

(A)  Present Approximation – Previous Approximation

(B)  True Value – Approximate Value

(C)  abs (True Value – Approximate Value)

(D)  abs (Present Approximation – Previous Approximation)

 

(2). The expression for true error in calculating the derivative of \(\sin\left( 2x \right)\) at \(x=\displaystyle \frac{\pi}{4}\) by using the approximate expression \(\displaystyle f^{\prime}\left( x \right) \approx \frac{f\left( x + h \right) - f\left( x \right)}{h}\) is

(A)  \(\displaystyle \frac{h - \cos\left( 2h \right) - 1}{h}\)

(B)  \(\displaystyle \frac{h - \cos\left( h \right) - 1}{h}\)

(C)  \(\displaystyle \frac{1 - \cos\left( 2h \right)}{h}\)

(D)  \(\displaystyle \frac{\sin\left( 2h \right)}{h}\)

 

(3). The relative approximate error at the end of an iteration to find the root of an equation is \(0.004\%\). The least number of significant digits we can trust in the solution is

(A) \(2\)

(B) \(3\)

(C) \(4\)

(D) \(5\)

 

(4). The number \(0.01850 \times 10^{3}\) has ________ significant digits

(A) \(3\)

(B) \(4\)

(C) \(5\)

(D) \(6\)

 

(5). The following gas stations were cited for irregular dispensation by the Department of Agriculture. Which one cheated you the most relatively?

Station Actual Gasoline dispensed Gasoline Reading at pump

Ser

Cit

Hus

She

\(9.90\)

\(19.90\)

\(29.80\)

\(29.95\)

\(10.00\)

\(20.00\)

\(30.00\)

\(30.00\)

(A) Ser

(B) Cit

(C) Hus

(D) She

 

(6). The number of significant digits in the number \(219900\) is

(A) \(4\)

(B) \(5\)

(C) \(6\)

(D) \(4\) or \(5\) or \(6\)

  

For complete solution, go to

http://nm.mathforcollege.com/mcquizzes/01aae/quiz_01aae_measuringerror_answers.pdf

Problem Set

(1). The trigonometric function \(\sin(x)\) can be calculated by using the following infinite series

\[\sin(x) = x - \frac{x^{3}}{3!} + \frac{x^{5}}{5!} - \frac{x^{7}}{7!} + ......\]

a)  What is the value of \(\sin(2.17)\) by using the first three terms in the given series?

b)  What is the value of \(\sin(2.17)\) by using the first four terms in the given series?

c)  Use your calculator for the true value of \(\sin(2.17)\)?

d)  What is the true error for the answer in part (a)?

e)  What is the absolute true error for the answer in part (a)?

f)  What is the relative true error for the answer in part (a)?

g)  What is the absolute relative true error for the answer in part (a)?

h)  What is the approximate error for the answer in part (b)?

i)  What is the absolute approximate error for the answer in part (b)?

j)  What is the relative approximate error for the answer in part (b)?

k)  What is the absolute relative approximate error for the answer in part (b)?

l)  Assume that you do not know the exact value of \(\sin(2.17)\), how many significant digits are at least correct if you use four terms in the series?

m)  What should be the pre-specified relative error tolerance if at least 4 significant digits are required to be correct in calculating \(\sin(2.17)\)?

Answer: \(a)\ 0.8679\ \ b)\ 0.8229\ \ c)\ 0.8257\ \ d)\ -0.04213\ \ e)\ 0.04213\)
\(f)\ -5.102\%\ \ g)\ 5.102\% h)\ -0.04495\ \ i)\ 0.04495\ \ j)\ -5.462\ \ k)\ 5.462\ \ l)\ 0\ \ m)\ 0.005%\)

  

(2).  A Maclaurin series for a function is given by

\[f(x) = x - \frac{x^{3}}{3!} + \frac{x^{5}}{5!} + ......\]

What is the absolute relative approximate error if three terms are used for calculating \(f(1.2)\)?

Answer: \(0.0221\ \text{or}\ 2.21\%\)

  

(3). A Maclaurin series for a function is given by

\[f(x) = x - \frac{x^{3}}{3!} + \frac{x^{5}}{5!} + ......\]

How many terms should be used in the series to consider that at least 2 significant digits are correct in your answer for \(f(0.1)\)?

Answer: \(2\)

  

(4).  A gas station owned by Valdez gives you \(9.90\) gallons of gasoline when you actually paid for \(9.95\) gallons. Another gas station owned by Hessup gives you \(19.80\) gallons of gasoline when you actually paid for \(19.85\) gallons of gasoline. If you only had these two gas stations available in your town, which one would you go to next time you had to fill up your car? Use the concepts learned in measuring errors to justify your answer.

Answer: \(\text{Hessup}\)

  

(5).  The function \(e^{x}\) can be calculated by using the following infinite Maclaurin series

\[e^{x} = 1 + x + \frac{x^{2}}{2!} + \frac{x^{3}}{3!} + \frac{x^{4}}{4!} + ........\]

a)  Use 5 terms to calculate the value of \(e^{0.9}\)?

b)  How many significant digits in my calculation would be correct if I use 5 terms?

c)  How do I know that I have used enough terms to calculate \(e^{0.9}\), if I pre-specify a tolerance of \(0.05\%\)? What is the minimum number of terms I should use to achieve the pre-specified tolerance?

d) Where are the sources of error coming from in the above series?

Answer: \(a)\ 2.4538\ \ b)\ 1\ \ c)\ 7\ \ d)\ \text{mainly truncation, but round-off error is there also.}\)

  

(6). How many significant digits are correct in the following numbers

a) \(185000\)

b)  \(0.0185\)

c)  \(1.0185\)

d) \(185 \times 10^{3}\)

e) \(1850 \times 10^{2}\)

f) \(0.01850 \times 10^{5}\)

g) \(0.0185 \times 10^{5}\)

h) \(100.00\)

i) \(100.001\)

Answer: \(a)\ 3\ \text{or}\ 4\ \text{or}\ 5\ \text{or}\ 6\ \ b)\ 3\ \ c)\ 5\ \ d)\ 3\ \ e)\ 4\ \ f)\ 4\ \ g)\ 3\ \ h)\ 5\ \ i)\ 6\)

  

(7). What is the correct normalized scientific notation for \(0.029411765\) with 4 significant digits?

Answer: \(2.941 \times 10^{-2}\)