Computing a priori Error Bounds for Floating-point Evaluations of ...

133 downloads 249 Views 190KB Size Report
http://www.math.uni-wuppertal.de/wrswt/literatur.html. Autoren-Kontaktadressen ... Email addresses: [email protected] (Frithjof Blomquist), ... If |εx| ≤ ε(f) ∀˜x ∈ [a, b] and if f is, for example, a positive, monotonic function then for all real arguments x ∈ [a, b] the function values f(x) are included by. ˜ f(a).
¨ Bergische Universitat Wuppertal

Computing a priori Error Bounds for Floating-point Evaluations of Arithmetic Expressions ¨ Frithjof Blomquist, Walter Kramer

Preprint BUW-WRSWT 2006/1

Wissenschaftliches Rechnen/ Softwaretechnologie

Impressum Herausgeber:

Prof. Dr. W. Kr¨amer, Dr. W. Hofschuster Wissenschaftliches Rechnen/Softwaretechnologie Fachbereich C (Mathematik und Naturwissenschaften) Bergische Universit¨at Wuppertal Gaußstr. 20 42097 Wuppertal, Germany

Internet-Zugriff Die Berichte sind in elektronischer Form erh¨altlich u¨ ber die World Wide Web Seiten http://www.math.uni-wuppertal.de/wrswt/literatur.html

Autoren-Kontaktadressen Frithjof Blomquist Adlerweg 6 66436 P¨uttlingen, Germany E-mail: [email protected] Walter Kr¨amer Bergische Universit¨at Wuppertal Gaußstr. 20 42097 Wuppertal, Germany E-mail: [email protected]

Computing a priori Error Bounds for Floating-point Evaluations of Arithmetic Expressions Frithjof Blomquist a , Walter Kr¨amer b a Adlerweg b Bergische

6, 66346 P¨ uttlingen, Germany

Universit¨ at Wuppertal,Gaußstr. 20, 42119 Wuppertal, Germany

Abstract For the implementation of mathematical functions on a computer often a large number of different expressions are used in different parts of the domain of the function under consideration. Deriving corresponding a-priori error bounds for the numerical evaluation of these expressions by hand is a very tedious and error-prone task. We discuss software tools implemented in C-XSC which can be used to automatically compute a priori error bounds for the numerical evaluation (using IEEE-754 floating-point operations) of arithmetic expressions. The tools are available as open source software and have been used with great success to find reliable and tight worst-case error bounds for mathematical function expressions. For a very simple example numerical results will be shown. Key words: computing a priori error bounds, open-source software, C-XSC, interval functions MSC Subject Classifications: 65G30, 65K05.

1

Introduction

In general the computer evaluation of a function expression f () leads to a defective machine value f˜(˜ x) for IEEE machine numbers x˜ ∈ [a, b] as arguments. With the exact function value f (˜ x) the absolute error can be written ˜ as f (˜ x) − f (˜ x) = εx · f (˜ x), where εx is the relative error depending on the argument x˜, the used expression term (mathematically equivalent expressions in general lead to different error bounds), and the actual rounding mode of the Email addresses: [email protected] (Frithjof Blomquist), [email protected] (Walter Kr¨amer).

CPU. If |εx | ≤ ε(f ) ∀˜ x ∈ [a, b] and if f is, for example, a positive, monotonic function then for all real arguments x ∈ [a, b] the function values f (x) are included by f˜(a) f˜(b) ≤ f (x) ≤ ∀x ∈ [a, b] (1) 1 + ε(f ) 1 − ε(f ) Hence, for the implementation of interval standard functions we need the relative error bounds ε(f ), which have been calculated e. g. in [5, 11, 4, 13, 7, 9, 10]. In [1] these ε(f )-values are computed automatically by reading the actual approximation term of the function under consideration. Here we use a more expensive but more flexible method, where each of the basic operations in the function term will be handled by an appropriate function call in a CXSC program [2]. In some cases the ε(f )-values can be improved by choosing different function terms in different regions of the domain and by using refined error bounds for elementary operations with special operands. We demonstrate these techniques With numerical examples. For the algorithms of the functions √ 2 x2 − 1 and e−x we give some hints for getting small error bounds. 2 2.1

Calculating error bounds Error bounds of the elementary operations

Let S(2, 53) denote the system of IEEE-numbers. In general the sum a ˜ + ˜b ˜ of two machine numbers a ˜ and b is not a machine number itself and must be ˜ rounded to a ˜ ⊕ b ∈ S(2, 53). If εa˜,˜b is the relative error, the absolute error is given by (˜ a ⊕ ˜b) − (˜ a + ˜b) = εa˜,˜b · (˜ a + ˜b) depending on a ˜ and ˜b and on the actual rounding mode of the CPU. If we allow the rounding to any of the two neighbouring machine numbers (in this case we use the term high accuracy) then for the four elementary operations with results in the normalized range |εa˜,˜b | ≤ 2−52 =: ε∗ ,and the absolute error of our sum can be estimated in high accuracy: |(˜ a ⊕ ˜b) − (˜ a + ˜b)| ≤ ε∗ · |˜ a + ˜b| (2) If all error estimations are done with the rounding of the elementary operations in high accuracy, the calculated error bounds are valid independently from the actul rounding mode of the CPU. 2.2

Calculating error bounds in C-XSC

We assume real values a and b ∈ IR with a ∈ A and b ∈ B , where A , B are machine intervals and interpret a as an exact result value, which has been evaluated on a computer with the machine result a ˜ = a + δa . Furthermore we assume |δa | ≤ ∆(a) ∀a ∈ A (the bound Delta(a) is a known quantity). If we calculate the machine sum a ˜ ⊕ ˜b of the defective function values a ˜ and ˜b then the absolute error is defined by δ+ := a ˜ ⊕ ˜b − (a + b). With ∆ := ∆(a) + ∆(b) 2

the absolute error |δ+ | is bounded by + B |) A3 |δ+ | ≤ ∆(+) := ∆ + ε∗ · (∆ + |A

a ∈ A, b ∈ B ,

(3)

+ B | is the maximum of the absolute values of the interval sum A3 where |A + denotes interval addition. Appropriate bounds ∆(◦), ε(◦) for + B . Here 3 A3 the absolute and relative errors of the elementary operations ◦ ∈ {+, −, ·, /} are given in [1]. Our simple example of the addition demonstrates that for calculating the error bound of an elementary operation we only need the inclusion intervals A, B of the exact operands a and b and their absolute or relative error bounds. Hence, for any elementary operation of a given expression we need an appropriate function call with the input data A and B together with the error bounds of the operands which deliver the error bound of the operation and an inclusion interval R for all exact operation results a ◦ b. The described functions are available in C-XSC, and an error bound of a given expression can be calculated by a sequence of appropriate function calls [2]. The following program fragment shows the calculation of a relative error bound for the simple term T1 (x) = 1 − x2 , x˜ ∈ [2−12 , 0.658]:

#include "abs_relh.hpp" //basic C-XSC routines for the computation // of worst case relative or absolute // error bounds for the elemntary // operations and functions #include "bnd_util.hpp" //function Max_bnd_Xi() based on subdivision #include //input/output using namespace cxsc; using namespace std; //Compute error bound for the function term T1 over the interval x real T1(const interval& x, const real& errx) { // T1(x)= 1 - x^2; interval x2, res; real errx2, relerr; abs_mulh1(x,errx,x,errx,x2,errx2); //x2= x^2 rel_1mx_delh(x2,errx2,res,relerr); //r = 1-x^2 return relerr; //relative error bound } int main() { interval X(comp(0.5,-11),0.658); //interval [2**(-12),0.658] real bound; //output parameter (worst case rel. error bound) real diam=1e-5; //diameter of subintervals real errx=0; //function arguments are error free flp numbers Max_bnd_Xi(T1,X,errx,diam,bound); //compute the maximum error // bound for T1() over X // using subintervals of X // of diameter

Suggest Documents