Chapter 1 Scientific Computing 1.Computer Arithmetic (1.3) 2.Approximation in Scientific Computing (1.2) January 7
Floating-Point Number System (FPNS) Mantissa Exponent Fraction
Examples 54 In base-10 system as 54 = (5 + 4/10) x 10 1 = 5.4 x 10 1 mantissa = 5.4, fraction = 0.4, exponent = 1 In base-2 system 54 = ( 0 + 1x x x x x2 5 ) = ( ) = ( 1 + 1/ (2 1 ) + 0/(2 2 ) + 1/(2 3 ) + 1/(2 4 ) + 0/(2 5 )) x 2 5 mantissa = , fraction = , exponent=5
Normalization 54 = ( 1 + 1/ (2 1 ) + 0/(2 2 ) + 1/(2 3 ) + 1/(2 4 ) + 0/(2 5 )) x 2 5 = x 32 (normalized) = ( 0 + 1/(2 1 ) + 1/(2 2 )+ 0/(2 3 ) + 1/(2 4 ) + 1/(2 5 )+0/(2 6 ) ) x 2 6 (not normalized)
There are = 254 possible exponent values How to represent zero?
OFL = when all d 0, …, d p-1 = beta - 1 Underflow level Overflow level
What are the 25 numbers?
Online Demo at
Absolute and Relative Errors Example Approximate with 4.3x10 has absolute error = relative error =approx=
Floating-Point Arithmetics
Cancellation
For example: with base = 10, p =3. Take x= 23115, y = 23090, there difference of 25 is comparatively much smaller than either x or y (using chopping) what is the difference x-y in this FPNS?
Quadratic Formula If the coefficients are too large or too small, overflow and underflow could occur. Overflow can be avoided by scaling the coefficients. Cancellation between –b and square root can be avoid by using
Example (pages 26-27) Take ( base = 10, p=4) a= , b=-98.78, c=5.015 The correct roots (to ten significant digits) , b 2 -4ac = 9756, its square-root is The computed roots using standard formula 1972, Using the second formula 1003,