Error: Finding Creative ways to Screw Up CS 170: Computing for the Sciences and Mathematics.

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.
Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
CS 351/ IT 351 Modeling and Simulation Technologies Errors In Models Dr. Jim Holten.
Floating Point Representation in Computers Floating Point Numbers - What are they? Floating Point Representation Floating Point Operations Where Things.
ECIV 201 Computational Methods for Civil Engineers Richard P. Ray, Ph.D., P.E. Error Analysis.
EXPERIMENTAL ERRORS AND DATA ANALYSIS
1 Lecture 9: Floating Point Today’s topics:  Division  IEEE 754 representations  FP arithmetic Reminder: assignment 4 will be posted later today.
Number Systems Standard positional representation of numbers:
Copyright 2008 Koren ECE666/Koren Part.4c.1 Israel Koren Spring 2008 UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering Digital Computer.
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.
February 26, 2003MIPS floating-point arithmetic1 Question  Which of the following are represented by the hexadecimal number 0x ? —the integer.
Simple Data Type Representation and conversion of numbers
Numbers and number systems
2.2 Errors. Why Study Errors First? Nearly all our modeling is done on digital computers (aside: what would a non-digital analog computer look like?)
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.
Computer Arithmetic Nizamettin AYDIN
1 Lecture 5 Floating Point Numbers ITEC 1000 “Introduction to Information Technology”
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 22, 2004 Lecture Number: 24.
Lecture 2 Number Representation and accuracy
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.
College of Engineering Representing Numbers in a Computer Section B, Spring 2003 COE1361: Computing for Engineers COE1361: Computing for Engineers 1 COE1361:
Data Representation in Computer Systems
Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers,
5.2 Errrors. Why Study Errors First? Nearly all our modeling is done on digital computers (aside: what would a non-digital analog computer look like?)
Round-off Errors.
Round-off Errors and Computer Arithmetic. The arithmetic performed by a calculator or computer is different from the arithmetic in algebra and calculus.
Lecture 9: Floating Point
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter.
Floating Point Arithmetic
MECN 3500 Inter - Bayamon Lecture 3 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
COMP201 Computer Systems Floating Point Numbers. Floating Point Numbers  Representations considered so far have a limited range dependent on the number.
Chapter 3 Scientific Measurement Measurement In chemistry, #’s are either very small or very large 1 gram of hydrogen = 602,000,000,000,000,000,000,000.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Copyright © Curt Hill Numerics Representation and Errors.
1 Floating Point Operations - Part II. Multiplication Do unsigned multiplication on the mantissas including the hidden bits Do unsigned multiplication.
Computer Organization and Design Information Encoding II Montek Singh Wed, Aug 29, 2012 Lecture 3.
Computer Arithmetic Floating Point. We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large.
Numerical Analysis Intro to Scientific Computing.
Modeling Biosystems Mathematical models are tools that biomedical engineers use to predict the behavior of the system. Three different states are modeled.
CS 170: Computing for the Sciences and Mathematics
Numerical Analysis CC413 Propagation of Errors.
CS 232: Computer Architecture II Prof. Laxmikant (Sanjay) Kale Floating point arithmetic.
Numerical Analysis CC413 Propagation of Errors. 2 In numerical methods, the calculations are not made with exact numbers. How do these inaccuracies propagate.
Binary Numbers The arithmetic used by computers differs in some ways from that used by people. Computers perform operations on numbers with finite and.
Module 2.2 Errors 03/08/2011. Sources of errors Data errors Modeling Implementation errors Absolute and relative errors Round off errors Overflow and.
COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.
Cosc 2150: Computer Organization Chapter 9, Part 3 Floating point numbers.
NUMERICAL ANALYSIS I. Introduction Numerical analysis is concerned with the process by which mathematical problems are solved by the operations.
Floating Point Representations
Machine arithmetic and associated errors Introduction to error analysis Class II.
Binary Numbers The arithmetic used by computers differs in some ways from that used by people. Computers perform operations on numbers with finite and.
New head garb has been ordered
Floating Point Math & Representation
Floating Point Numbers: x 10-18
CS 232: Computer Architecture II
April 2006 Saeid Nooshabadi
Chapter 6 Floating Point
Chapter 2 ERROR ANALYSIS
Recall our hypothetical computer Marc-32
Approximations and Round-Off Errors Chapter 3
Numerical Analysis Lecture 2.
Chapter 1 / Error in Numerical Method
CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4: KFUPM CISE301_Topic1.
Presentation transcript:

Error: Finding Creative ways to Screw Up CS 170: Computing for the Sciences and Mathematics

Administrivia Last time  Basics of modeling  Assigned HW 1 Today  HW1 due!  Assign HW 2 Monday 9/13– NO CLASS

Error What is the value of a model…  That is completely wrong  That is a perfect match to a physical system  That may be off by as much as 5%

Types of Error Input Data Errors  Faulty/inaccurate sensors, poorly calibrated, mis-read results.. Modeling Errors  Poor assumptions, bad math, mis-understanding of system Implementation Errors  Bug in computer program, poor programming  Precision  The limits of finite number representation

Input Data Errors NSIDC  Sensor drift led to their real-time sea ice estimates to be off by over 500,000 km 2  Still only off by 4% 

Modeling Errors Obvious type: math formulation errors, mis-writing a formula, etc. By virtue of making assumptions and simplifications, models will have “error” versus reality.  This isn’t necessarily a bad thing, as long as we manage it well Lord Kelvin used his knowledge of temperature dissipation to estimate that the earth was between million years old.  Actual: ~12 billion  Assumed there was no heat source but the sun

Implementation Errors Incorrect programming (a “bug”)  Didn’t implement the model correctly  Wrong equations  Mis-defined inputs/outputs  Implemented the solution to a different problem Precision Errors  Computers only have so much space to store numbers  This limits the range and precision of values!

Precision Errors In a computer, a number is stored in a number of bits (binary digits)  IEEE 754 standard floating point  Variation on standard normalized scientific notation  single-precision is 32 bits  double-precision is 64 bits  Stored in 3 parts  sign (1 bit) – is it positive or negative?  magnitude – what is the exponent?  mantissa/significand – what is the number? i.e × 10 23

Exponential notation Example:  10 3 Fractional part or significand?  Exponent? 33 Normalized?   10 5

Significant digits Significant digits of floating point number  All digits except leading zeros  Number of significant digits in  10 3 ?  9 significant digits Precision  Number of significant digits

Round-off error Problem of not having enough bits to store entire floating point number Example:  10 5 if only can store 6 significant digits, rounded?   10 5 Do not test directly for equality of floating point variables  Note that many numbers that seem “safe” really aren’t!  i.e. 0.2 is an infinite repeating series when expressed in binary

Absolute error |correct – result| Example: correct =  10 5 and result =  10 5 Absolute error = ?  |   10 5 | =  10 5 = 0.990

Relative error |(correct - result) / correct| Example: (correct - result) = and correct =  10 5  0.990/(  10 5 ) =  10 -5

Relative error Why consider relative errors?  1,000,000 vs. 1,000,001  1 vs. 2 Absolute error for these is the same! If exact answer is 0 or close to 0, use absolute error  Why?

Addition and subtraction errors Beware if there is a big difference in the magnitude of numbers! Example: (0.65  10 5 ) + (0.98  ) = ?  = Suppose we can only store 6 significant digits?  = (  10 5 )

Associative property Does not necessarily hold! Sum of many small numbers + large number may not equal adding each small number to large number Similarly, distributive property does not necessarily hold

To reduce numerical errors Round-off errors  Use maximum number of significant digits If big difference in magnitude of numbers  Add from smallest to largest numbers

Error Propagation (Accumulated Error) Example: repeatedly executing: t = t + dt Better to repeatedly increment i and calculate: t = i * dt

Overflow/underflow Overflow - error condition that occurs when not enough bits to express value in computer Underflow - error condition that occurs when result of computation is too small for computer to represent

Truncation error  Error that occurs when truncated, or finite, sum is used as approximation for sum of infinite series

Error is Not Inherently Bad Almost all of these issues can be managed and controlled! A certain amount of error is normal What’s important is that we:  Know how much error there might be  Keep it within a bound that allows the results to still be valid

Rates: The Basics of Calculus

Calculus Mathematics of change Two parts  Differential calculus  Integral calculus

Rates “Rate of Change”  Often depends on current amounts Rates are important in a lot of simulations  growth/decay of…  populations  materials/concentrations  radioactivity  money  motion  force  pressure

Height (y) in m vs time (t) in sec of ball thrown up from bridge

Average velocity between 0 sec & 1 sec? between 1 sec & 2 sec? between 0.75 sec & 1.25 sec? Estimate of instantaneous velocity at t = 1 sec? Time (t) in seconds Height (y) in meters

Derivative Derivative of y = s(t) with respect to t at t = a is the instantaneous rate of change of s with respect to t at a (provided limit exists):

Derivative at a point is the slope of the curve at that point

Differential Equation Equation that contains a derivative Velocity function  v(t) = dy/dt = s'(t) = -9.8t + 15 Initial condition  y 0 = s(0) = 11 Solution:  function y = s(t) that satisfies equation and initial condition(s)  in this case:  s(t) = -4.9t t + 11

Second Derivative Acceleration - rate of change of velocity with respect to time Second derivative of function y = s(t) is the derivative of the derivative of y with respect to independent variable t Notation  s''(t)  d 2 y/dt 2

Systems Dynamics Software package that makes working with rates much easier. Components include:  “Stocks” – collections of things (noun)  “Flow” – activity that changes a stock (verb)  “Variables” – constants or equations – converter  “Connector” – denotes input/information being trasmitted

HOMEWORK! READ pages in the textbook On your own  Work through the Vensim PLE tutorial  Turn-in the final result files on W: Vensim is being deployed tonight. If there is a problem, I will notify everyone ASAP. NO CLASS on Monday