Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Chapter 1: Error Analysis

2022

1/22
(UNIMAS) Chapter 1: Error Analysis 2022 1 / 22
Outline

1 Measuring Errors
True Error
Relative True Error
Approximate Error
Relative Approximate Error
Significant Digits

2 Sources of Error
Round-O↵ Error
Truncation Error

2/22
(UNIMAS) Chapter 1: Error Analysis 2022 2 / 22
True Error

In any numerical analysis, errors will arise during the calculations.


To be able to deal with the issue of errors, we need to
I identify where the error is coming from, followed by
I quantifying the error, and lastly
I minimize the error as per our needs.
In this chapter, we will concentrate on how to quantify errors.
error
~ true

True error denoted by Et is the di↵erence between the true value


(a.k.a. the exact value) and the approximate value.

True Error = True Value Approximate Value

3/22
(UNIMAS) Chapter 1: Error Analysis 2022 3 / 22
True Error

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

f (x + h) f (x)
f 0 (x) ⇡ .
h
For f (x) = 7e 0.5x and h = 0.3, find
(a) the approximate value of f 0 (2)
(b) the true value of f 0 (2)
(c) the true error for part (a)

4/22
(UNIMAS) Chapter 1: Error Analysis 2022 4 / 22
True Error
Solution:
(a)

f (x + h) f (x)
f 0 (x) ⇡
h
f (2 + 0.3) f (2) 7e 0.5(2.3) 7e 0.5(2)
f 0 (2) ⇡ =
0.3 0.3
22.107 19.028
= = 10.2646
0.3
(b) The exact value of f 0 (2) can be calculated by using our
knowledge of di↵erential calculus.

f (x) = 7e 0.5x
f 0 (x) = 7(0.5)e 0.5x = 3.5e 0.5x ) f 0 (2) = 3.5e 0.5(2) = 9.5140
5/22
(UNIMAS) Chapter 1: Error Analysis 2022 5 / 22
True Error

(c)

True Error, Et = True Value Approximate Value


= 9.5140 10.2646
= 0.75061

6/22
(UNIMAS) Chapter 1: Error Analysis 2022 6 / 22
Relative True Error

The magnitude of true error does not show how bad the error is.
This brings us to the definition of relative true error.
relative .

Relative true error is denoted by "t and is defined as the ratio


between the true error and the true value.
True Error
Relative True Error =
True Value
True Value Approximate Value
=
True Value

7/22
(UNIMAS) Chapter 1: Error Analysis 2022 7 / 22
Relative True Error
Example
The derivative of a function f (x) at a particular value of x can be
approximately calculated by

f (x + h) f (x)
f 0 (x) ⇡ .
h
For f (x) = 7e 0.5x and h = 0.3, find the relative true error at x = 2.

Solution:
True Value Approximate Value 0.75061
"t = =
True Value 9.5140
= 0.078895/ 7.8895%

Absolute relative true errors may also need to be calculated


|"t | = | 0.078895| = 0.078895 = 7.8895%
8/22
(UNIMAS) Chapter 1: Error Analysis 2022 8 / 22
Approximate Error
Previously, we discussed how to calculate true errors. Such errors are
calculated only if true values are known.

But mostly we will not have the luxury of knowing true values as why
would you want to find the approximate values if you 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.

Approximate error is denoted by Ea and is defined as the di↵erence


approximate
'

between the present approximation and previous approximation.

Approximate Error = Present Approximation Previous Approximation

9/22
(UNIMAS) Chapter 1: Error Analysis 2022 9 / 22
Approximate Error

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

f (x + h) f (x)
f 0 (x) ⇡ .
h
For f (x) = 7e 0.5x and at x = 2, find
(a) f 0 (2) using h = 0.3
(b) f 0 (2) using h = 0.15
(c) approximate error for the value of f 0 (2) for part (b)

10/22
(UNIMAS) Chapter 1: Error Analysis 2022 10 / 22
Approximate Error
Solution:
(a)

f (2 + 0.3) f (2) 7e 0.5(2.3) 7e 0.5(2)


f 0 (2) ⇡ =
0.3 0.3
22.107 19.028
= = 10.265.
0.3
(b)

f (2 + 0.15) f (2) 7e 0.5(2.15) 7e 0.5(2)


f 0 (2) ⇡ =
0.15 0.15
20.50 19.028
= = 9.8799.
0.15
(c)

Ea == Present Approximation Previous Approximation


= 9.8799 10.265 = 0.38474
11/22
(UNIMAS) Chapter 1: Error Analysis 2022 11 / 22
Relative Approximate Error

The magnitude of approximate error does not show how bad the
error is. This brings us to the definition of relative approximate
error.
Relative approximate error is denoted by "a and is defined as the
ratio between the approximate error and the present
approximation.
Approximate Error
Relative Approximate Error =
Present Approximation

12/22
(UNIMAS) Chapter 1: Error Analysis 2022 12 / 22
keeping 4,5, 6 decimal point
Relative Approximate Error
Example
The derivative of a function f (x) at a particular value of x can be
approximately calculated by

f (x + h) f (x)
f 0 (x) ⇡ .
h
For f (x) = 7e 0.5x , find the relative approximate error in calculating f 0 (2)
using vlaues from h = 0.3 and h = 0.15.

Solution:
Approximate Value 0.3874
"a = =
Present Approximation 9.8799
= 0.038942/ 3.8942%
Absolute relative approximate errors may also need to be calculated,
|"a | = | 0.038942| = 0.038942 = 3.8942% 13/22
(UNIMAS) Chapter 1: Error Analysis 2022 13 / 22
Relative Approximate Error
In a numerical method that uses iterative methods, a user can
calculate relative approximate error "a at the end of each
iteration.
The user may pre-specify a minimum acceptable tolerance called
the pre-specified tolerance, "s .
If the absolute relative approximate error "a is less than or equal
to the pre-specified tolerance "s , i.e. |"a |  "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, |"a |  0.5 ⇥ 102 m %.
14/22
(UNIMAS) Chapter 1: Error Analysis 2022 14 / 22
Relative Approximate Error
Example
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: / Maclaurin series

x x2
e =1+x + + ···
2!
Using 6 terms, we get the current approximation as
0.72 0.73 0.74 0.75
e 0.7 = 1 + 0.7 + + + + = 2.0136
2! 3! 4! 5!
Using 5 terms, we get the previous approximation as
0.72 0.73 0.74
e 0.7 = 1 + 0.7 + + + = 2.0122
2! 3! 4!
15/22
(UNIMAS) Chapter 1: Error Analysis 2022 15 / 22
Relative Approximate Error

The percentage absolute relative approximation error is

2.0136 2.0122
|"a | = ⇥ 100% = 0.069527%
2.0136

Since 0.5 ⇥ 102 3 %  |"a |  0.5 ⇥ 102 2 %, at least 2 significant


digits are correct in the answer of e 0.7 ⇡ 2.0136.
I
" } % %
0,5×10 ≤ 0.069527 Yo ≤ 0.5 ✗ 102-2
% ≤ 0106952790
'
≤ 0.5%
-

0.5×10

0.05 % ≤ 0.0695277 .
≤ 0.5%
16/22
(UNIMAS) Chapter 1: Error Analysis 2022 16 / 22
Significant Digits

Example
0.0459 has three significant digits
4.590 has four significant digits
4008 has four significant digits
4008.0 has five significant digits
1.079 ⇥ 103 has four significant digits
1.0790 ⇥ 103 has five significant digits
1.07900 ⇥ 103 has six significant digits

17/22
(UNIMAS) Chapter 1: Error Analysis 2022 17 / 22
Sources of Error
Error in solving an engineering or science problem can arise due
to several factors.
First, the error may be in the modeling technique. A
mathematical model may be based on using assumptions that
are not acceptable. For example, one may assume that the drag
force on a car is proportional to the velocity of the car, but
actually, it is proportional to the square of the velocity of the
car. This itself can create huge errors in determining the
performance of the car, no matter how accurate the numerical
methods you may use are.
Second, errors may arise from mistakes in programs themselves
or in the measurement of physical quantities. But, in
applications of numerical methods itself, the two errors we need
to focus on are
I Round o↵ error
I Truncation error. 18/22
(UNIMAS) Chapter 1: Error Analysis 2022 18 / 22
Round-O↵ Error

A computer can only represent a number approximately.


1
For example, a number like may be represented as 0.333333
3
on a PC. Then the round o↵ error in this case is
1
0.333333 = 0.00000033̄
3
There are otherpnumbers that cannot be represented exactly. For
example,⇡ and 2 are numbers that need to be approximated in
computer calculations.

19/22
(UNIMAS) Chapter 1: Error Analysis 2022 19 / 22
Truncation Error
Truncation error is defined as the error caused by truncating a
mathematical procedure. For example, the Maclaurin series for
e x is given as
x2 x3
ex = 1 + x + + + ··· .
2! 3!
This series has an infinite number of terms but when using this
series to calculate e x , only a finite number of terms can be
used. For example, if one uses three terms to calculate e x , then
x x2
e =1+x + .
2!
The truncation error for such an approximation is
✓ ◆
x x2 x3 x4
truncation error = e 1+x + = + + ··· .
2! 3! 4!
20/22
(UNIMAS) Chapter 1: Error Analysis 2022 20 / 22
Truncation Error

But, how can truncation error be controlled in this example? We


can use the concept of relative approximate error to see how
many terms need to be considered.
Assume that one is calculating e 1.2 using the Maclaurin series,
then
1.22 1.23
e 1.2 = 1 + 1.2 + + + ··· .
2! 3!
Let us assume one wants the absolute relative approximate error
to be less than 1%.
The next table shows the value of e 1.2 , approximate error and
absolute relative approximate error as a function of the number
of terms, n.

21/22
(UNIMAS) Chapter 1: Error Analysis 2022 21 / 22
Truncation Error

n e 1.2 Ea |"a |%
1 1 - -
2 2.2 1.2 54.546
3 2.92 0.72 24.658
4 3.208 0.288 8.9776
5 3.2944 0.0864 2.6226
6 3.3151 0.020736 0.62550

Using 6 terms of the series yields a |"a | < 1%.

22/22
(UNIMAS) Chapter 1: Error Analysis 2022 22 / 22

You might also like