chapter 1 scientific computing computer arithmetic (1.3)
DESCRIPTION
Chapter 1 Scientific Computing Computer Arithmetic (1.3) 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 - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/1.jpg)
Chapter 1Scientific Computing
1. Computer Arithmetic (1.3)2. Approximation in Scientific Computing (1.2)
January 7
![Page 2: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/2.jpg)
Floating-Point Number System (FPNS)
Mantissa Exponent
Fraction
![Page 3: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/3.jpg)
Examples54
In base-10 system as
54 = (5 + 4/10) x 101 = 5.4 x 101
mantissa = 5.4, fraction = 0.4, exponent = 1
In base-2 system
54 = ( 0 + 1x21 + 1x 22 + 0x23 + 1x24 + 1x25)
= (0 + 2 + 4 + 0 + 16 + 32 )
= ( 1 + 1/ (21) + 0/(22) + 1/(23) + 1/(24) + 0/(25)) x 25
mantissa = 1.6875, fraction = 0.6875, exponent=5
![Page 4: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/4.jpg)
![Page 5: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/5.jpg)
Normalization
54 = ( 1 + 1/ (21) + 0/(22) + 1/(23) + 1/(24) + 0/(25)) x 25
= 1.6875 x 32 (normalized) = ( 0 + 1/(21) + 1/(22)+ 0/(23) + 1/(24) + 1/(25)+0/(26) ) x 26
(not normalized)
![Page 6: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/6.jpg)
![Page 7: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/7.jpg)
There are 126+127+1 = 254 possible exponent values
How to represent zero?
![Page 8: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/8.jpg)
OFL = when all d0, …, dp-1 = beta - 1
Underflow level
Overflow level
![Page 9: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/9.jpg)
![Page 10: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/10.jpg)
What are the 25 numbers?
![Page 11: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/11.jpg)
Online Demo at
http://www.cse.illinois.edu/iem/floating_point/rounding_rules/
![Page 12: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/12.jpg)
Absolute and Relative Errors
Example
Approximate 43.552 with 4.3x10 has
absolute error = 0.552
relative error =approx= 0.01267
![Page 13: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/13.jpg)
![Page 14: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/14.jpg)
![Page 15: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/15.jpg)
![Page 16: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/16.jpg)
Floating-Point Arithmetics
![Page 17: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/17.jpg)
![Page 18: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/18.jpg)
![Page 19: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/19.jpg)
![Page 20: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/20.jpg)
![Page 21: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/21.jpg)
Cancellation
![Page 22: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/22.jpg)
Cancellation
![Page 23: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/23.jpg)
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?
![Page 24: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/24.jpg)
![Page 25: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/25.jpg)
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
![Page 26: Chapter 1 Scientific Computing Computer Arithmetic (1.3)](https://reader035.vdocument.in/reader035/viewer/2022062316/56814d52550346895dba8ca6/html5/thumbnails/26.jpg)
Example (pages 26-27)
Take ( base = 10, p=4)
a=0.05010, b=-98.78, c=5.015
The correct roots (to ten significant digits)
1971.605916, 0.05077069387
b2-4ac = 9756, its square-root is 98.77
The computed roots using standard formula
1972, 0.09980
Using the second formula
1003, 0.05077