computer basics computer basics ieee floats ieee floats
play

Computer Basics Computer Basics IEEE Floats IEEE Floats (Part II) - PowerPoint PPT Presentation

Computer Basics Computer Basics IEEE Floats IEEE Floats (Part II) (Part II) Rubin H Landau Rubin H Landau With With Sally Haerer and Scott Clark Sally Haerer and Scott Clark Computational Physics for Undergraduates Computational Physics


  1. Computer Basics Computer Basics IEEE Floats IEEE Floats (Part II) (Part II) Rubin H Landau Rubin H Landau With With Sally Haerer and Scott Clark Sally Haerer and Scott Clark Computational Physics for Undergraduates Computational Physics for Undergraduates BS Degree Program: Oregon State University BS Degree Program: Oregon State University “ Engaging People in Cyber Infrastructure Engaging People in Cyber Infrastructure ” Suppor Support by EPICS/NSF & OSU by EPICS/NSF & OSU Introductory Computational Science 1 Rubin Landau, EPIC/OSU 2005 Introductory Computational Science 1 Rubin Landau, EPIC/OSU 2005

  2. Model: Machine Precision Model: Machine Precision Model: Machine Precision  Floating point  limited precision − singles (32b): 6-7 decimal places − doubles 15-16 places − affects calculations: 7 + 10 -7 = ? 7 = 0 1000 0010 1110 0000 0000 0000 0000 000, 10 -7 = 0 0110 0000 1101 0110 1011 1111 1001 010  Different exponents   can't add mantissas  Shift bits (insert 0's) till same exponent 10 -7 = 0 1000 0010 0000 0000 0000 0000 0000 000  7 + 10 -7 = 7 − Last digits lost (truncation error) − Ignore 10 -7 in single precision Introductory Computational Science 2 Rubin Landau, EPIC/OSU 2005 Introductory Computational Science 2 Rubin Landau, EPIC/OSU 2005

  3. ’’   m ``Machine Precision’’  m ``Machine Precision’’ ``Machine Precision m • Measure of precision in computation • Definition: max # add to 1 gives 1 as answer 1 c +  m = 1 c (1) •  x stored on computer:  m  10 -7 (single),  m  10 - 16 (double) (2) x c  x (1   ) , |  |   m (3) • Scientists: Just say No! to singles Introductory Computational Science 3 Rubin Landau, EPIC/OSU 2005 Introductory Computational Science 3 Rubin Landau, EPIC/OSU 2005

  4. Time for Exercises Time for Exercises Time for Exercises in Lab in Lab in Lab Introductory Computational Science 4 Rubin Landau, EPIC/OSU 2005 Introductory Computational Science 4 Rubin Landau, EPIC/OSU 2005

  5. Landau’ ’s Rules of Education s Rules of Education Landau Landau’s Rules of Education Most of ed is learning names; ideas 1. simple Confusion is the first step towards 2. understanding Traumatic experiences are good 3. teachers Introductory Computational Science 5 Rubin Landau, EPIC/OSU 2005 Introductory Computational Science 5 Rubin Landau, EPIC/OSU 2005

  6.  m Exercise: Determine Your  Exercise: Determine Your  m Exercise: Determine Your m 1. Determine the machine precision   m m of your computer Sam ple pseudocode: eps = 1. begin do N times eps = eps/2. // Make smaller one = 1. + eps write: loop number, one, eps end do 2. Determine   m m for single & double precision (floats) 3. * Determine precise values (decimal OK, octal, hexadecimal/octal better) Introductory Computational Science Rubin Landau, EPIC/OSU 2005 Introductory Computational Science Rubin Landau, EPIC/OSU 2005 Lab 1

  7. Exercise: Summing Series Exercise: Summing Series Exercise: Summing Series e − x ' 1 − x + x 2 2! − x 3 · · · + x N 3! + · · · + remainder (sum =) 2! 3! N ! (term) 1. Calculate e – x : x = 0.1, 1, 10, 100 , 1000 2. Require “absolute” error less than 1 part in 10 8 | term/ sum| < 10 -8 remainder ≈ term Presumptions: no roundoff error Introductory Computational Science Rubin Landau, EPIC/OSU 2005 Introductory Computational Science Rubin Landau, EPIC/OSU 2005 Lab 2

  8. Series Exercise (cont) Series Exercise (cont) Series Exercise (cont) e − x ' 1 − x + x 2 2! − x 3 3! + · · · + x N (sum =) N ! (term) term = 1, sum = 1, eps = 10**(-8) // Initialize do term = -term * x/i // “Good”, factorials “bad” sum = sum + term // Add in term while abs(term/sum) > eps // Continue if error end do 3. Output as table x N sum |sum - exp(-x)| /sum “ exp(- x )” = built-in exponential ( Math.exp ) 4. Compare “good'' to “bad'' (factorials and powers) Introductory Computational Science Rubin Landau, EPIC/OSU 2005 Introductory Computational Science Rubin Landau, EPIC/OSU 2005 Lab 3

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend