Introduction to Scientific Computation

Slides:



Advertisements
Similar presentations
CML CML CS 230: Computer Organization and Assembly Language Aviral Shrivastava Department of Computer Science and Engineering School of Computing and Informatics.
Advertisements

Topics covered: Floating point arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
2-1 Chapter 2 - Data Representation Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer Architecture.
Chapter 2: Data Representation
Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 2: Data Representation.
2-1 Computer Organization Part Fixed Point Numbers Using only two digits of precision for signed base 10 numbers, the range (interval between lowest.
Number Systems Lecture 02.
Binary Number Systems.
The Binary Number System
Simple Data Type Representation and conversion of numbers
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
Computer Organization and Architecture Computer Arithmetic Chapter 9.
Computer Arithmetic Nizamettin AYDIN
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Information Representation: Negative and Floating Point.
Fixed-Point Arithmetics: Part II
Computer Architecture
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles of Computer.
Data Representation - Part II. Characters A variable may not be a non-numerical type Character is the most common non- numerical type in a programming.
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
Data Representation: Floating Point for Real Numbers Computer Organization and Assembly Language: Module 11.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Fixed-point and floating-point numbers Ellen Spertus MCS 111 October 4, 2001.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Floating Point Arithmetic – Part I
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
MATH Lesson 2 Binary arithmetic.
Floating Point. Binary Fractions.
Floating Points & IEEE 754.
Floating Point Numbers
Introduction to Numerical Analysis I
Floating Point Representations
Department of Computer Science Georgia State University
Programming and Data Structure
Number Representation
Introduction To Computer Science
Computer Architecture & Operations I
2.4. Floating Point Numbers
Number Systems and Binary Arithmetic
Topics IEEE Floating Point Standard Rounding Floating Point Operations
CS 105 “Tour of the Black Holes of Computing!”
Floating Point Numbers: x 10-18
Floating Point Number system corresponding to the decimal notation
PRESENTED BY J.SARAVANAN. Introduction: Objective: To provide hardware support for floating point arithmetic. To understand how to represent floating.
William Stallings Computer Organization and Architecture 7th Edition
Topic 3d Representation of Real Numbers
Luddy Harrison CS433G Spring 2007
Number Representations
Data Representation Data Types Complements Fixed Point Representation
CS201 - Lecture 5 Floating Point
Floating Point Representation
(Part 3-Floating Point Arithmetic)
Computer Science 210 Computer Organization
Approximations and Round-Off Errors Chapter 3
ECEG-3202 Computer Architecture and Organization
COMS 361 Computer Organization
Prof. Giancarlo Succi, Ph.D., P.Eng.
CS 105 “Tour of the Black Holes of Computing!”
COMS 161 Introduction to Computing
Topic 3d Representation of Real Numbers
Numbers with fractions Could be done in pure binary
Number Representations
Lecture 9: Shift, Mult, Div Fixed & Floating Point
CS 105 “Tour of the Black Holes of Computing!”
Presentation transcript:

Introduction to Scientific Computation Whom do you call…?

Copyright, G. A. Tagliarini, PhD Common Problems Intractable analytical representations Model building: sample data are available but no closed form analytical representation for a relation Need to estimate intermediate behavior (interpolation) Need to predict/forecast behavior (extrapolation) Change representation from one domain to another (e.g., DSP) 11/21/2018 Copyright, G. A. Tagliarini, PhD

Copyright, G. A. Tagliarini, PhD Computing Issues Inherently discrete representation Finite ranges that vary according to the space allocated to store the representation Alternative arithmetic systems Integers (two’s complement representation) Floating point (IEEE 754) 11/21/2018 Copyright, G. A. Tagliarini, PhD

Computer Integer Arithmetic Representations assume n bits bn-1…b0 Unsigned Range is [0, 2n-1], there is no sign so all bits can be used to represent magnitude Example with n=8 and x = 1001 11002 = 15610 Typically used to represent storage addresses Signed magnitude Two’s complement 11/21/2018 Copyright, G. A. Tagliarini, PhD

Computer Integer Arithmetic Representations assume n bits bn-1…b0 Unsigned Signed magnitude Range is [-(2n-1-1), 2n-1-1] including two zeros! In the representation bn-1…b0, bn-1 represents the sign and bn-2…b0 the magnitude Example with n=8 and x = 1001 11002 = -2810 Typically not used Two’s complement 11/21/2018 Copyright, G. A. Tagliarini, PhD

Computer Integer Arithmetic Representations assume n bits bn-1…b0 Unsigned Signed magnitude Two’s complement Asymmetric range is [-2n-1, 2n-1-1] includes only one zero! In the representation bn-1…b0, bn-1 indicates the sign but is also used to determine the magnitude Example with n=8 and x = 0001 11002 = 2810 11/21/2018 Copyright, G. A. Tagliarini, PhD

Two’s Complement Representation of a Negative Quantity Assume x<0 Find y = |x| Determine the unsigned binary representation of y = bn-1…b0 Complement each bit (replace each 0 with 1 and each 1 with 0) to form y’ = bn-1’…b0’, where bi’=(1-bi), for i e {0, 1,…, n-1} Add 1 to complete the representation 11/21/2018 Copyright, G. A. Tagliarini, PhD

Two’s Complement Representation of a Negative Quantity Assume n = 8 and x = -28 (note x<0) Find y = |x| → y = 2810 Determine the unsigned binary representation of y = bn-1…b0 → y = 0001 11002 Complement each bit to form y’ = 1110 00112 Add 1 to form the two’s complement representation of -28 which is y’+1 = 1110 01002 Note: 0001 11002 + 1110 01002 = 0, as expected! (Remember that the field width is fixed.) 11/21/2018 Copyright, G. A. Tagliarini, PhD

Two’s Complement Interpretation If bn-1 = 0, interpret as the corresponding unsigned (non-negative) integer If bn-1 = 1, Complement each bit Add 1 Interpret the result as an unsigned quantity Attach the “-” sign 11/21/2018 Copyright, G. A. Tagliarini, PhD

Two’s Complement Interpretation Example where bn-1 = 1, x = 1001 11002 Complement each bit → 0110 0011 Add 1 → 0110 0100 Interpret the result as an unsigned quantity → 10010 Attach the “-” sign → -10010 11/21/2018 Copyright, G. A. Tagliarini, PhD

Review of Single Precision IEEE 754 Floating Point Notation Uses 32-bits in three fields: Sign (a 1-bit field) 0 - nonnegative 1 - negative Biased exponent (an 8-bit field) Bias equals 12710 (or 0111 11112) Normalized mantissa (a 23-bit field) Leading “1” omitted 11/21/2018 Copyright, G. A. Tagliarini, PhD

Conversion to IEE 754 Representation Select the appropriate value for the sign bit Write the quantity in normalized binary scientific notation as a product of: A value x such that 12 ≤ x < 102 and a A power 102 Add the bias to the exponent to obtain the biased exponent field value Write the mantissa by Dropping the leading “1” (to the left of the binary point) Extending or rounding the remaining to 23-bits 11/21/2018 Copyright, G. A. Tagliarini, PhD

IEEE 754 Conversion Example Convert 1 3/16 Sign bit = 0 1 3/16 = 1.00112 = 1.00112 x (102)02 Biased exponent = 02 + 0111 11112 = 0111 11112 Mantissa = 0011 0000 0000 0000 0000 0002 (note that the leading “1” has been omitted and trailing zeros added to create a total of 23 bits) Completed representation 0011 1111 1001 1000 0000 0000 0000 00002 or 3F98 000016 11/21/2018 Copyright, G. A. Tagliarini, PhD

IEEE 754 Conversion Example 2 Convert -3.110 Sign bit = 1 3.110 = 11.0001100110011…2 = 1.1000110011…2 x (102)12 Biased exponent = 12 + 0111 11112 = 1000 00002 Mantissa = 1000 1100 1100 1100 1100 1102 (note that the leading “1” has been omitted, repeating digits used and the representation rounded to a total of 23 bits) Completed representation 1100 0000 0100 0110 0110 0110 0110 01102 or C046 666616 11/21/2018 Copyright, G. A. Tagliarini, PhD

What Difference Does It Make? Patriot Missile Failure (28 killed, 100 injured) https://www.ima.umn.edu/~arnold/disasters/patriot.html Ariane 5 Explosion ($7 Billion) https://www.ima.umn.edu/~arnold/disasters/ariane.html 11/21/2018 Copyright, G. A. Tagliarini, PhD

Some IEEE 754 Floating Point Values Sign Bit Exponent Field Mantissa Floating Point Value 0111 1111 0000 0000 0000 0000 0000 000 1.0 0000 0000 0000 0000 0000 001 1.0 + eM 1000 0000 2.0 2.0*(1.0 + eM) 1000 0001 4.0 4.0*(1.0 + eM) 1000 0010 8.0 8.0*(1.0 + eM) 11/21/2018 Copyright, G. A. Tagliarini, PhD

Some IEEE 754 Floating Point Values SignBit Exponent Field Mantissa Interpretation 0000 0000 0000 0000 0000 0000 0000 000 +0.0 1 -0.0 1111 1111 +∞ -∞ xxxx xxxx xxxx xxxx xxxx xxx (at least one x≠0) NaN 1111 1110 1111 1111 1111 1111 1111 111 eMax=2+127*(2-2-23) ≈2+128 0000 0000 0000 0000 0000 001 eMin=2-126*2-23=2-149 11/21/2018 Copyright, G. A. Tagliarini, PhD

Some Notes About IEEE 754, Floating Point Representation The density of the distribution of floating point values varies along the number line Half of the possible floating point values lie in the interval [-1, 1] For single precision representation Machine epsilon εM = 2-23 The minimum representable value εMin = 2-149 The maximum representable value εMax ≈ 2128 11/21/2018 Copyright, G. A. Tagliarini, PhD

Finding Machine Epsilon, εM Set εM = 1 Do εM = εM/2 x = 1 + εM While (x>1) εM = 2*εM 11/21/2018 Copyright, G. A. Tagliarini, PhD

Copyright, G. A. Tagliarini, PhD Errors Round-off Arise from limitations in the space allocated for representing specific type of datum Truncation Arise from abbreviating an analytical representation 11/21/2018 Copyright, G. A. Tagliarini, PhD

Copyright, G. A. Tagliarini, PhD Random Numbers Uniform random distribution (e.g., Math.random()) For u1 and u2 are chosen from a uniform distribution, then have a Gaussian distribution 11/21/2018 Copyright, G. A. Tagliarini, PhD