COS 323: Computing for the Physical and Social Sciences Szymon Rusinkiewicz.

Slides:



Advertisements
Similar presentations
Roundoff and truncation errors
Advertisements

2009 Spring Errors & Source of Errors SpringBIL108E Errors in Computing Several causes for malfunction in computer systems. –Hardware fails –Critical.
Overview CNS 3320 – Numerical Software Engineering.
Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
Floating Point Numbers
Introduction to Scientific Computing ICE / ICE 508 Prof. Hyuckjae Lee KAIST- ICC
1cs542g-term CS542G - Breadth in Scientific Computing.
ECIV 201 Computational Methods for Civil Engineers Richard P. Ray, Ph.D., P.E. Error Analysis.
COS 323: Computing for the Physical and Social Sciences Szymon Rusinkiewicz.
Round-Off and Truncation Errors
The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Numerical Analysis ECIV 3306 Chapter 3 Approximations and Errors.
1cs542g-term CS542G - Breadth in Scientific Computing.
COS 323 Fall 2008 Computing for the Physical and Social Sciences Ken Steiglitz.
1 Error Analysis Part 1 The Basics. 2 Key Concepts Analytical vs. numerical Methods Representation of floating-point numbers Concept of significant digits.
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM.
Computer Science 210 Computer Organization Floating Point Representation.
Binary Representation and Computer Arithmetic
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Chapter 31.
Numerical Computations in Linear Algebra. Mathematically posed problems that are to be solved, or whose solution is to be confirmed on a digital computer.
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
Information Representation (Level ISA3) Floating point numbers.
IT253: Computer Organization
Lecture 2 Number Representation and accuracy
Number Systems So far we have studied the following integer number systems in computer Unsigned numbers Sign/magnitude numbers Two’s complement numbers.
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM CISE301_Topic1.
CISE301_Topic11 CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4:
Computing Systems Basic arithmetic for computers.
Introduction to Numerical Analysis I
College of Engineering Representing Numbers in a Computer Section B, Spring 2003 COE1361: Computing for Engineers COE1361: Computing for Engineers 1 COE1361:
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers,
Computer Science Engineering B.E.(4 th sem) c omputer system organization Topic-Floating and decimal arithmetic S ubmitted to– Prof. Shweta Agrawal Submitted.
Round-off Errors and Computer Arithmetic. The arithmetic performed by a calculator or computer is different from the arithmetic in algebra and calculus.
CSC 221 Computer Organization and Assembly Language
16. Binary Numbers Programming in C++ Computer Science Dept Va Tech August, 1999 © Barnette ND, McQuain WD, Keenan MA 1 Binary Number System Base.
Floating Point Arithmetic
MECN 3500 Inter - Bayamon Lecture 3 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Problems with Floating-Point Representations Douglas Wilhelm Harder Department of Electrical and Computer Engineering University of Waterloo Copyright.
Copyright © Curt Hill Numerics Representation and Errors.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 3.
CS 61C L3.2.1 Floating Point 1 (1) K. Meinz, Summer 2004 © UCB CS61C : Machine Structures Lecture Floating Point Kurt Meinz inst.eecs.berkeley.edu/~cs61c.
Modeling Biosystems Mathematical models are tools that biomedical engineers use to predict the behavior of the system. Three different states are modeled.
Floating Point Numbers Representation, Operations, and Accuracy CS223 Digital Design.
Errors in Numerical Methods
IT11004: Data Representation and Organization Floating Point Representation.
CS 232: Computer Architecture II Prof. Laxmikant (Sanjay) Kale Floating point arithmetic.
10/7/2004Comp 120 Fall October 7 Read 5.1 through 5.3 Register! Questions? Chapter 4 – Floating Point.
Numerical Analysis CC413 Propagation of Errors. 2 In numerical methods, the calculations are not made with exact numbers. How do these inaccuracies propagate.
Module 2.2 Errors 03/08/2011. Sources of errors Data errors Modeling Implementation errors Absolute and relative errors Round off errors Overflow and.
Cosc 2150: Computer Organization Chapter 9, Part 3 Floating point numbers.
Chapter 2 Errors in Numerical Methods and Their Impacts.
NUMERICAL ANALYSIS I. Introduction Numerical analysis is concerned with the process by which mathematical problems are solved by the operations.
Floating Points & IEEE 754.
Introduction to Numerical Analysis I
Floating Point Representations
Fundamentals of Computer Science
Computer Science 210 Computer Organization
Floating Point Math & Representation
Floating Point Numbers: x 10-18
IEEE floating point format
Chapter 6 Floating Point
CSCI206 - Computer Organization & Programming
Floating Point Representation
Computer Science 210 Computer Organization
Approximations and Round-Off Errors Chapter 3
Topic 3d Representation of Real Numbers
Numbers with fractions Could be done in pure binary
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM CISE301_Topic1.
Presentation transcript:

COS 323: Computing for the Physical and Social Sciences Szymon Rusinkiewicz

What’s This Course About? Numerical AlgorithmsNumerical Algorithms Analysis of DataAnalysis of Data SimulationSimulation

Numerical Analysis Algorithms for solving numerical problemsAlgorithms for solving numerical problems – Calculus, algebra, data analysis, etc. – Applications in all scientific and engineering fields Analyze/design algorithms based on:Analyze/design algorithms based on: – Running time, memory usage (both asymptotic and constant factors) – Applicability, stability, and accuracy for different classes of problems

Why Is This Hard/Interesting? “Numbers” in computers  numbers in math“Numbers” in computers  numbers in math – Limited precision and range Algorithms sometimes don’t give right answerAlgorithms sometimes don’t give right answer – Iterative, randomized, approximate – Unstable Running time / accuracy / stability tradeoffsRunning time / accuracy / stability tradeoffs

Numbers in Computers “Integers”“Integers” – Implemented in hardware: fast – Mostly sane, except for limited range Floating pointFloating point – Implemented in most hardware – Much larger range (e.g.  for integers, vs.  for FP) – Lower precision (e.g. 7 digits vs. 9) – “Relative” precision: actual accuracy depends on size

Floating Point Numbers Like scientific notation: e.g., c is  10 8 m/sLike scientific notation: e.g., c is  10 8 m/s This has the form (multiplier)  (base) (power)This has the form (multiplier)  (base) (power) In the computer,In the computer, – Multiplier is called mantissa – Base is almost always 2 – Power is called exponent

Modern Floating Point Formats Almost all computers use IEEE 754 standardAlmost all computers use IEEE 754 standard “Single precision”:“Single precision”: – 24-bit mantissa, base = 2, 8-bit exponent, 1 bit sign – All fits into 32 bits (!) “Double precision”:“Double precision”: – 53-bit mantissa, base = 2, 11-bit exponent, 1 bit sign – All fits into 64 bits Sometimes also have “extended formats”Sometimes also have “extended formats”

Other Number Representations Fixed pointFixed point – Absolute accuracy doesn’t vary with magnitude – Represent fractions to a fixed precision – Not supported directly in hardware, but can hack it “Infinite precision”“Infinite precision” – Integers or rationals allocated dynamically – Can grow up to available memory – No direct support in hardware, but libraries available

Consequences of Floating Point “Machine epsilon”: smallest positive number you can add to 1.0 and get something other than 1.0“Machine epsilon”: smallest positive number you can add to 1.0 and get something other than 1.0 For single precision:   10  7For single precision:   10  7 – No such number as – Rule of thumb: “almost 7 digits of precision” For double:   2  10  16For double:   2  10  16 – Rule of thumb: “not quite 16 digits of precision” These are all relative numbersThese are all relative numbers

So What? Simple example: add 1 / 10 to itself 10 timesSimple example: add 1 / 10 to itself 10 times

Oops! Result: 1 / / 10 + …  1Result: 1 / / 10 + …  1 Reason: 0.1 can’t be represented exactly in binary floating pointReason: 0.1 can’t be represented exactly in binary floating point – Like 1 / 3 in decimal Rule of thumb: comparing floating point numbers for equality is always wrongRule of thumb: comparing floating point numbers for equality is always wrong

More Subtle Problem Using quadratic formula to solve x 2 – 9999x + 1 = 0Using quadratic formula to solve x 2 – 9999x + 1 = 0 – Only 4 digits: single precision should be OK, right? Correct answers: … and …Correct answers: … and … Actual answers in single precision: 0 and 9999Actual answers in single precision: 0 and 9999 – First answer is 100% off! – Total cancellation in numerator because b 2 >> 4 ac

Catalog of Errors Roundoff error – caused by limitations of floating-point “numbers”Roundoff error – caused by limitations of floating-point “numbers” Truncation error – caused by stopping an approximate technique earlyTruncation error – caused by stopping an approximate technique early – e.g., too few terms of Taylor series for sin(  ) Inherent error – limitation on data availableInherent error – limitation on data available – GIGO Statistical error – too few random samplesStatistical error – too few random samples

Running Time Depending on algorithm, we’ll look at:Depending on algorithm, we’ll look at: – Asymptotic analysis for noniterative algorithms (e.g., inverting an n  n matrix requires time proportional to n 3 ) – Convergence order for iterative approximate algorithms (e.g., an answer to precision  might require iterations proportional to 1/  or 1/  2 )

This Course Basic techniques: root finding, optimization, linear systemsBasic techniques: root finding, optimization, linear systems Data analysis and modeling: least squares, dimensionality reduction, visualization, statisticsData analysis and modeling: least squares, dimensionality reduction, visualization, statistics Signal processing: sampling, filteringSignal processing: sampling, filtering Integration and differential equationsIntegration and differential equations SimulationSimulation

Mechanics Programming assignmentsProgramming assignments – Typically more thought than coding – Some in MATLAB, some in C or Java – Analysis, writeup counts a lot! Final projectFinal project

Mechanics “Lab” time – now cancelled“Lab” time – now cancelled Course webpageCourse webpage – (infinitely long address – find from CS dept webpage) Contact me at me at TA: Alex Golovinskiy Alex Golovinskiy