Interval Arithmetic Kwang Hee Ko School of Mechatronics Gwangju Institute of Science and Technology.

Slides:



Advertisements
Similar presentations
Microcomputer Systems 1
Advertisements

Roundoff and truncation errors
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 2: Data types and addressing modes dr.ir. A.C. Verschueren.
2009 Spring Errors & Source of Errors SpringBIL108E Errors in Computing Several causes for malfunction in computer systems. –Hardware fails –Critical.
CML CML CS 230: Computer Organization and Assembly Language Aviral Shrivastava Department of Computer Science and Engineering School of Computing and Informatics.
Fabián E. Bustamante, Spring 2007 Floating point Today IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Next time.
Topics covered: Floating point arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
2-1 Chapter 2 - Data Representation Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer Architecture.
Chapter 2: Data Representation
Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 2: Data Representation.
Chapter 8 Representing Information Digitally.
University of Washington Today Topics: Floating Point Background: Fractional binary numbers IEEE floating point standard: Definition Example and properties.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Introduction.
Representation and Conversion of Numeric Types 4 We have seen multiple data types that C provides for numbers: int and double 4 What differences are there.
Number Systems Lecture 02.
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?)
1 Preliminaries Precalculus Review I Precalculus Review II
Numerical Computations in Linear Algebra. Mathematically posed problems that are to be solved, or whose solution is to be confirmed on a digital computer.
Information Representation (Level ISA3) Floating point numbers.
Computer Organization and Architecture Computer Arithmetic Chapter 9.
Computer Arithmetic Nizamettin AYDIN
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
CEN 316 Computer Organization and Design Computer Arithmetic Floating Point Dr. Mansour AL Zuair.
Fixed-Point Arithmetics: Part II
Computer Science 111 Fundamentals of Programming I Number Systems.
IT253: Computer Organization
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 22, 2004 Lecture Number: 24.
Computing Systems Basic arithmetic for computers.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles of Computer.
Fall 2011SYSC 5704: Elements of Computer Systems 1 Data Representation Also called Encoding Murdocca Chapter 2.
Data Representation in Computer Systems
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
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.
Robustness in Numerical Computation I Root Finding Kwanghee Ko School of Mechatronics Gwnagju Institute of Science and Technology.
Number Representation for
Numerical Methods.
Computer Arithmetic Floating Point. We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large.
CDA 3101 Fall 2013 Introduction to Computer Organization
Cosc 2150: Computer Organization Chapter 9, Part 3 Floating point numbers.
MATH Lesson 2 Binary arithmetic.
CHAPTER 5: Representing Numerical Data
Floating Point Representations
Computation of the solutions of nonlinear polynomial systems
Integer Division.
Topics IEEE Floating Point Standard Rounding Floating Point Operations
CS 105 “Tour of the Black Holes of Computing!”
Chapter 6 Floating Point
Floating Point.
CSCE 350 Computer Architecture
Introduction to Abstract Data Types
CS201 - Lecture 5 Floating Point
CS 105 “Tour of the Black Holes of Computing!”
Approximations and Round-Off Errors Chapter 3
CS 105 “Tour of the Black Holes of Computing!”
CS 105 “Tour of the Black Holes of Computing!”
CS213 Floating Point Topics IEEE Floating Point Standard Rounding
Topic 3d Representation of Real Numbers
CS 105 “Tour of the Black Holes of Computing!”
Computer Organization and Assembly Language
CS 105 “Tour of the Black Holes of Computing!”
Presentation transcript:

Interval Arithmetic Kwang Hee Ko School of Mechatronics Gwangju Institute of Science and Technology

Interval Numbers  An interval number is defined as  An ordered pair of real numbers denoted by [a,b]  It is a set of real numbers x such that  [a,b] = {x|a ≤ x ≤ b}  Operations in set theory can be applied.  Two intervals [a,b] and [c,d] are said to be equal if  a=c and b=d  The intersection of two intervals is empty of [a,b]∩[c,d] = 0 if either  a > d or c > b  Otherwise [a,b]∩[c,d]=[max(a,c),min(b,d)]  The union of the two intersecting intervals is  [a,b] ∪ [c,d]=[min(a,c),max(b,d)]

Interval Numbers  An order of intervals is defined by  [a,b]<[c,d] if and only if b < c  Width: w([a,b]) = b-a  Magnitute: |[a,b]| = max(|a|,|b|)  Examples  [2,4]∩[3,5] = [3,4]  [2,4]U[3,5] = [2,5]  |[-7,-2]| = 7

Interval Arithmetic  Exact-Interval Arithmetic: an extension of real arithmetic. We assume that endpoints are computed with infinite precision.  Basic arithmetic operations: +,-,·,/ [a,b]*[c,d] = {x*y| a ≤ x ≤ b, c ≤ y ≤ d} 0 ∈ [c,d]

Interval Arithmetic  Examples  [2,4]+[3,5] = [2+3,4+5] = [5,9]  [2,4]-[3,5] = [2-5,4-3] = [-3,1]  [2,4]*[3,5]=[min(2*3,2*5,4*3,4*5),max(2*3,2*5,4*3,4*5)]=[6,20]  [2,4]/[3,5]=[min(2/3,2/5,4/3,4/5),max(2/3,2/5,4 /3,4/5)]=[2/5,4/3]

Interval Arithmetic  Interval arithmetic is associative, commutative.  NOT distributive but subdistributive [a,b] ᆞ [e,f]

Interval Arithmetic  Example of being subdistributive  [1,2]*([1,2]-[1,2]) = [1,2]*([-1,1])=[-2,2]  [1,2]*[1,2] – [1,2]*[1,2] = [1,4]-[1,4] = [-3,3]  [-2,2] ⊆ [-3,3]

Interval Arithmetic  Inclusion Monotonic  If I ⊂ K, J ⊂ L  I + J ⊂ K + L  I – J ⊂ K – L  IJ ⊂ KL  I/J ⊂ K/L (if 0 ∈ L)

Rounded Interval Arithmetic  If floating point arithmetic is used to evaluate these interval arithmetic equations, there is no guarantee that the roundings of the bounds are performed conservatively.  Rounded interval arithmetic (RIA) ensures that the computed end points always contain the exact interval.

IEEE 754 Standard format of Floating Point Arithmetic  Units-in-last-place, ulp l, ulp u for each separate floating point number.  Concept  To calculate ulp it is necessary to extract the integer value of the exponent from the binary representation.  Recall that the value of the significand B of a double precision number X is  X = (-1) s 2 E B with B = 1+b b …+b  The value of the least significant bit b 52 is  Thus, the value of ulp is 2 E = 2 E-52.

IEEE 754 Standard format of Floating Point Arithmetic  Using the C standard functions frexp() and ldexp().  Because of the use of standard library functions, this implementation is slow. #include double ulp(double x) { double ulp; int exp; frexp(x,&exp); /* extract exponent of x */ ulp = ldexp(0.5,exp-52); /* calculate ulp = 0.5^(exp-52) */ return ulp; }

IEEE 754 Standard format of Floating Point Arithmetic  To avoid using the library functions and to construct the ulp directly…  The biased exponent e occupies bits 52 through 62.  If we could manipulate the binary representation as a 64-bit integer, we could extract e by dividing by  Right-shift the bit pattern by 52 bits, placing e in bits 10 through 0.  The sign bit would then occupy bit 11, could be removed by performing a bitwise logical AND with the 64-bit mask 0…  Most commercial processors and programming languages do not support 64-bit integers; generally, only 8, 16 and 32-bit integers are available.  To overcome this limitation, we can overlay the storage location of the 640bit double precision number with an array of four 16- bit integers (short type)

IEEE 754 Standard format of Floating Point Arithmetic  In C or C++ this can be accomplished using the union data structure  typedef union { double dp; /* the 64-bit double precision value */ unsigned short sh[4] /* overlay an array of 4 16-bit integers*/ } Double  After the assignment  Double x;  Double D;  D.dp = x;

IEEE 754 Standard format of Floating Point Arithmetic  In C or C++ this can be accomplished using the union data structure  The exponent of the variable x can be extracted from D.sh[0], whose 16 bits contain  the sign bit s (bit 15),  the 11-bit biased exponent e (bits 14 through 4)  The 4 most significant bits b 1 b 2 b 3 b 4 of the mantissa m (bits 3 through 0)  The biased exponent e can be extracted from D.sh[0] by performing a bitwise logical AND with the 16-bit mask to zero-out the sign bit and the four most significant bits of the mantissa and then right-shifting e by 4 bits. Then the unbiased exponent E = e-1023.

IEEE 754 Standard format of Floating Point Arithmetic  Algorithm

IEEE 754 Standard format of Floating Point Arithmetic  Comparison of two different implementations  The timings (in CPU seconds) were taken on a 100MHz RISC processor.  The values are the accumulated CPU times to perform 100,000 calculations of the ulp of various representative values of X.

IEEE 754 Standard format of Floating Point Arithmetic  Software/hardware roundings in implementation of rounded interval arithmetic  The software rounding method is computationally more expensive than hardware rounding, requiring an extra addition and subtraction and the computation of the ulp of two values.  The software rounding method extends the upper and lower bounds of the interval during every arithmetic operation.  Hardware rounding is superior to software rounding.  Set a CPU flag for appropriate roundings.  The hardware rounding method only extends the bounds when the result of the operation cannot be exactly represented, producing tighter interval bounds.

IEEE 754 Standard format of Floating Point Arithmetic  Whenever an exact value cannot be represented in a given precision, rounding occurs.  IEEE 754 Standard specifies four rounding modes: round to nearest, round to positive infinity, round to negative infinity and round to zero.  As default, the standard sets the round to nearest mode.

IEEE 754 Standard format of Floating Point Arithmetic  MS Windows (Visual C++)  Linux (Refer to ‘fpu_control.h’ file)  _FPU_SETCW(arg)  -infinity: arg = 0x077f  +infinity: arg = 0x0b7f  Nearest : arg = … double a, b, cLower, cUpper; … _controlfp( _RC_DOWN, _MCW_RC ); // round to -infinity cLower = a*b; _controlfp( _RC_UP, _MCW_RC ); // round to +infinity cUpper = a*b; _controlfp( _RC_NEAR, _MCW_RC ); // restore rounding mode

RIA Implementation  Use C++ class Interval { Private: double low,double upp; … }; Interval operator+(Interval a,Interval b) { Interval c; _controlfp( _RC_DOWN, _MCW_RC ); c.low = a.low+b.low; _controlfp( _RC_UP, _MCW_RC ); c.upp = a.upp + b.upp; _controlfp( _RC_NEAR, _MCW_RC ); return c; }

RIA Implementation  We can define various additional operations and functions other than basic arithmetic ones in terms of interval arithmetic.  Sqrt, exp, sin, cos, etc.  Disadvantages  Performance is slower than floating point arithmetic.  It tends to suffer overestimation of intervals during computation.

Alternative to Interval Arithmetic  Affine Arithmetic  Conceptually similar to interval arithmetic in that affine arithmetic also maintains a range containing the exact value.  But it works better to control the size of a range.

Robustness Issues  Suppose we have a degree four planar Bezier curve whose control points are given by  (-0.5,0.0635), (-0.25, ), (0,0.0625), (0.25, ), (0.5,0.0625)  It is equivalent to the explicit curve y=x 4 (-0.5 ≤ x ≤ 0.5)  The curve intersects with x-axis tangentially at (x,y) = (0,0)

Robustness Issues  We translate the curve by +1 in the y direction and translate it back to the original position by moving it by -1/3 three times.  The curve is generally not the same as the original one in floating point arithmetic.  Ex.) We evaluate the curve at parameter value t=0.5 to get (0, ) instead of (0,0).  This is a serious change of topological structure of the curve.  Intersection -> no intersection  Geometric operations in floating point arithmetic is subjected to such errors.

 Floating Point Arithmetic  Limited precision / errors due to rounding : possibility of missing roots Number of roots = 17 Root 1: 1 Root 2: 0.95 Root 3: Root 4: Root 5: Root 6: Root 7: Root 8: Root 9: Root 10: Root 11: Root 12: Root 13: Root 14: Root 15: Root 16: Root 17: Robustness Issues

Examples in Real World  Some disasters attributable to bad numerical computing in real life  Patriot Missile Failure: in Dharan, Saudi Arabia, on February 25, This is ultimately attributable to poor handling of rounding errors  Explosion of the Ariane 5 rocket: Just after lift-off on its maiden voyage off French Guiana, on June 4, 1996, it exploded, which was ultimately the consequence of a simple overflow.  The sinking of the Sleipner A offshore platform: Due to inaccurate finite element analysis, the platform sank down to the ocean floor costing nearly one billion dollars.

The Patriot Missile Failure  Inaccurate time computation  The time in tenths of second as measured by the system’s internal clock was multiplied by 1/10 to produce the time in seconds.  The calculation was performed using a 24 bit fixed point register.  The value 1/10 is a non-terminating binary expansion, which is chopped at 24 bits.  1/10 = 1/ / /2 8 + …  The Patriot missile stores 24 bits only.  An error, , is introduced.  100 hour operation -> * 100 * 60 * 60 * 10 = 0.34sec. This is enough time to miss a Scud since during 0.34 sec, the Scud travels more than half a kilometer.

Ariane 5 Rocket Explosion  Insufficient Precision  Ariane 5, which is worth 7 billion dollars crashed in less than a minute after lift-off.  A small computer program is to blame for the crash which tries to stuff a 64-bit number into a 16-bit space.  At the bottom of a sequence of events to disaster, conversion of velocity data in a 64-bit format to a 16- bit format triggered an overflow error, making the core system in the rocket shut down.

Robustness in Numerical Computation I Root Finding Kwanghee Ko School of Mechatronics Gwnagju Institute of Science and Technology

Motivation  Why do we need a nonlinear polynomial solver? Many geometric problems are formulated as systems of nonlinear polynomial equations Distance function Intersections Curvature extrema, etc.

Solution Methods  Local Solution Methods Newton-type method good initial approximation No assurance that all roots have been found  Global Solution Methods Algebraic Type Methods Homotopy (Continuation) Methods Subdivision Methods

 Advantages Efficient and stable Easy to implement  Disadvantages No certainty that each root has been isolated No explicit information about root multiplicities  Example Algorithm Projected Polyhedron Algorithm

 Transform algebraic problems (finding roots) to geometric problems (computing intersections). Use a powerful geometric property, the convex hull property in the algorithm.  Input : a system of polynomial equations in Bernstein form.  Output : intervals (regions) which contain roots. Note : Conversion from power basis to Bernstein basis is unstable. So we need to use Bernstein polynomials from the beginning to formulate a problem.

Projected Polyhedron Algorithm (Univariate Polynomial Case) 1.Make an transformation such that the range t of a function f(t) is from 0 to 1. 2.Construct a graph (t,f(t)) 0 t1t1t1 t2t2 f(t)

Projected Polyhedron Algorithm (Univariate Polynomial Case) Construct the convex hull of the Bezier curve

Projected Polyhedron Algorithm (Univariate Polynomial Case) Intersect the convex hull with the parameter axis

Projected Polyhedron Algorithm (Univariate Polynomial Case) Discard the regions which do not contain roots after applying the de Casteljau subdivision algorithm Eliminate

Projected Polyhedron Algorithm (Multivariate Polynomial Case)  x = (x 1,x 2, …,x m ) independent variables  f 1 (x)=f 2 (x)= … =f n (x)=0  Algorithm  Affine Transformation : 0  x i  1, i=1, …,m  Construct a graph for each f j, j=1, …,n.  Project the control polygon of each f j onto m different coordinate (2D) plane, i.e. (x 1,x m+1 )-plane, …, (x m,x m+1 )-plane.  Construct n two dimensional convex hulls in each plane.  Intersect each convex hull with the horizontal axis : x 1, …,x m.  Compute intersection of all the intervals obtained at step 5.  If empty, no solution. If non-empty, discard the portions that do not contain roots.  Repeat.

Robustness Issues in Root Finding  Floating Point Arithmetic Limited precision / errors due to rounding : possibility of missing roots Number of roots = 17 Root 1: 1 Root 2: 0.95 Root 3: Root 4: Root 5: Root 6: Root 7: Root 8: Root 9: Root 10: Root 11: Root 12: Root 13: Root 14: Root 15: Root 16: Root 17:

How to Guarantee Robustness?  Rational / Exact Arithmetic Memory intensive and time consuming  Interval Arithmetic Inexpensive and robust Robustness Issues in Root Finding

Number of roots = 20 Root 1: [ , ] Root 2: [ , ] Root 3: [ , ] Root 4: [ , ] Root 5: [ , ] Root 6: [ , ] Root 7: [ , ] Root 8: [ , ] Root 9: [ , ] Root 10: [ , ] Root 11: [ , ] Root 12: [ , ] Root 13: [ , ] Root 14: [ , ] Root 15: [ , ] Root 16: [ , ] Root 17: [ , ] Root 18: [ , ] Root 19: [ , ] Root 20: [ , 1] Results in Rounded Interval Arithmetic Robustness Issues in Root Finding