CSE 541 Numerical Methods - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

CSE 541 Numerical Methods

Description:

If value after last retained digit is 5, then truncate. If value after last digit is =5, then: ... are not zero, round-up. Else, randomly round-up or truncate. ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 16
Provided by: rogerc2
Category:

less

Transcript and Presenter's Notes

Title: CSE 541 Numerical Methods


1
CSE 541Numerical Methods
  • Machine Representation of Numbers

2
Speed
  • The computer vs the human
  • Who can count to 1 trillion the fastest?
  • Human count from one to 1,000,000,000,000 by one
  • - or -
  • Computer Execute on a Pentium-4 2GHz machine
  • int i 1
  • while (1)
  • printf( d/n, i )
  • Computers are extremely fast at performing simple
    arithmetic

3
Blazing Fast
  • Assume a human can count on average one number
    per second (bad assumption).
  • Implies 1 trillion seconds, or about 32,000
    years!!!!
  • Assume that a 2GHz machine can increment by one
    each clock cycle.
  • Implies 500 seconds!!!!

4
Machine Precision
  • What is our current National Debt?
  • (see http//www.brillig.com/debt_clock/)
  • What is the annual revenue of a Fortune 100
    company?
  • How many molecules are in one mole of gas (under
    ideal assumptions)
  • How many pixels are displayed in a two hour HDTV
    movie?
  • What is the current balance of Bill Gates
    checking account?
  • How many ounces of Pepsi are consumed per year?
  • What is the smallest measurable mass in the
    universe that is not zero?

5
Machine Precision
  • Problem
  • We live in a world with a wide range of scales
  • Computers have limited capabilities

6
Machine Precision
  • Computers have limited capabilities!!!

7
Accuracy and Range
  • More bits you have to represent numbers means
  • A wider range and more accuracy
  • Integer Representation
  • 16-bit integers (common in the late 1990s)
  • 216 65,536
  • 32-bit integers
  • 232 4,294,967,296
  • 64-bit integers
  • 264 ? 1.84 1019

ltlt 1,000,000,000,000
Still no Avagadros number 6.022 1023
8
Back to Our Challenge
  • A 2GHZ 32-bit machine may be blazing fast, but it
    will never reach one trillion either, if care
    isnt taken!!!
  • Overflow
  • Computer Forever
  • Human 32,000 years
  • Forever gtgt 32,000 years, humans win!!!!

9
Accuracy and Standards
  • What is int i and what is its range?
  • Machine dependent
  • ANSI C standard
  • int machine dependent
  • short machine dependent

Not much of a standard, huh?
10
Advice
  • Use the preprocessor to define your own types
  • define CSEint int \\ I want this to be 32-bit
    signed integer
  • define CSEshort short \\ 16-bit signed integer
  • Hence, if you port to another architecture and
    need to change it, only change it in one place.
  • Likewise, use each packages types glFloat,

11
Numbers
  • Whole numbers 0,1,2,
  • Signed integers ,-1,0,1,2,
  • Rational numbers a/b, 1/3, etc.
  • Irrational numbers v2, e, pi, etc.
  • Is there a difference between 0.1 and 1/3?

12
Representing Real Numbers
  • In Base-10, we can express any number as a sum of
    weighted powers of ten.
  • Hence

13
Representing Real Numbers
  • In Base-2 or binary we have a series in powers of
    two?

14
Limiting Precision
  • Truncate PI
  • Truncate to what?
  • To 8 significant digits
  • Okay
  • 3.1415926535897932384626433832795
  • ?
  • 3.1415926

15
Truncation vs Rounding
  • Round to nearest value
  • 3.1415926535897932384626433832795
  • ?
  • 3.1415927
  • Rules
  • If value after last retained digit is gt 5, then
    round-up.
  • If value after last retained digit is lt 5, then
    truncate.
  • If value after last digit is 5, then
  • If all remaining digits are not zero, round-up.
  • Else, randomly round-up or truncate.
Write a Comment
User Comments (0)
About PowerShow.com