0% found this document useful (0 votes)
319 views15 pages

1.2 Round Off Errors and Computer Arithmetic

This document discusses round-off errors that occur in computer arithmetic. It explains that numbers are stored using a binary system with a fixed number of bits, so common real numbers like pi cannot be represented exactly. This leads to round-off error in calculations. The document also describes the IEEE 754 standard for floating-point numbers, which specifies formats and algorithms. Examples are given to show how a real number is represented in a 64-bit floating-point format and how calculations can introduce round-off errors. Methods for measuring absolute and relative errors from rounding are also mentioned.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
319 views15 pages

1.2 Round Off Errors and Computer Arithmetic

This document discusses round-off errors that occur in computer arithmetic. It explains that numbers are stored using a binary system with a fixed number of bits, so common real numbers like pi cannot be represented exactly. This leads to round-off error in calculations. The document also describes the IEEE 754 standard for floating-point numbers, which specifies formats and algorithms. Examples are given to show how a real number is represented in a 64-bit floating-point format and how calculations can introduce round-off errors. Methods for measuring absolute and relative errors from rounding are also mentioned.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Sec:1.

Round-off Errors
and Computer
Arithmetic
Sec:1.2 Round-off Errors and Computer Arithmetic

The purpose of this section is to study how errors in


numbers can propagate through mathematical functions.

  2 Why?
Example:
( √ 19 ) =¿ round-off errors are directly related to the manner
in which numbers are stored in a computer.

 * Numbers such as π, e, or cannot be expressed by


a fixed number of significant figures
*numbers on the computer are represented with a
binary, or base-2, system.

 
*binary system 
floating point numbers

Error = 0.000000000000004
>> format short
  relative error = >> pi
3.1416
>> format long
>> pi
3.141592653589793
Sec:1.2 Round-off Errors and Computer Arithmetic

Binary Machine Numbers A 64-bit (binary digit) representation


(floating-point number)
s c f
In a computer, only a relatively small subset of
the real number system is used for the Example:
representation of all the real numbers. 0 10000000011 1011100100010000000000000000000000000000000000000000

1st 11-bit 52-bit


Real line
−∞
  ⋯  −𝟐
  −𝟏
  𝟎  𝟏  𝟐  ⋯  +∞
  sign characteristic mantissa

exponent fraction
In 1985, the IEEE (Institute for Electrical and Electronic
Engineers) published a report called Binary Floating
Example:
Point Arithmetic Standard 754–1985.
0 10000000011 1011100100010000000000000000000000000000000000000000

This provides standards for binary and decimal floating


point numbers, formats for data interchange, algorithms for  
¿(− 𝟏)𝒔 𝟐𝒄 −𝟏𝟎𝟐𝟑 (𝟏+ 𝒇 )
rounding arithmetic operations, and for the handling of
exceptions.
10000000011
single, double, precisions
𝒄=1 ∙ 210 + 0∙ 29 + ⋯+1∙ 21 +1∙ 20
 
𝒄=1024 +0 +⋯ ⋯ ⋯ +2 +1
 
𝒄=1027
 
Sec:1.2 Round-off Errors and Computer Arithmetic

A 64-bit (binary digit) representation


11-bit exponent
c
10000000011 s f
11-bit 52-bit
sign exponent fraction
𝒄=1 ∙ 210 + 0∙ 29 + ⋯ +1∙ 21 +1∙ 20
 
Example:
𝒄=1024 +0 +⋯ ⋯ ⋯ +2 +1
  0 10000000011 1011100100010000000000000000000000000000000000000000

𝒄=𝟏𝟎𝟐𝟕 𝟏)𝒔 𝟐𝒄 −𝟏𝟎𝟐𝟑 (𝟏+ 𝒇 )


   
¿(−

52-bit fraction
1011100100010000000000000000000000000000000000000000 
1 3 4 5 8 12
1 1 1 1 1 1
𝒇  =1 ∙( ) +1 ∙( ) +1∙ ( ) +1 ∙( ) +1∙( ) +1 ∙ ( )
2 2 2 2 2 2
1 1 1 1 1 1
𝒇  = + +
2 8 16 32 256 4096¿ 𝟎 .𝟕𝟐𝟐𝟗𝟎𝟎𝟑𝟗𝟎𝟔𝟐𝟓
+ + +  

0 10000000011 1011100100010000000000000000000000000000000000000000 S=0 c = 1027


𝒔 𝒄 −𝟏𝟎𝟐𝟑 𝑓 =𝟎 . 𝟕𝟐𝟐𝟗𝟎𝟎𝟑𝟗𝟎𝟔𝟐𝟓
 ¿(− 𝟏) 𝟐 (𝟏+ 𝒇 )
 ¿(− 𝟏)𝟎 × 𝟐𝟏𝟎𝟐𝟕 −𝟏𝟎𝟐𝟑 × (𝟏+ 𝟎 .𝟕𝟐𝟐𝟗𝟎𝟎𝟑𝟗𝟎𝟔𝟐𝟓 )

¿  𝟐𝟕 . 𝟓𝟔𝟔𝟒𝟎𝟔𝟐𝟓
Sec:1.2 Round-off Errors and Computer Arithmetic

Example: (similar to 15a/29)

Use the 64-bit long real format to find the decimal equivalent of the following floating-
point machine number.

0 01111111110 1001001100000000000000000000000000000000000000000000

S=0

c = 2^9+2^8+2^7+2^6+2^5+2^4+2^3+2^2+2^1= 1022

  𝟏+ 𝟏 + 𝟏 + 𝟏
𝟏 𝟒 𝟕 𝟖
𝟏 𝟏 𝟏 𝟏
𝒇  =( ) +( ) +( ) +( ) ¿ = 0.57421875
𝟐 𝟐 𝟐 𝟐 𝟐 𝟏𝟔 𝟏𝟐𝟖 𝟐𝟓𝟔

0 01111111110 1001001100000000000000000000000000000000000000000000

 ¿(− 𝟏)𝟎 × 𝟐𝟏𝟎 𝟐𝟐− 𝟏𝟎𝟐𝟑 × (𝟏+ 𝟎. 𝟓𝟕𝟒𝟐𝟏𝟖𝟕𝟓 ) ¿


  𝟎 .𝟕𝟖𝟕𝟏𝟎𝟗𝟑𝟕𝟓

Example:
1 01111111110 1001001100000000000000000000000000000000000000000000
  −𝟎 . 𝟕𝟖𝟕𝟏𝟎𝟗𝟑𝟕𝟓
 ¿(− 𝟏)𝟏 × 𝟐𝟏𝟎 𝟐𝟐−𝟏𝟎𝟐𝟑 × (𝟏+𝟎 . 𝟓𝟕𝟒𝟐𝟏𝟖𝟕𝟓 ) ¿
Sec:1.2 Round-off Errors and Computer Arithmetic

Largest floating point

0 11111111111 1111111111111111111111111111111111111111111111111111
S=0 c = 2046 𝒇  =𝟏 − 𝟐− 𝟓𝟐

𝒏𝒖𝒎𝒃𝒆𝒓
  =(− 𝟏)𝟎 × 𝟐𝟐𝟎𝟒𝟔 −𝟏𝟎𝟐𝟑 × (𝟐 − 𝟐− 𝟓𝟐 ) = 0.1797693134862316e+309

>> 2^1023*(2-2^(-52))
1.797693134862316e+308

>>2^1024-2^971
Inf

Numbers greater than 𝟐𝟏𝟎𝟐𝟑 × (𝟐− 𝟐−𝟓𝟐 )


 
result in overflow (Inf)
Sec:1.2 Round-off Errors and Computer Arithmetic

smallest normalized positive number

S=0 c=1  𝒇 =𝟎

𝟎 𝟏− 𝟏𝟎𝟐𝟑
 𝒏𝒖𝒎𝒃𝒆𝒓 =(− 𝟏 ) × 𝟐 ×(𝟏 +𝟎 ) = 2.225073858507201e-308

Numbers occurring in calculations


that have a magnitude less than
− 𝟏𝟎𝟐 𝟐
 𝟐 × (𝟏 +𝟎 )

result in underflow and are generally


set to zero
Sec:1.2 Round-off Errors and Computer Arithmetic
𝟐𝟕.𝟓𝟔𝟔𝟒𝟎𝟔𝟐𝟓
 
0

𝑥 ∗

0 10000000011 1011100100010000000000000000000000000000000000000000

the next largest machine number

0 10000000011 1011100100010000000000000000000000000000000000000001

any real number in the interval  

Is represented by the real number 𝟐𝟕


  . 𝟓𝟔𝟔𝟒𝟎𝟔𝟐𝟓

𝟐𝟕 .𝟓𝟔𝟔𝟒𝟎𝟔𝟐𝟓+ 𝒙 ∗
  =¿27.5664062500000017763568394002504646778106689453125
𝟐
Sec:1.2 Round-off Errors and Computer Arithmetic

Decimal Machine Numbers Binary Machine Numbers


we assume that machine numbers are
(floating-point number)
represented in the normalized decimal
floating-point form s c f

Example:
5-digit decimal machine numbers

Example:
The floating-point form of y, denoted
fl(y), is obtained by terminating the   y = π = 0.314159265 . . . × .
mantissa of y at k decimal digits.
two common ways of termination chopping   fl(y) = 0.31415 ×
chopping
rounding   fl(y) = 0.31416 ×
rounding
Sec:1.2 Round-off Errors and Computer Arithmetic

Example: Example:

  y = π = 0.314159265 . . . × . Determine the absolute and relative errors

chopping   fl(y) = 0.31415 × chopping

rounding   fl(y) = 0.31416 × rounding

two methods for measuring approximation errors

Remark As a measure of accuracy, the absolute error can be misleading and


the relative error more meaningful, because the relative error takes into
consideration the size of the value.

significant digits
(or figures)
Sec:1.2 Round-off Errors and Computer Arithmetic

significant digits
(or figures)

Example:
Determine the significant digits

 𝑝=0.1 𝑝  ∗=0.10005

 0.00005 =0.0005 ≤5 ×10 −4


0.1

Example:
Determine the significant digits

 𝑝=5000 𝑝  ∗=5002.4

  2.4 =0.00048=4.8 ×10− 4 ≤5 ×10 −4


5000
Sec:1.2 Round-off Errors and Computer Arithmetic

Finite-Digit Arithmetic Source of round-off error:


number repersentations, arithmetic operations

Example:  represent machine addition, subtraction,


multiplication, and division operations
x ⊕ y = fl(fl(x) + fl(y)),

Example:
Suppose
  that x = and y =
Use five-digit chopping for calculating x + y

 x =   fl(x) = 0.71428 ×
 y =   fl(y) = 0.33333 ×

  x ⊕ y = fl(0.71428 × + 0.33333 × ),
  number 1.0476× is said to approximate to
The
  = fl(1.04761× )= 1.0476× 4 significant digits
Sec:1.2 Round-off Errors and Computer Arithmetic

Nested Arithmetic round-off error can also be reduced by


rearranging calculations
Example: 𝑓  ( 𝑥 )=¿
Evaluate f (x) at x = 4.71 using three-digit arithmetic.

Exact: f (4.71)= −14.263899 The relative errors

Three-digit (chopping): f (4.71) = −13.5 0.05


Three-digit (rounding): f (4.71)= −13.4 0.06

𝑓  ( 𝑥 )=¿

Three-digit (chopping): f (4.71) = −14.2 0.0045


Three-digit (rounding): f (4.71)= −14.3 0.0025

Remark The decreased error in this example is due to the reduction in computations from
four multiplications and three additions to two multiplications and three additions.
One way to reduce round-off error is to reduce the number of computations.
Polynomials should always be expressed in nested form
Sec:1.2 Round-off Errors and Computer Arithmetic
round-off error can also be reduced by
rationalizing the numerator
rearranging calculations

Example:

The relative errors Remark


0.24
1) the subtraction of nearly equal
numbers,
2) the division by small number
0.00062 (x2)

You might also like