How to Compute the Area of a Triangle: a Formal Revisit
|
|
- Alexander Paul Underwood
- 5 years ago
- Views:
Transcription
1 21st IEEE International Symposium on Computer Arithmetic How to Compute the Area of a Triangle: a Formal Revisit Sylvie Boldo Inria Saclay Île-de-France, LRI, Université Paris-Sud April 9th, 2013
2 Motivations Given 3 FP numbers a, b, and c that are the side lengths of a triangle, we want to compute the area of this triangle. b c The common formula is attributed to Heron of Alexandria: = s (s a) (s b) (s c) where s = a + b + c 2 a
3 Motivations This is known to be inaccurate using FP arithmetic in the case of needle-like triangles: b c for a = , b = , and c = , Heron s formula gives 17.6 and Kahan s a for a = , b = , and c = , Heron s formula FAILS and Kahan s gives Kahan suggested sorting a, b, c and using: = 1 4 (a + (b + c)) (c (a b)) (c + (a b)) (a + (b c))
4 Literature [Kahan, Miscalculating Area and Angles of a Needle-like Triangle, 1986?] Area is accurate to within a few units in their last digits. Proof A few facts (values are non-negative, exact subtractions) [Goldberg, What every computer scientist should know about floating-point arithmetic, 1991] The rounding error of area is at most 11 ε, provided ε < and subtraction and square roots are accurate. No proof.
5 Motivations Can we formally (im)-prove the error bound? (a proof that is mechanically verified by a proof assistant) What can be said about underflows? What can be said about overflows? Can we have an understandable proved program? We will use the Coq proof assistant and the Flocq library (multi-radix, multi-format and multi-precision library). For the formal proof of the C program, we will use the following chain: Frama-C/Jessie/Why3 (see later).
6 Notations Side lengths: a, b and c They are sorted and represent a (possibly degenerate) triangle: 0 c b a b + c radix β, precision p, machine epsilon ε = β1 p 2. minimal exponent E i (the smallest positive (subnormal) FP number is β E i ) rounding to nearest, ties to even,, : rounded addition, subtraction and multiplication C(e) the exact value of a FP expression e (i.e. obtained without rounding) err(x, y, e) means that the relative error is less than e: x y e y
7 Kahan s algorithm = 1 4 (a + (b + c)) (a + (b c)) (c + (a b)) (c (a b))
8 Kahan s algorithm = 1 4 (a + (b + c)) (a + (b c)) (c + (a b)) (c (a b)) t 1 = a (b c) t 2 = a (b c) t 3 = c (a b) t 4 = c (a b) M = t 1 t 2 t 3 t 4 ( ) 1 = ( M) 4
9 Kahan s algorithm = 1 4 (a + (b + c)) (a + (b c)) (c + (a b)) (c (a b)) t 1 = a (b c) t 2 = a (b c) t 3 = c (a b) t 4 = c (a b) M = ((t 1 t 2 ) t 3 ) t 4 ( ) 1 = ( M) 4
10 Plan 1 Motivations 2 Error Bound Provided neither Underflow, nor Overflow Occur 3 Underflow Handling 4 Program Proof 5 Conclusion
11 Assumptions Set of hypotheses with unbounded exponent range: the exponent range is unbounded, 1 4 fits in the format, ε 1 100, 0 c b a b + c.
12 Proof sketch all t i are non-negative, so the square root is innocuous a b = a b, using Sterbenz theorem basic forward error analysis on the others FP additions, subtractions, and multiplications This lemma about the square root: Theorem (err sqrt flx) Given x, y, e, if 0 y, and e 0.5 and err(x, y, e), then err( ( x), y, ε + (1 + ε) 5 8 e).
13 Practical use of un-instantiated variables Thanks to Coq inference mechanism, I did not write explicitly the rounding error of M in the expected form: ε + (1 + ε) (ε + (1 + ε) (ε + (1 + ε) (2 ε + ε ε+ (2 ε + ε ε) + (2 ε + ε ε) (2 ε + ε ε)) + ε + (ε+ (1 + ε) (2 ε + ε ε + (2 ε + ε ε) + (2 ε + ε ε) (2 ε + ε ε))) ε) + ε + (ε + (1 + ε) (ε + (1 + ε) (2 ε + ε ε + (2 ε + ε ε) + (2 ε + ε ε) (2 ε + ε ε)) +ε + (ε + (1 + ε) (2 ε + ε ε + (2 ε + ε ε)+ (2 ε + ε ε) (2 ε + ε ε))) ε)) ε)
14 Final rounding error with an unbounded exponent range Theorem (err flx) We have err(, C( ), 61 8 ε + 36ε2 ). Instead of 11 ε, we have a formal proof of ε (+Nε 2 ). If we assume radix 2, then multiplying by 1 4 is exact: Theorem (err flx radix2) With β = 2, we have err(, C( ), 53 8 ε + 29ε2 ). Instead of 11 ε, we have a formal proof of ε (+Nε 2 ).
15 Plan 1 Motivations 2 Error Bound Provided neither Underflow, nor Overflow Occur 3 Underflow Handling 4 Program Proof 5 Conclusion
16 Assumptions Set of hypotheses with underflow gradual underflow with E i as minimal exponent, E i 3 p, no upper bound on the exponent, 1 4 fits in the format, ε 1 100, 0 c b a b + c.
17 Proof sketch as before, all t i are non-negative, so the square root is innocuous as before, a b = a b, using Sterbenz theorem if the result of an addition is a subnormal FP, then it is exact for the square root, there is no problem, as a square root cannot be subnormal (except zero) for multiplication, we have to assume the result is not subnormal: Theorem (err mult flt) Given x 1, y 1, e 1, x 2, y 2, e 2, if x 1 and x 2 fit in the format, if err(x 1, y 1, e 1 ), and err(x 2, y 2, e 2 ), and if β E i +p 1 < x 1 x 2, then err(x 1 x 2, y 1 y 2, ε + (1 + ε) (e 1 + e 2 + e 1 e 2 )).
18 Detect subnormals We need to prove no subnormal is created. detect afterwards if a subnormal appeared in the computation If the result is big enough, it will mean no underflow happened anywhere in the computation. order the t i s by magnitude. Theorem We have 0 t 4 t 3 t 2 t 1. use the following fact to not loose subnormality: Theorem (subnormal aux) Given x and y, we assume that x is a FP and that β E i +p 1 < x y. We also assume that, if x 1, then y 1. Then β E i +p 1 < x.
19 Final rounding error with underflow Theorem (err flt) Ei We assume that 1 +p 1 4 β 2 <. We have err(, C( ), 61 8 ε + 36ε2 ). Theorem (err flt radix2) We assume that β = 2, and that 2 Ei +p 1 err(, C( ), 53 8 ε + 29ε2 ). 2 2 <. We have same error bounds as before, assuming is not too small.
20 What about Overflow? Overflow is only taken into account at the program level. we will prove no overflow occur We assume a < using Gappa, we prove no overflow occur in the 14 operations
21 Plan 1 Motivations 2 Error Bound Provided neither Underflow, nor Overflow Occur 3 Underflow Handling 4 Program Proof 5 Conclusion
22 Methodology C Program
23 Methodology Human Annotated C Program (specification, invariant)
24 Methodology Human Annotated C Program (specification, invariant) Frama-C Jessie Theorem statements
25 Methodology Human Annotated C Program (specification, invariant) Frama-C Jessie Automatic provers (Gappa) Theorem statements Coq Human
26 Methodology Human Annotated C Program (specification, invariant) Frama-C Jessie Theorem statements Automatic provers (Gappa) Coq Human
27 Methodology Human Annotated C Program (specification, invariant) Frama-C Jessie Theorem statements Automatic provers (Gappa) Coq Human
28 Methodology Human Annotated C Program (specification, invariant) Frama-C Jessie Theorem statements Automatic provers (Gappa) Coq Human
29 Methodology Human Annotated C Program (specification, invariant) Frama-C Jessie Theorem statements Automatic provers (Gappa) Coq Human
30 Methodology Human Annotated C Program (specification, invariant) Frama-C Jessie Theorem statements Automatic provers (Gappa) Coq Human
31 Methodology Human Annotated C Program (specification, invariant) Frama-C Jessie Theorem statements Automatic provers (Gappa) Coq Human
32 Methodology Human Annotated C Program (specification, invariant) Frama-C Jessie Theorem statements Automatic provers (Gappa) Coq Human
33 Methodology Human Annotated C Program (specification, invariant) Frama-C Jessie Theorem statements Automatic provers (Gappa) Coq Human Proved Theorems
34 Methodology Human Annotated C Program (specification, invariant) Frama-C Jessie Theorem statements Automatic provers (Gappa) Coq Human The program is correct with respect to its specifications Proved Theorems
35 Triangle C program /*@ requires 0 <= ensures \ result ==\ round_double (\ NearestEven,\ sqrt ( x double s q r t ( double x ) ; /*@ logic real S( real a, real b, real c) \ let s = (a+b+c \ sqrt (s*(s-a )*(s-b )*(s-c */ /*@ requires 0 <= c <= b <= a && a <= b + c && a <= 0 x1p255 ensures 0x1p -513 < \ == > \ abs (\ result <= (53./8*0 x1p *0 x1p -106)* S(a,b, */ double t r i a n g l e ( double a, double b, double c ) { r e t u r n (0 x1p 2 s q r t ( ( a+(b+c ) ) ( a+(b c ) ) ( c+(a b ) ) ( c (a b ) ) ) ) ; }
36 Triangle C program /*@ requires 0 <= ensures \ result ==\ round_double (\ NearestEven,\ sqrt ( x double s q r t ( double x ) ; Square root definition /*@ logic real S( real a, real b, real c) \ let s = (a+b+c \ sqrt (s*(s-a )*(s-b )*(s-c */ /*@ requires 0 <= c <= b <= a && a <= b + c && a <= 0 x1p255 ensures 0x1p -513 < \ == > \ abs (\ result <= (53./8*0 x1p *0 x1p -106)* S(a,b, */ double t r i a n g l e ( double a, double b, double c ) { r e t u r n (0 x1p 2 s q r t ( ( a+(b+c ) ) ( a+(b c ) ) ( c+(a b ) ) ( c (a b ) ) ) ) ; }
37 Triangle C program /*@ requires 0 <= ensures \ result ==\ round_double (\ NearestEven,\ sqrt ( x double s q r t ( double x ) ; /*@ logic real S( real a, real b, real c) \ let s = (a+b+c \ sqrt (s*(s-a )*(s-b )*(s-c */ Heron s formula (no rounding) /*@ requires 0 <= c <= b <= a && a <= b + c && a <= 0 x1p255 ensures 0x1p -513 < \ == > \ abs (\ result <= (53./8*0 x1p *0 x1p -106)* S(a,b, */ double t r i a n g l e ( double a, double b, double c ) { r e t u r n (0 x1p 2 s q r t ( ( a+(b+c ) ) ( a+(b c ) ) ( c+(a b ) ) ( c (a b ) ) ) ) ; }
38 Triangle C program /*@ requires 0 <= ensures \ result ==\ round_double (\ NearestEven,\ sqrt ( x double s q r t ( double x ) ; /*@ logic real S( real a, real b, real c) \ let s = (a+b+c \ sqrt (s*(s-a )*(s-b )*(s-c */ /*@ requires 0 <= c <= b <= a && a <= b + c && a <= 0 x1p255 ensures 0x1p -513 < \ == > \ abs (\ result <= (53./8*0 x1p *0 x1p -106)* S(a,b, */ Kahan s algorithm with properly ordered t i s double t r i a n g l e ( double a, double b, double c ) { r e t u r n (0 x1p 2 s q r t ( ( a+(b+c ) ) ( a+(b c ) ) ( c+(a b ) ) ( c (a b ) ) ) ) ; }
39 Triangle C program /*@ requires 0 <= ensures \ result ==\ round_double (\ NearestEven,\ sqrt ( x double s q r t ( double x ) ; /*@ logic real S( real a, real b, real c) \ let s = (a+b+c \ sqrt (s*(s-a )*(s-b )*(s-c */ ordered side lengths /*@ requires 0 <= c <= b <= a && a <= b + c && a <= 0 x1p255 ensures 0x1p -513 < \ == > \ abs (\ result <= (53./8*0 x1p *0 x1p -106)* S(a,b, */ double t r i a n g l e ( double a, double b, double c ) { r e t u r n (0 x1p 2 s q r t ( ( a+(b+c ) ) ( a+(b c ) ) ( c+(a b ) ) ( c (a b ) ) ) ) ; }
40 Triangle C program /*@ requires 0 <= ensures \ result ==\ round_double (\ NearestEven,\ sqrt ( x double s q r t ( double x ) ; /*@ logic real S( real a, real b, real c) \ let s = (a+b+c \ sqrt (s*(s-a )*(s-b )*(s-c */ overflow condition /*@ requires 0 <= c <= b <= a && a <= b + c && a <= 0 x1p255 ensures 0x1p -513 < \ == > \ abs (\ result <= (53./8*0 x1p *0 x1p -106)* S(a,b, */ double t r i a n g l e ( double a, double b, double c ) { r e t u r n (0 x1p 2 s q r t ( ( a+(b+c ) ) ( a+(b c ) ) ( c+(a b ) ) ( c (a b ) ) ) ) ; }
41 Triangle C program /*@ requires 0 <= ensures \ result ==\ round_double (\ NearestEven,\ sqrt ( x double s q r t ( double x ) ; /*@ logic real S( real a, real b, real c) \ let s = (a+b+c \ sqrt (s*(s-a )*(s-b )*(s-c */ /*@ requires 0 <= c <= b <= a && a <= b + c && a <= 0 x1p255 ensures 0x1p -513 < \ result If no == > \ abs (\ result <= (53./8*0 x1p *0 x1p -106)* S(a,b, */ double t r i a n g l e ( double a, double b, double c ) { r e t u r n (0 x1p 2 s q r t ( ( a+(b+c ) ) ( a+(b c ) ) ( c+(a b ) ) ( c (a b ) ) ) ) ; }
42 Triangle C program /*@ requires 0 <= ensures \ result ==\ round_double (\ NearestEven,\ sqrt ( x double s q r t ( double x ) ; /*@ logic real S( real a, real b, real c) \ let s = (a+b+c \ sqrt (s*(s-a )*(s-b )*(s-c */ /*@ requires 0 <= c <= b <= a && a <= b + c && a <= 0 x1p255 ensures 0x1p -513 < \ == > \ abs (\ result <= (53./8*0 x1p *0 x1p -106)* S(a,b, */ Error bound double t r i a n g l e ( double a, double b, double c ) { r e t u r n (0 x1p 2 s q r t ( ( a+(b+c ) ) ( a+(b c ) ) ( c+(a b ) ) ( c (a b ) ) ) ) ; }
43 Triangle C program /*@ requires 0 <= ensures \ result ==\ round_double (\ NearestEven,\ sqrt ( x double s q r t ( double x ) ; /*@ logic real S( real a, real b, real c) \ let s = (a+b+c \ sqrt (s*(s-a )*(s-b )*(s-c */ /*@ requires 0 <= c <= b <= a && a <= b + c && a <= 0 x1p255 ensures 0x1p -513 < \ == > \ abs (\ result <= (53./8*0 x1p *0 x1p -106)* S(a,b, */ Function call double t r i a n g l e ( double a, double b, double c ) { r e t u r n (0 x1p 2 s q r t ( ( a+(b+c ) ) ( a+(b c ) ) ( c+(a b ) ) ( c (a b ) ) ) ) ; }
44 Program proof
45 Plan 1 Motivations 2 Error Bound Provided neither Underflow, nor Overflow Occur 3 Underflow Handling 4 Program Proof 5 Conclusion
46 Conclusion tighter error bound mechanically verified tighter error bound rather easy formal proof (shows the library is comprehensive) unexpectedly tedious to handle higher-order terms in the error bounds: ε, 0 < ε < 1 100, ε 9 +9ε 8 +36ε 7 +84ε ε ε 4 +84ε 3 +36ε 2 +9ε 37ε 2 +9ε As usual, underflow handling is tricky. Here we detect afterwards by ordering the multiplications.
47 Perspectives We assumed either (β = 2 and p 7) or (β = 10 and p 3). These assumptions can be removed by increasing the error bound. Tighter error bound: 1 2 instead of 5 8 in the sqrt error lemma (+ second-order terms). t 4 is exact For β = 2 and an unbounded exponent range, err(, C( ), 5 ε + 36ε 2 ). Tighter error bound in progress: 4.75 ε if tightening the t 2 error bound same bound with underflow
48 Thank you for your attention!
49 Thank you for your attention!
A Formally-Proved Algorithm to Compute the Correct Average of Decimal Floating-Point Numbers
A Formally-Proved Algorithm to Compute the Correct Average of Decimal Floating-Point Numbers Sylvie Boldo, Florian Faissole, and Vincent Tourneur 1 ARITH-25 - June 26th 1 Thanks to the IEEE for the student
More informationFormal Verification of a Floating-Point Elementary Function
Introduction Coq & Flocq Coq.Interval Gappa Conclusion Formal Verification of a Floating-Point Elementary Function Inria Saclay Île-de-France & LRI, Université Paris Sud, CNRS 2015-06-25 Introduction Coq
More informationFormal Verification of Floating-Point programs
Formal Verification of Floating-Point programs Sylvie Boldo and Jean-Christophe Filliâtre Montpellier June, 26th 2007 INRIA Futurs CNRS, LRI Motivations Goal: reliability in numerical software Motivations
More informationFormal Verification of Programs Computing the Floating-Point Average
Formal Verification of Programs Computing the Floating-Point Average Sylvie Boldo (B) LRI, Bâtiment 650, Inria, Université Paris-Sud, 91405 Orsay Cedex, France Sylvie.Boldo@inria.fr Abstract. The most
More informationA Formally-Proved Algorithm to Compute the Correct Average of Decimal Floating-Point Numbers
A Formally-Proved Algorithm to Compute the Correct Average of Decimal Floating-Point Numbers Sylvie Boldo, Florian Faissole, Vincent Tourneur To cite this version: Sylvie Boldo, Florian Faissole, Vincent
More informationCombining Coq and Gappa for Certifying FP Programs
Introduction Example Gappa Tactic Conclusion Combining Coq and Gappa for Certifying Floating-Point Programs Sylvie Boldo Jean-Christophe Filliâtre Guillaume Melquiond Proval, Laboratoire de Recherche en
More informationSome issues related to double roundings
Some issues related to double roundings Erik Martin-Dorel 1 Guillaume Melquiond 2 Jean-Michel Muller 3 1 ENS Lyon, 2 Inria, 3 CNRS Valencia, June 2012 Martin-Dorel, Melquiond, Muller Some issues related
More informationA Formally-Proved Algorithm to Compute the Correct Average of Decimal Floating-Point Numbers
A Formally-Proved Algorithm to Compute the Correct Average of Decimal Floating-Point Numbers Sylvie Boldo, Florian Faissole, and Vincent Tourneur Inria LRI, CNRS & Univ. Paris-Sud, Université Paris-Saclay,
More informationNumerical Computations and Formal Methods
Program verification Formal arithmetic Decision procedures Proval, Laboratoire de Recherche en Informatique INRIA Saclay IdF, Université Paris Sud, CNRS October 28, 2009 Program verification Formal arithmetic
More informationFlocq: A Unified Library for Proving Floating-point Algorithms in Coq
Flocq: A Unified Library for Proving Floating-point Algorithms in Coq Sylvie Boldo INRIA Saclay - Île-de-France, ProVal, Orsay, F-91893 LRI, Univ Paris-Sud, CNRS, Orsay, F-91405 Email: Sylvie.Boldo@inria.fr
More informationWhen double rounding is odd
When double rounding is odd Sylvie Boldo and Guillaume Melquiond Laboratoire de l Informatique du Parallélisme UMR 5668 CNRS, ENS Lyon, INRIA, UCBL 46 allée d Italie, 69 364 Lyon Cedex 07, France E-mail:
More informationFlocq: A Unified Library for Proving Floating-point Algorithms in Coq
Flocq: A Unified Library for Proving Floating-point Algorithms in Coq Sylvie Boldo, Guillaume Melquiond To cite this version: Sylvie Boldo, Guillaume Melquiond. Flocq: A Unified Library for Proving Floating-point
More informationA Parameterized Floating-Point Formalizaton in HOL Light
NSV 2015 A Parameterized Floating-Point Formalizaton in HOL Light Charles Jacobsen a,1,2 Alexey Solovyev a,3,5 Ganesh Gopalakrishnan a,4,5 a School of Computing University of Utah Salt Lake City, USA Abstract
More informationProof of Properties in FP Arithmetic
Proof of Properties in Floating-Point Arithmetic LMS Colloquium Verification and Numerical Algorithms Jean-Michel Muller CNRS - Laboratoire LIP (CNRS-INRIA-ENS Lyon-Université de Lyon) http://perso.ens-lyon.fr/jean-michel.muller/
More informationCS321 Introduction To Numerical Methods
CS3 Introduction To Numerical Methods Fuhua (Frank) Cheng Department of Computer Science University of Kentucky Lexington KY 456-46 - - Table of Contents Errors and Number Representations 3 Error Types
More informationFloating-Point Arithmetic
Floating-Point Arithmetic ECS30 Winter 207 January 27, 207 Floating point numbers Floating-point representation of numbers (scientific notation) has four components, for example, 3.46 0 sign significand
More informationFloating-Point Arithmetic
Floating-Point Arithmetic Raymond J. Spiteri Lecture Notes for CMPT 898: Numerical Software University of Saskatchewan January 9, 2013 Objectives Floating-point numbers Floating-point arithmetic Analysis
More informationFloating Point (with contributions from Dr. Bin Ren, William & Mary Computer Science)
Floating Point (with contributions from Dr. Bin Ren, William & Mary Computer Science) Floating Point Background: Fractional binary numbers IEEE floating point standard: Definition Example and properties
More information1.2 Round-off Errors and Computer Arithmetic
1.2 Round-off Errors and Computer Arithmetic 1 In a computer model, a memory storage unit word is used to store a number. A word has only a finite number of bits. These facts imply: 1. Only a small set
More informationFloating-point representation
Lecture 3-4: Floating-point representation and arithmetic Floating-point representation The notion of real numbers in mathematics is convenient for hand computations and formula manipulations. However,
More informationComputer Architecture Chapter 3. Fall 2005 Department of Computer Science Kent State University
Computer Architecture Chapter 3 Fall 2005 Department of Computer Science Kent State University Objectives Signed and Unsigned Numbers Addition and Subtraction Multiplication and Division Floating Point
More informationFloating Point Arithmetic
Floating Point Arithmetic CS 365 Floating-Point What can be represented in N bits? Unsigned 0 to 2 N 2s Complement -2 N-1 to 2 N-1-1 But, what about? very large numbers? 9,349,398,989,787,762,244,859,087,678
More information2 Computation with Floating-Point Numbers
2 Computation with Floating-Point Numbers 2.1 Floating-Point Representation The notion of real numbers in mathematics is convenient for hand computations and formula manipulations. However, real numbers
More informationFloating-Point Numbers in Digital Computers
POLYTECHNIC UNIVERSITY Department of Computer and Information Science Floating-Point Numbers in Digital Computers K. Ming Leung Abstract: We explain how floating-point numbers are represented and stored
More informationFloating Point Representation. CS Summer 2008 Jonathan Kaldor
Floating Point Representation CS3220 - Summer 2008 Jonathan Kaldor Floating Point Numbers Infinite supply of real numbers Requires infinite space to represent certain numbers We need to be able to represent
More informationWhat Every Computer Scientist Should Know About Floating Point Arithmetic
What Every Computer Scientist Should Know About Floating Point Arithmetic E Note This document is an edited reprint of the paper What Every Computer Scientist Should Know About Floating-Point Arithmetic,
More informationChapter 2 Float Point Arithmetic. Real Numbers in Decimal Notation. Real Numbers in Decimal Notation
Chapter 2 Float Point Arithmetic Topics IEEE Floating Point Standard Fractional Binary Numbers Rounding Floating Point Operations Mathematical properties Real Numbers in Decimal Notation Representation
More informationMathematical preliminaries and error analysis
Mathematical preliminaries and error analysis Tsung-Ming Huang Department of Mathematics National Taiwan Normal University, Taiwan August 28, 2011 Outline 1 Round-off errors and computer arithmetic IEEE
More informationBuilt-in Treatment of an Axiomatic Floating-Point Theory for SMT Solvers
Built-in Treatment of an Axiomatic Floating-Point Theory for SMT Solvers Sylvain Conchon LRI, Université Paris Sud Guillaume Melquiond INRIA Saclay Île-de-France Cody Roux LRI, Université Paris Sud Mohamed
More information2 Computation with Floating-Point Numbers
2 Computation with Floating-Point Numbers 2.1 Floating-Point Representation The notion of real numbers in mathematics is convenient for hand computations and formula manipulations. However, real numbers
More informationFloating-Point Numbers in Digital Computers
POLYTECHNIC UNIVERSITY Department of Computer and Information Science Floating-Point Numbers in Digital Computers K. Ming Leung Abstract: We explain how floating-point numbers are represented and stored
More informationLecture 2 MODES OF NUMERICAL COMPUTATION
1. Diversity of Numbers Lecture 2 Page 1 It is better to solve the right problem the wrong way than to solve the wrong problem the right way. The purpose of computing is insight, not numbers. Richard Wesley
More informationFloating Point January 24, 2008
15-213 The course that gives CMU its Zip! Floating Point January 24, 2008 Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties class04.ppt 15-213, S 08 Floating
More informationFloating point numbers in Scilab
Floating point numbers in Scilab Michaël Baudin May 2011 Abstract This document is a small introduction to floating point numbers in Scilab. In the first part, we describe the theory of floating point
More informationDivide: Paper & Pencil
Divide: Paper & Pencil 1001 Quotient Divisor 1000 1001010 Dividend -1000 10 101 1010 1000 10 Remainder See how big a number can be subtracted, creating quotient bit on each step Binary => 1 * divisor or
More informationGenerating formally certified bounds on values and round-off errors
Generating formally certified bounds on values and round-off errors Marc DAUMAS and Guillaume MELQUIOND LIP Computer Science Laboratory UMR 5668 CNRS ENS Lyon INRIA UCBL Lyon, France Generating formally
More informationFloating Point Representation in Computers
Floating Point Representation in Computers Floating Point Numbers - What are they? Floating Point Representation Floating Point Operations Where Things can go wrong What are Floating Point Numbers? Any
More informationWhat Every Computer Scientist Should Know About Floating-Point Arithmetic
Page 1 of 87 Numerical Computation Guide Appendix D What Every Computer Scientist Should Know About Floating- Point Arithmetic Note This appendix is an edited reprint of the paper What Every Computer Scientist
More informationFormal Certification of Arithmetic Filters for Geometric Predicates
Introduction Formalization Implementation Conclusion Formal Certification of Arithmetic Filters for Geometric Predicates Guillaume Melquiond Sylvain Pion Arénaire, LIP ENS Lyon Geometrica, INRIA Sophia-Antipolis
More informationWhen double rounding is odd
Laboratoire de l Informatique du Parallélisme École Normale Supérieure de Lyon Unité Mixte de Recherche CNRS-INRIA-ENS LYON-UCBL n o 5668 When double rounding is odd Sylvie Boldo, Guillaume Melquiond November
More informationRoundoff Errors and Computer Arithmetic
Jim Lambers Math 105A Summer Session I 2003-04 Lecture 2 Notes These notes correspond to Section 1.2 in the text. Roundoff Errors and Computer Arithmetic In computing the solution to any mathematical problem,
More informationSystem Programming CISC 360. Floating Point September 16, 2008
System Programming CISC 360 Floating Point September 16, 2008 Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Powerpoint Lecture Notes for Computer Systems:
More informationComputational Mathematics: Models, Methods and Analysis. Zhilin Li
Computational Mathematics: Models, Methods and Analysis Zhilin Li Chapter 1 Introduction Why is this course important (motivations)? What is the role of this class in the problem solving process using
More informationComputational Methods. Sources of Errors
Computational Methods Sources of Errors Manfred Huber 2011 1 Numerical Analysis / Scientific Computing Many problems in Science and Engineering can not be solved analytically on a computer Numeric solutions
More informationComputer Arithmetic. 1. Floating-point representation of numbers (scientific notation) has four components, for example, 3.
ECS231 Handout Computer Arithmetic I: Floating-point numbers and representations 1. Floating-point representation of numbers (scientific notation) has four components, for example, 3.1416 10 1 sign significandbase
More informationFloating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754
Floating Point Puzzles Topics Lecture 3B Floating Point IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties For each of the following C expressions, either: Argue that
More informationFloating Point Puzzles The course that gives CMU its Zip! Floating Point Jan 22, IEEE Floating Point. Fractional Binary Numbers.
class04.ppt 15-213 The course that gives CMU its Zip! Topics Floating Point Jan 22, 2004 IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Floating Point Puzzles For
More informationRepresenting and Manipulating Floating Points
Representing and Manipulating Floating Points Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu The Problem How to represent fractional values with
More informationSystems I. Floating Point. Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties
Systems I Floating Point Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties IEEE Floating Point IEEE Standard 754 Established in 1985 as uniform standard for
More informationFloating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754
Floating Point Puzzles Topics Lecture 3B Floating Point IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties For each of the following C expressions, either: Argue that
More informationCombining Coq and Gappa for Certifying Floating-Point Programs
Combining Coq and Gappa for Certifying Floating-Point Programs Sylvie Boldo 1,2, Jean-Christophe Filliâtre 2,1, and Guillaume Melquiond 1,2 1 INRIA Saclay - Île-de-France, ProVal, Orsay, F-91893 2 LRI,
More informationDeductive Verification in Frama-C and SPARK2014: Past, Present and Future
Deductive Verification in Frama-C and SPARK2014: Past, Present and Future Claude Marché (Inria & Université Paris-Saclay) OSIS, Frama-C & SPARK day, May 30th, 2017 1 / 31 Outline Why this joint Frama-C
More informationCertifying the floating-point implementation of an elementary function using Gappa
1 Certifying the floating-point implementation of an elementary function using Gappa Florent de Dinechin, Member, IEEE, Christoph Lauter, and Guillaume Melquiond Abstract High confidence in floating-point
More informationBindel, Fall 2016 Matrix Computations (CS 6210) Notes for
1 Logistics Notes for 2016-09-07 1. We are still at 50. If you are still waiting and are not interested in knowing if a slot frees up, let me know. 2. There is a correction to HW 1, problem 4; the condition
More informationIntroduction to floating point arithmetic
Introduction to floating point arithmetic Matthias Petschow and Paolo Bientinesi AICES, RWTH Aachen petschow@aices.rwth-aachen.de October 24th, 2013 Aachen, Germany Matthias Petschow (AICES, RWTH Aachen)
More informationFloating Point. The World is Not Just Integers. Programming languages support numbers with fraction
1 Floating Point The World is Not Just Integers Programming languages support numbers with fraction Called floating-point numbers Examples: 3.14159265 (π) 2.71828 (e) 0.000000001 or 1.0 10 9 (seconds in
More informationRepresenting and Manipulating Floating Points
Representing and Manipulating Floating Points Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu The Problem How to represent fractional values with
More informationEE878 Special Topics in VLSI. Computer Arithmetic for Digital Signal Processing
EE878 Special Topics in VLSI Computer Arithmetic for Digital Signal Processing Part 4-B Floating-Point Arithmetic - II Spring 2017 Koren Part.4b.1 The IEEE Floating-Point Standard Four formats for floating-point
More informationNumerical Computing: An Introduction
Numerical Computing: An Introduction Gyula Horváth Horvath@inf.u-szeged.hu Tom Verhoeff T.Verhoeff@TUE.NL University of Szeged Hungary Eindhoven University of Technology The Netherlands Numerical Computing
More informationFloating Point Numbers
Floating Point Numbers Computer Systems Organization (Spring 2016) CSCI-UA 201, Section 2 Instructor: Joanna Klukowska Slides adapted from Randal E. Bryant and David R. O Hallaron (CMU) Mohamed Zahran
More informationFloating Point Numbers
Floating Point Numbers Computer Systems Organization (Spring 2016) CSCI-UA 201, Section 2 Fractions in Binary Instructor: Joanna Klukowska Slides adapted from Randal E. Bryant and David R. O Hallaron (CMU)
More informationRev Name Date. . Round-off error is the answer to the question How wrong is the rounded answer?
Name Date TI-84+ GC 7 Avoiding Round-off Error in Multiple Calculations Objectives: Recall the meaning of exact and approximate Observe round-off error and learn to avoid it Perform calculations using
More informationCS321. Introduction to Numerical Methods
CS31 Introduction to Numerical Methods Lecture 1 Number Representations and Errors Professor Jun Zhang Department of Computer Science University of Kentucky Lexington, KY 40506 0633 August 5, 017 Number
More informationVocabulary: Looking For Pythagoras
Vocabulary: Looking For Pythagoras Concept Finding areas of squares and other figures by subdividing or enclosing: These strategies for finding areas were developed in Covering and Surrounding. Students
More informationComputing Integer Powers in Floating-Point Arithmetic
Computing Integer Powers in Floating-Point Arithmetic Peter Kornerup Vincent Lefèvre Jean-Michel Muller May 2007 This is LIP Research Report number RR2007-23 Ceci est le Rapport de Recherches numéro RR2007-23
More informationUNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Digital Computer Arithmetic ECE 666
UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering Digital Computer Arithmetic ECE 666 Part 4-B Floating-Point Arithmetic - II Israel Koren ECE666/Koren Part.4b.1 The IEEE Floating-Point
More informationFloating Point Numbers. Lecture 9 CAP
Floating Point Numbers Lecture 9 CAP 3103 06-16-2014 Review of Numbers Computers are made to deal with numbers What can we represent in N bits? 2 N things, and no more! They could be Unsigned integers:
More informationComputing predecessor and successor in rounding to nearest
Computing predecessor and successor in rounding to nearest Siegfried Rump, Paul Zimmermann, Sylvie Boldo, Guillaume Melquiond To cite this version: Siegfried Rump, Paul Zimmermann, Sylvie Boldo, Guillaume
More informationRepresenting and Manipulating Floating Points. Jo, Heeseung
Representing and Manipulating Floating Points Jo, Heeseung The Problem How to represent fractional values with finite number of bits? 0.1 0.612 3.14159265358979323846264338327950288... 2 Fractional Binary
More informationRepresenting and Manipulating Floating Points. Computer Systems Laboratory Sungkyunkwan University
Representing and Manipulating Floating Points Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu The Problem How to represent fractional values with
More informationRepresenting and Manipulating Floating Points
Representing and Manipulating Floating Points Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu SSE23: Introduction to Computer Systems, Spring 218,
More informationWhy3 where programs meet provers
Why3 where programs meet provers Jean-Christophe Filliâtre CNRS KeY Symposium 2017 Rastatt, Germany October 5, 2017 history started in 2001, as an intermediate language in the process of verifying C and
More informationGiving credit where credit is due
CSCE 230J Computer Organization Floating Point Dr. Steve Goddard goddard@cse.unl.edu http://cse.unl.edu/~goddard/courses/csce230j Giving credit where credit is due Most of slides for this lecture are based
More informationFloating Point Numbers
Floating Point Numbers Summer 8 Fractional numbers Fractional numbers fixed point Floating point numbers the IEEE 7 floating point standard Floating point operations Rounding modes CMPE Summer 8 Slides
More informationOptimized Binary64 and Binary128 Arithmetic with GNU MPFR (common work with Vincent Lefèvre)
Arith 24 conference, London, July 24, 2017 Optimized Binary64 and Binary128 Arithmetic with GNU MPFR (common work with Vincent Lefèvre) Paul Zimmermann Introducing the GNU MPFR library a software implementation
More informationGiving credit where credit is due
JDEP 284H Foundations of Computer Systems Floating Point Dr. Steve Goddard goddard@cse.unl.edu Giving credit where credit is due Most of slides for this lecture are based on slides created by Drs. Bryant
More informationObjectives. look at floating point representation in its basic form expose errors of a different form: rounding error highlight IEEE-754 standard
Floating Point Objectives look at floating point representation in its basic form expose errors of a different form: rounding error highlight IEEE-754 standard 1 Why this is important: Errors come in two
More informationUNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Digital Computer Arithmetic ECE 666
UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering Digital Computer Arithmetic ECE 666 Part 4-C Floating-Point Arithmetic - III Israel Koren ECE666/Koren Part.4c.1 Floating-Point Adders
More informationAvoiding double roundings in scaled Newton-Raphson division
Avoiding double roundings in scaled Newton-Raphson division Jean-Michel Muller To cite this version: Jean-Michel Muller. Avoiding double roundings in scaled Newton-Raphson division. Asilomar Conference
More informationClasses of Real Numbers 1/2. The Real Line
Classes of Real Numbers All real numbers can be represented by a line: 1/2 π 1 0 1 2 3 4 real numbers The Real Line { integers rational numbers non-integral fractions irrational numbers Rational numbers
More informationComputer arithmetics: integers, binary floating-point, and decimal floating-point
n!= 0 && -n == n z+1 == z Computer arithmetics: integers, binary floating-point, and decimal floating-point v+w-w!= v x+1 < x Peter Sestoft 2010-02-16 y!= y p == n && 1/p!= 1/n 1 Computer arithmetics Computer
More informationA Unified Coq Framework for Verifying C Programs with Floating-Point Computations
A Unified Coq Framework for Verifying C Programs with Floating-Point Computations Tahina Ramananandro Paul Mountcastle Benoît Meister Richard Lethin Reservoir Labs Inc., USA lastname@reservoir.com Abstract
More informationCSCI 402: Computer Architectures. Arithmetic for Computers (3) Fengguang Song Department of Computer & Information Science IUPUI.
CSCI 402: Computer Architectures Arithmetic for Computers (3) Fengguang Song Department of Computer & Information Science IUPUI 3.5 Today s Contents Floating point numbers: 2.5, 10.1, 100.2, etc.. How
More informationComputer Organization: A Programmer's Perspective
A Programmer's Perspective Representing Numbers Gal A. Kaminka galk@cs.biu.ac.il Fractional Binary Numbers 2 i 2 i 1 4 2 1 b i b i 1 b 2 b 1 b 0. b 1 b 2 b 3 b j 1/2 1/4 1/8 Representation Bits to right
More informationMAT128A: Numerical Analysis Lecture Two: Finite Precision Arithmetic
MAT128A: Numerical Analysis Lecture Two: Finite Precision Arithmetic September 28, 2018 Lecture 1 September 28, 2018 1 / 25 Floating point arithmetic Computers use finite strings of binary digits to represent
More informationComputational Economics and Finance
Computational Economics and Finance Part I: Elementary Concepts of Numerical Analysis Spring 2016 Outline Computer arithmetic Error analysis: Sources of error Error propagation Controlling the error Rates
More informationBinary floating point encodings
Week 1: Wednesday, Jan 25 Binary floating point encodings Binary floating point arithmetic is essentially scientific notation. Where in decimal scientific notation we write in floating point, we write
More informationVerified Compilation of Floating-Point Computations
Journal of Automated Reasoning manuscript No. (will be inserted by the editor) Verified Compilation of Floating-Point Computations Sylvie Boldo Jacques-Henri Jourdan Xavier Leroy Guillaume Melquiond the
More informationUser s Guide for Gappa. Guillaume Melquiond
User s Guide for Gappa Guillaume Melquiond Contents 1 Introduction 1 2 Invoking Gappa 3 2.1 Input and output................................................... 3 2.2 Command-line options...............................................
More informationIEEE Floating Point Numbers Overview
COMP 40: Machine Structure and Assembly Language Programming (Fall 2015) IEEE Floating Point Numbers Overview Noah Mendelsohn Tufts University Email: noah@cs.tufts.edu Web: http://www.cs.tufts.edu/~noah
More informationLecture 13: (Integer Multiplication and Division) FLOATING POINT NUMBERS
Lecture 13: (Integer Multiplication and Division) FLOATING POINT NUMBERS Lecture 13 Floating Point I (1) Fall 2005 Integer Multiplication (1/3) Paper and pencil example (unsigned): Multiplicand 1000 8
More information11 1. Introductory part In order to follow the contents of this book with full understanding, certain prerequisites from high school mathematics will
11 1. Introductory part In order to follow the contents of this book with full understanding, certain prerequisites from high school mathematics will be necessary. This firstly pertains to the basic concepts
More informationFoundations of Computer Systems
18-600 Foundations of Computer Systems Lecture 4: Floating Point Required Reading Assignment: Chapter 2 of CS:APP (3 rd edition) by Randy Bryant & Dave O Hallaron Assignments for This Week: Lab 1 18-600
More informationFormal Verification of Floating-Point Programs
Formal Verification of Floating-Point Programs Sylvie Boldo INRIA Futurs Sylvie.Boldo@inria.fr Jean-Christophe Filliâtre CNRS Jean-Christophe.Filliatre@lri.fr ProVal, Parc Orsay Université, F-91893 LRI,
More informationAMTH142 Lecture 10. Scilab Graphs Floating Point Arithmetic
AMTH142 Lecture 1 Scilab Graphs Floating Point Arithmetic April 2, 27 Contents 1.1 Graphs in Scilab......................... 2 1.1.1 Simple Graphs...................... 2 1.1.2 Line Styles........................
More informationReview of Calculus, cont d
Jim Lambers MAT 460/560 Fall Semester 2009-10 Lecture 4 Notes These notes correspond to Sections 1.1 1.2 in the text. Review of Calculus, cont d Taylor s Theorem, cont d We conclude our discussion of Taylor
More informationComputer Architecture and IC Design Lab. Chapter 3 Part 2 Arithmetic for Computers Floating Point
Chapter 3 Part 2 Arithmetic for Computers Floating Point Floating Point Representation for non integral numbers Including very small and very large numbers 4,600,000,000 or 4.6 x 10 9 0.0000000000000000000000000166
More informationChapter 3. Errors and numerical stability
Chapter 3 Errors and numerical stability 1 Representation of numbers Binary system : micro-transistor in state off 0 on 1 Smallest amount of stored data bit Object in memory chain of 1 and 0 10011000110101001111010010100010
More informationImproving Coq Propositional Reasoning Using a Lazy CNF Conversion
Using a Lazy CNF Conversion Stéphane Lescuyer Sylvain Conchon Université Paris-Sud / CNRS / INRIA Saclay Île-de-France FroCoS 09 Trento 18/09/2009 Outline 1 Motivation and background Verifying an SMT solver
More informationFloating Point Arithmetic
Floating Point Arithmetic Clark N. Taylor Department of Electrical and Computer Engineering Brigham Young University clark.taylor@byu.edu 1 Introduction Numerical operations are something at which digital
More information