Class 5. Data Representation and Introduction to Visualization

Similar documents
Data Representation and Introduction to Visualization

Chapter 3. Errors and numerical stability

Floating-point representations

Floating-point representations

Chapter 3: Arithmetic for Computers

Finite arithmetic and error analysis

Floating Point Numbers

CSCI 402: Computer Architectures. Arithmetic for Computers (3) Fengguang Song Department of Computer & Information Science IUPUI.

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

Divide: Paper & Pencil

Introduction to Computers and Programming. Numeric Values

Floating Point Numbers

Floating Point Numbers

ECE232: Hardware Organization and Design

Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers

1.2 Round-off Errors and Computer Arithmetic

COMP2611: Computer Organization. Data Representation

Floating Point Arithmetic

Floating Point (with contributions from Dr. Bin Ren, William & Mary Computer Science)

Number Systems. Both numbers are positive

The ALU consists of combinational logic. Processes all data in the CPU. ALL von Neuman machines have an ALU loop.

Floating-Point Arithmetic

Up next. Midterm. Today s lecture. To follow

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

Floating-point numbers. Phys 420/580 Lecture 6

Floating-point representation

Representing and Manipulating Floating Points. Jo, Heeseung

Numerical computing. How computers store real numbers and the problems that result

15213 Recitation 2: Floating Point

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Lecture 3

Chapter 4. Operations on Data

Representing and Manipulating Floating Points

Floating Point January 24, 2008

Representing and Manipulating Floating Points

Floating Point Representation in Computers

Mathematical preliminaries and error analysis

Module 2: Computer Arithmetic

Representing and Manipulating Floating Points. Computer Systems Laboratory Sungkyunkwan University

Chapter Three. Arithmetic

Data Representation Type of Data Representation Integers Bits Unsigned 2 s Comp Excess 7 Excess 8

3.1 DATA REPRESENTATION (PART C)

Computational Methods. Sources of Errors

2 Computation with Floating-Point Numbers

Data Representation Floating Point

Representing and Manipulating Floating Points

More Programming Constructs -- Introduction

CO212 Lecture 10: Arithmetic & Logical Unit

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Digital Computer Arithmetic ECE 666

2 Computation with Floating-Point Numbers

Data Representation Floating Point

Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction

Systems I. Floating Point. Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties

Scientific Computing. Error Analysis

FLOATING POINT NUMBERS

CS321. Introduction to Numerical Methods

2.1.1 Fixed-Point (or Integer) Arithmetic

Foundations of Computer Systems

Data Representation 1

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

Binary floating point encodings

Floating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754

CMPSCI 145 MIDTERM #1 Solution Key. SPRING 2017 March 3, 2017 Professor William T. Verts

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

fractional quantities are typically represented in computers using floating point format this approach is very much similar to scientific notation

Floating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754

Floating-Point Numbers in Digital Computers

Floating-Point Numbers in Digital Computers

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example

Floating Point Puzzles The course that gives CMU its Zip! Floating Point Jan 22, IEEE Floating Point. Fractional Binary Numbers.

Chapter 2 Float Point Arithmetic. Real Numbers in Decimal Notation. Real Numbers in Decimal Notation

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Digital Computer Arithmetic ECE 666

Review of Calculus, cont d

Computer Organization: A Programmer's Perspective

COMPUTER ARCHITECTURE AND ORGANIZATION. Operation Add Magnitudes Subtract Magnitudes (+A) + ( B) + (A B) (B A) + (A B)

Numeric Encodings Prof. James L. Frankel Harvard University

C NUMERIC FORMATS. Overview. IEEE Single-Precision Floating-point Data Format. Figure C-0. Table C-0. Listing C-0.

COMP Overview of Tutorial #2

Floating Point Representation. CS Summer 2008 Jonathan Kaldor

Objectives. Connecting with Computer Science 2

Floating point. Today! IEEE Floating Point Standard! Rounding! Floating Point Operations! Mathematical properties. Next time. !

MATH 353 Engineering mathematics III

Computing Basics. 1 Sources of Error LECTURE NOTES ECO 613/614 FALL 2007 KAREN A. KOPECKY

Number Systems and Computer Arithmetic

Chapter 5 : Computer Arithmetic

Number Representations

Giving credit where credit is due

CS101 Lecture 04: Binary Arithmetic

Classes of Real Numbers 1/2. The Real Line

Table : IEEE Single Format ± a a 2 a 3 :::a 8 b b 2 b 3 :::b 23 If exponent bitstring a :::a 8 is Then numerical value represented is ( ) 2 = (

CS321 Introduction To Numerical Methods


Giving credit where credit is due

System Programming CISC 360. Floating Point September 16, 2008

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Computer Arithmetic. 1. Floating-point representation of numbers (scientific notation) has four components, for example, 3.

Most nonzero floating-point numbers are normalized. This means they can be expressed as. x = ±(1 + f) 2 e. 0 f < 1

Math 340 Fall 2014, Victor Matveev. Binary system, round-off errors, loss of significance, and double precision accuracy.

Floating Point : Introduction to Computer Systems 4 th Lecture, May 25, Instructor: Brian Railing. Carnegie Mellon

Operations On Data CHAPTER 4. (Solutions to Odd-Numbered Problems) Review Questions

Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:

Transcription:

Class 5. Data Representation and Introduction to Visualization Visualization Visualization is useful for: 1. Data entry (initial conditions). 2. Code debugging and performance analysis. 3. Interpretation and display of results. Our focus will be #3. The computational astrophysicist can either: 1. Develop new visualization software tailored to problem under study. 2. Use an existing software package. Plotting 1-D data Function of one variable only: f(x) vs. x. Examples: sm, gnuplot, xgobi, IDL, etc. Minimum requirements: Read data from file. Perform arithmetic manipulation of data. Multiple data sets on plot. Multiple plots on page. Add text to plots. Plotting 2-D data Function of 2 variables, i.e. f(x, y). If f is a scalar quantity, can: 1. Make image. Represent each (x, y) data point by one or more pixels on screen. Use integer value to represent data value at (x, y) point (8 bit: 0 255; 24-bit: 0 16.8 million). 2. Make contour plot. Contours are isosurfaces of data. 3. Make 3-D surface plot. Use (x, y) as 2 coordinates, f as third coordinate, plot surface. 1

If f is a vector quantity, i.e. f(x, y), can: 1. Plot vectors directly (as arrows). Can be hard to see. 2. Plot streamlines. Contours of Φ, where f = Φ. 2-D plotting packages include sm, gnuplot, xgobi, IDL, ximage, NCAR graphics, etc. Plotting 3-D data Function of 3 variables, i.e. f(x, y, z). If f is a scalar quantity, can: 1. Plot 2-D slices. E.g. faces of cube. 2. Plot isosurfaces. These are now 3-D surfaces. Can use wireframe of polygons. Can shade with second variable g(x, y, z). 3. Plot volumetric rendering. Solve transfer equation ( ray tracing ) using emissivity proportional to data value. Standard algorithms exist for 3-D rendering, including shadowing, hidden surface removal, etc. Often implemented in hardware. Also have dynamic/interactive visualization: rotation, etc. If f is a vector quantity, i.e. f(x, y, z), can: 1. Plot 3-D vectors on 2-D slice. 2. Plot streamlines in 3-D. 3-D plotting packages include tipsy, xgobi, IDL, NCAR graphics, xdataslice, etc. Animation If any one of the coordinates of data in a plot is time, it makes sense to render images as a time sequence, e.g. make animation. The eye is very sensitive to motion, can discover much detail using animations. Animation formats include MPEG, FLI, QT, AVI, GIF, plus many custom formats. Animation players include mpeg play, xanim, quicktime, gifview, etc. Often built into web browsers. 2

Data Representation Computers store data as different variable types, e.g. integer, floating point, complex, etc. Different machines have different wordlengths, e.g. 4-byte ints on a 32-bit machine (Pentium), 8-byte ints on a 64-bit machine (G5). This makes (binary) data non-portable. Integers All data types represented by 0 s and 1 s. An integer value: N = # of bits in word. s i = value of bit i in binary string s. N j = s i 2 N i i=1 E.g., 0 0 0 0 0 1 1 0 = 2 2 + 2 1 = 6 for 8-bit word. Use two s complement method for sign (see below). Largest value that can be represented is 2 N 1. For 32-bit word this is 4,294,967,295. Arithmetic with integers is exact, except: when division results in remainder, or result exceeds largest representable integer. E.g. 2 10 9 + 3 10 9 = overflow error. Note multiplication (division) by 2 s can be achieved by left-shift (right-shift), which is very fast (in C, use the << (>>) operator). Two s complement Exploits finite size of data representations (cyclic groups) and properties of binary arithmetic. To get negative of binary integer, invert all bits and add 1 to the result. E.g., 1 = 0 0 0 0 0 0 0 1 in 8-bit. invert bits: 1 1 1 1 1 1 1 0 add 1: 0 0 0 0 0 0 0 1 result: 1 1 1 1 1 1 1 1 = 1 In 8 bits, signed char ranges from 128 to +127. 3

Negative powers of 2 Binary notation can be extended to cover negative powers of 2, e.g. 110.101 is: 1 2 2 + 1 2 1 + 1 2 1 + 1 2 3 = 6.625. Can represent real numbers by specifying some location in the word as the binary point ( fixed-point representation ). In practice, use some bits for an exponent ( floating-point representation ). Floats For most machines these days, real numbers are represented by floating-point format: x = s M B e E s = sign B = base (usually 2, sometimes 16) M = mantissa e = exponent E = bias, usually 127. In past, manufacturers used different number of bits for each of M and e, resulting in non-portable code. Currently, most manufacturers adopt IEEE standard: s = first bit. Next 8 bits are e. (e = 255 reserved for inf & NaN.) Last 23 bits are M, expressed as a binary fraction, either 1.F, or, if e = 0, 0.F (in which case E = 126), where F is in base 2. E.g., 0 10000001 10100000000000000000000 = (+1) [ 2 (129 127)] (1+0.5+0.125) = 6.5. Largest single-precision float f max = 2 127 (1+1/2+1/4+ +1/2 23 ) 3.4028235 10 38 (just under 2 128 ). Smallest (and least precise!) f min = 2 149 10 45. Round-off error Not all values along real axis can be represented. There are 10 38 integers between f min and f max, but only 2 32 10 9 bit patterns. 4

Values < 10 45 result in underflow error. If value cannot be represented, next nearest value is produced. Difference between desired and actual value is called round-off error (RE). Smallest value e m for which 1 + e m > 1 is called machine accuracy, typically 2 23 10 7 for 32 bits. Double precision greatly reduces e m ( 10 16 ). (In this case the 64 bits are divided into 1 sign bit, 11 exponent bits, and 52 mantissa bits; the bias is 1023.) RE accumulates in a calculation: Random walk: total error Ne m after N operations. But algorithms rarely random, giving linear error Ne m. Subtraction of two very nearly equal numbers can give rise to large RE. E.g., solution of quadratic equation... x = b ± b 2 4ac 2a...can go badly wrong whenever ac b 2 (Cf. PS#2). RE cannot be avoided it is a consequence of using a finite number of bits to represent real values. Truncation error In practice, most numerical algorithms approximate desired solution with a finite number of artithmetic operations, e.g., evaluating integral by quadrature; summing series using finite number of terms. Difference between true solution and numerical approximation to solution is called truncation error (TE). TE exists even on perfect machine with no RE. TE is under programmer s control; much effort goes into reducing it. Usually RE and TE do not interact. Sometimes TE can amplify RE until it swamps calculation. The solution is then called unstable. E.g., integer powers of Golden Mean (Cf. PS#2). 5