Page 15 - Compact Numerical Methods For Computers
P. 15

A starting point                         5
                      bring it into the appropriate range. For example

                                                   sin(p – f ) = sin                     (1.1)
                      or
                                                  sin( p /2 – f ) = cos                  (1.2)
                      Unless this range reduction is done very carefully the results may be quite
                      unexpected. On one system, hosted by a Data General NOVA, I have observed
                      that the sine of an angle near p and the cosine of an angle near p/2 were both
                      computed as unity instead of a small value, due to this type of error. Similarly, on
                      some early models of Hewlett- Packard pocket calculators, the rectangular-to-polar
                      coordinate transformation may give a vector 180° from the correct direction. (This
                      appears to have been corrected now.)
                        Testing the quality of the floating-point arithmetic and special functions is
                      technically difficult and tedious. However, some developments which aid the user
                      have been made by public-spirited scientists. Of these, I consider the most worthy
                      example to be PARANOIA, a program to examine the floating-point arithmetic
                      provided by a programming language translator. Devised originally by Professor W
                      Kahan of the University of California, Berkeley, it has been developed and distri-
                      buted in a number of programming languages (Karpinski 1985). Its output is
                      didactic, so that one does not have to be a numerical analyst to interpret the results. I
                      have used the BASIC,  FORTRAN, Pascal and C versions of PARANOIA, and have seen
                                                ®
                      reports of Modula-2 and ADA † versions.
                        In the area of special functions, Cody and Waite (1980) have devised software to
                      both calculate and test a number of the commonly used transcendental functions
                                                y
                      (sin, cos, tan, log, exp, sqrt, x ). The ELEFUNT testing software is available in their
                      book, written in FORTRAN. A considerable effort would be needed to translate it into
                      other programming languages.
                        An example from our own work is the program DUBLTEST, which is designed to
                      determine the precision to which the standard special functions in BASIC  are
                      computed (Nash and Walker-Smith 1987). On the IBM PC, many versions of
                      Microsoft BASIC  (GWBASIC,  BASICA) would only compute such functions in single
                      precision, even if the variables involved as arguments or results were double
                      precision. For some nonlinear parameter estimation problems, the resulting low
                      precision results caused unsatisfactory operation of our software.
                        Since most algorithms are in some sense iterative, it is necessary that one has
                      some criterion for deciding when sufficient progress has been made that the
                      execution of a program can be halted. While, in general, I avoid tests which
                      require knowledge of the machine, preferring to use the criterion that no progress
                      has been made in an iteration, it is sometimes convenient or even necessary to
                      employ tests involving tolerances related to the structure of the computing device
                      at hand.
                        The most useful property of a system which can be determined systematically is
                      the machine precision. This is the smallest number, eps, such that

                                                      1+eps>1                             (1.3)
                      † ADA is a registered name of the US Department of Defense.
   10   11   12   13   14   15   16   17   18   19   20