interval arithmetic kwang hee ko school of mechatronics gwangju institute of science and technology

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

Upload: kerry-boone

Post on 29-Dec-2015

220 views

Category:

Documents


4 download

TRANSCRIPT

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

Interval Arithmetic

Kwang Hee KoSchool of Mechatronics

Gwangju Institute of Science and Technology

Page 2: 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)]

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

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

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

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]

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

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]

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

Interval Arithmetic

Interval arithmetic is associative, commutative.

NOT distributive but subdistributive

[a,b]ᆞ [e,f]

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

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]

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

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)

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

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.

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

IEEE 754 Standard format of Floating Point Arithmetic

Units-in-last-place, ulpl, ulpu 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)s2EB with B = 1+b12-1+b22-2+…+b522-52 The value of the least significant bit b52 is 2-52. Thus, the value of ulp is 2E2-52 = 2E-52.

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

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 <math.h>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;}

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

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 252. 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…011111111111.

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)

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

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;

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

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 b1b2b3b4 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 0111111111110000 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.

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

IEEE 754 Standard format of Floating Point Arithmetic

Algorithm

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

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.

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

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.

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

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.

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

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

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

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;

}

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

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.

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

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.

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

Robustness Issues Suppose we have a degree four planar

Bezier curve whose control points are given by (-0.5,0.0635), (-0.25,-0.0625), (0,0.0625),

(0.25,-0.0625), (0.5,0.0625) It is equivalent to the explicit curve y=x4 (-0.5

≤ x ≤ 0.5) The curve intersects with x-axis tangentially at

(x,y) = (0,0)

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

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,0.00035) 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.

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

Floating Point Arithmetic Limited precision / errors due to rounding :

possibility of missing roots

Number of roots = 17Root 1: 1Root 2: 0.95Root 3: 0.899999999995996Root 4: 0.849999999999972Root 5: 0.80000000000028Root 6: 0.70000000000294Root 7: 0.650000000006303Root 8: 0.599999999966461Root 9: 0.499999999996737Root 10: 0.449999999994588Root 11: 0.350000000000347Root 12: 0.300000000019175Root 13: 0.249999999996938Root 14: 0.20000000000004Root 15: 0.150000000000388Root 16: 0.100000000000162Root 17: 0.0500000000000002

0)20

()(20

1

ittf

i

Robustness Issues

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

Examples in Real World Some disasters attributable to bad

numerical computing in real life Patriot Missile Failure: in Dharan, Saudi Arabia,

on February 25, 1991. 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.

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

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/24 + 1/25 + 1/28 + … The Patriot missile stores 24 bits only. An error, 0.000000095, is introduced.

100 hour operation -> 0.000000095 * 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.

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

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.

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

Robustness in Numerical Computation I

Root Finding

Kwanghee KoSchool of Mechatronics

Gwnagju Institute of Science and Technology

Page 30: Interval Arithmetic Kwang Hee Ko School of Mechatronics Gwangju 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.

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

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

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

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

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

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.

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

Projected Polyhedron Algorithm(Univariate Polynomial Case)

1.1. Make an Make an transformatitransformation such that on such that the range the range tt of a function of a function f(t)f(t) is from 0 is from 0 to 1.to 1.

2.2. Construct a Construct a graph (graph (t,f(t)t,f(t)))

0 t1t1 t2

f(t)

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

Projected Polyhedron Algorithm (Univariate Polynomial Case)

Construct the Construct the convex hull of convex hull of the Bezier the Bezier curvecurve

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

Projected Polyhedron Algorithm (Univariate Polynomial Case)

Intersect the Intersect the convex hull convex hull with the with the parameter axisparameter axis

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

Projected Polyhedron Algorithm (Univariate Polynomial Case)

Discard the Discard the regions which regions which do not contain do not contain roots after roots after applying the applying the de Casteljau de Casteljau subdivision subdivision algorithmalgorithm Eliminate

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

Projected Polyhedron Algorithm (Multivariate Polynomial Case)

x = (x1,x2,…,xm) independent variables

f1(x)=f2(x)=…=fn(x)=0 Algorithm

1. Affine Transformation : 0 xi 1, i=1,…,m

2. Construct a graph for each fj, j=1,…,n.

3. Project the control polygon of each fj onto m different coordinate (2D) plane, i.e. (x1,xm+1)-plane, …, (xm,xm+1)-plane.

4. Construct n two dimensional convex hulls in each plane.5. Intersect each convex hull with the horizontal axis : x1,…,xm.

6. Compute intersection of all the intervals obtained at step 5.7. If empty, no solution. If non-empty, discard the portions that

do not contain roots.

8. Repeat.

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

Robustness Issues in Root Finding

Floating Point Arithmetic• Limited precision / errors due to rounding :

possibility of missing rootsNumber of roots = 17Root 1: 1Root 2: 0.95Root 3: 0.899999999995996Root 4: 0.849999999999972Root 5: 0.80000000000028Root 6: 0.70000000000294Root 7: 0.650000000006303Root 8: 0.599999999966461Root 9: 0.499999999996737Root 10: 0.449999999994588Root 11: 0.350000000000347Root 12: 0.300000000019175Root 13: 0.249999999996938Root 14: 0.20000000000004Root 15: 0.150000000000388Root 16: 0.100000000000162Root 17: 0.0500000000000002

0)20

()(20

1

ittf

i

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

How to Guarantee Robustness?

Rational / Exact Arithmetic• Memory intensive and time consuming

Interval Arithmetic• Inexpensive and robust

Robustness Issues in Root Finding

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

Number of roots = 20Root 1: [0.0499999999499999, 0.0500000000499999]Root 2: [0.0999999999501635, 0.100000000050164]Root 3: [0.149999999950384, 0.150000000050384]Root 4: [0.199999999950106, 0.200000000050106]Root 5: [0.249999999950677, 0.250000000050677]Root 6: [0.299999999942791, 0.300000000100442]Root 7: [0.349999999902533, 0.350000000186656]Root 8: [0.399999999763889, 0.400000000220964]Root 9: [0.449999999713928, 0.450000000330666]Root 10: [0.499999999608116, 0.500000000334665]Root 11: [0.549999999752196, 0.550000000340326]Root 12: [0.599999999761494, 0.600000000180693]Root 13: [0.649999999906409, 0.650000000124028]Root 14: [0.699999999948099, 0.700000000048099]Root 15: [0.749999999928722, 0.750000000028722]Root 16: [0.799999999949892, 0.800000000049892]Root 17: [0.849999999949933, 0.850000000049934]Root 18: [0.899999999945992, 0.900000000045992]Root 19: [0.949999999949999, 0.95000000005]Root 20: [0.99999999995, 1]

Results in Rounded Interval ArithmeticResults in Rounded Interval Arithmetic

Robustness Issues in Root Finding