You are on page 1of 37

Komputasi Numerik

Lecture 2: Roundoff and Truncation Errors

ENEE604020 – 2 SKS
Dr. Aries Subiantoro
aries.Subiantoro@ui.ac.id

DTE
ko m n u m
(1) Errors

(2) Round-off Errors

(3) Truncation Errors

Outline
Sources
Presentation based on material from:
• Chapra chapter 4

3 Departemen Teknik Elektro FTUI


Accuracy and Precision

• Accuracy, how close is a computed or measured value to the


true value
• Precision (or reproducibility), how close is a computed or
measured value to previously computed or measured values.
• Inaccuracy (or bias), a systematic deviation from the actual
value.
• Imprecision (or uncertainty), magnitude of scatter.

4 2/15/2022 Departemen Teknik Elektro FTUI


Accuracy and Precision

(a) inaccurate and imprecise

(b) accurate and imprecise

(c) inaccurate and precise

(d) accurate and precise

5 2/15/2022 Departemen Teknik Elektro FTUI


Errors
ERRORS
• The errors associated with both calculations and measurements can be characterized
with regard to their accuracy and precision

True value = approximation + error


Et = true value − approximation
Et : the exact value of the error the true error is commonly expressed as an absolute
subscript t : true value value and referred to as the absolute error

• Normalize the error to the true value:

True fractional relative error = true value − approximation


true value
• The true percent relative error:

εt = true value − approximation


true value
x100%

7
Approximate Error
• E and ε are subscripted with a t to signify that the error is based on the true value

• However, in actual situations such information is rarely available. The error is


normalized to an approximate value

• Percent relative error

8
Iterative Computation
• When performing computations, we may not be concerned with the sign of the error
but are interested in whether the absolute value of the percent relative error is lower
than a prespecified tolerance εs
• The computation is repeated until :

• The result is correct to at least n significant figures:

9
Significant Figures
• Number of significant figures indicates precision. Significant digits of a number are those
that can be used with confidence, e.g., the number of certain digits plus one estimated
digit.

53,800 How many significant figures?

5.38 x 104 3
5.380 x 104 4
5.3800 x 104 5

• Zeros are sometimes used to locate the decimal point not significant figures.

0.00001753 4
0.0001753 4
0.001753 4

10
Example

11
Example

12
Round-off Errors
ROUNDOFF ERRORS
• Roundoff errors arise because digital computers cannot represent some quantities
exactly
• In certain cases, they can actually lead to a calculation going unstable and yielding
obviously erroneous results, called ill-conditioned

There are two major facets of roundoff errors involved in numerical


calculations:
1. Digital computers have magnitude and precision limits on their ability to
represent numbers.
2. Certain numerical manipulations are highly sensitive to roundoff errors.
This can result from both mathematical considerations as well as from
the way in which computers perform arithmetic operations.

14
Round-off Errors
• Numbers such as p, e, or 7 cannot be expressed by a fixed number of significant
figures.
• Computers use a base-2 representation, they cannot precisely represent certain exact
base-10 numbers.
• Fractional quantities are typically represented in computer using “floating point” form,
e.g.,

Integer part
exponent
s x be
mantissa
Base of the number system used

15
Number Base

Integer representation
Range of integer number on a 16-bit
computer -32,768 to +32,767

16
Floating Point Representation

floating-point number is stored in an 8-byte word in IEEE double


precision format

17
Round-Off Errors
156.78  0.15678x103 in a floating point base-10 system
• Suppose only 4 decimal places to be stored
1
 0.029411765
34
1
0.0294 10 0  m 1
10
• Normalized to remove the leading zeroes. Multiply the mantissa by 10
and lower the exponent by 1
0.2941 x 10-1
Additional significant figure
is retained
18
Round-Off Errors
• Therefore
for a base-10 system 0.1 ≤ m <1
for a base-2 system 0.5 ≤ m <1
• Floating point representation allows both fractions and very large
numbers to be expressed on the computer. However,
• Floating point numbers take up more room
• Take longer to process than integer numbers.
• Round-off errors are introduced because mantissa holds only a finite
number of significant figures

19
Chopping
• Example: p=3.14159265358 to be stored on a base-10 system carrying 7
significant digits.
P = 3.141592 chopping error et=0.00000065
If rounded
P = 3.141593 et=0.00000035
• Some machines use chopping, because rounding adds to the
computational overhead. Since number of significant figures is large
enough, resulting chopping error is negligible.

20
20
Truncation Errors
Truncation Errors: The Taylor Series

f  xi 1   f xi  
x df

x 
2
d2 f

x 
n
dn f

1! dx xi 2! dx 2 xi
n! dx n xi

Zero-order approximation

f  xi 1   f xi 
First-order approximation

x df
f  xi 1   f  xi  
1! dx xi
22
Truncation Errors: Example
3 5 7 9
Taylor’s series expansion: sin( x)  x  x x x x
   
3! 5! 7! 9!
 
The exact value: sin    0.5
6

  
The Zero-order approximation; sin     0.5235988
6 6

The truncation error: E TR  0.5  0.5235988  0.0235988

23
Truncation Errors: Example
x3 x5 x7 x9
Taylor’s series expansion: sin( x)  x     
3! 5! 7! 9!

  
The exact value: sin    0.5
6

 
The first-order approximation; sin     
 6
  0.4996742
 6  6  3! 

The truncation error: E TR  0.5  0.4996742  0.0003258

24
The Taylor Series
• nth order approximation
f 
f ( xi 1 )  f ( xi )  f ( xi )( xi 1  xi )  ( xi 1  xi ) 2  
2!
f (n)
 ( xi 1  xi ) n  Rn
n!
(xi+1-xi)= h step size (define first)
f ( n1) (e ) ( n1)
Rn  h
(n  1)!
• Reminder term Rn accounts for all terms from (n+1) to infinity.
25
The Taylor Series

approximation
f x   0.1x 4  0.15 x 3  0.5 x 2  0.25 x  1.2
26
The Taylor Series
• e is not known exactly, lies somewhere between xi+1 > e > xi .
• Need to determine fn+1(x), to do this you need f'(x).
• If we knew f(x), there wouldn’t be any need to perform the Taylor series
expansion.
• However, R = O(hn+1), (n+1)th order, the order of truncation error is hn+1.
• O(h), halving the step size will halve the error.
• O(h2), halving the step size will quarter the error.

27
The Remainder for the Taylor Series Expansion

28
The Remainder for the Taylor Series Expansion

29
29
Example

Page 97
problem 4.5.
Determine
truncation
errors

30
Example

31
Example II

Page 87-
Example 4.4
problem 4.5.

32
32
Finite Differencing

33 2/15/2022 Optimality criteria Line search methods One variable minimization Trust region methods Gradient & Hessian
Example II

Page 87-
Example 4.4
problem 4.5.

34
34
Example II

35
35
Homework

• Chapra chapter 4 nomor: 4.1, 4.13, 4.19


• Platform pengumpulan tugas: Sistem EMAS
• Deadline: Senin, 21 Febuari 2022, pukul 08.00 WIB
• Format file PDF: [NPM]_[Nama]_[Tugas #1]
• Tugas presentasi pekan depan:
• Kelompok I: soal 4.13
• Kelompok II: soal 4.19

DTE
ko m n u m
36
Terima Kasih

37

You might also like