William J. Cody, Jr.
Argonne National Laboratory

William M. Waite
University of Colorado

Each discussion of an elementary function implementation in our book Software Manual for the Elementary Functions includes a FORTRAN program to demonstrate the capabilities and limitations of any program evaluating that function. Output from these demonstration programs includes evidence that no major programming blunders have been made, statistical estimates of the overall accuracy of the program, and verification that all error conditions have been properly trapped. Detailed descriptions of specific tests are included in the discussions of the individual functions, and a general explanation of the testing procedure can be found in Chapter 3 of the book.

These programs use the uniform random number generator RAN. This generator is designed to return only about 29 random bits and is not suitable for machines without some additional synthesis of low-order bits. Randomness in the low-order bits is not as crucial as randomness in the high-order bits for our purposes, but it is essential that the low-order bits not all be 0.

Each of our test programs uses information about the floating-point arithmetic system. The radix and precision are required by all of the programs, and some of them require additional information about the largest and smallest positive floating-point numbers, whether the arithmetic rounds or chops, etc. The test programs call upon the environmental inquiry subprogram MACHAR, which dynamically determines these and other environmental parameters by exercising the floating-point arithmetic. This subprogram fails whenever the the active arithmetic registers retain floating-point quantities to more precision than stored numbers and use that extra precision in subsequent computation. MACHAR must be modified to force the storage and retrieval of important intermediate results on such machines. (The test programs may also fail in such cases, and the notes in the book indicate some, but perhaps not all, of the places where they too must be modified.) The contest program can be used to verify the operation of MACHAR.

The functions in the book make use of two primitive operations on the floating-point representation:

Return the integer representation of the exponent in the normalized representation of the floating-point number X. This operation is valid only when X is nonzero.
Return the floating-point representation of a number whose significand is the significand of the floating-point number X and whose exponent is the integer N. This operation is only valid when X is nonzero and the result neither overflows nor underflows.
The test program for these primitive operations is vfyexop.

Each of the following sections links to the test program for the specified function.


The test program for the square root routine is sqrtest. It uses a logarithmically-distributed random number generated by randl


The test program for the logarithm routines is logtest.


The test program for the exponential routine is exptest.

Power (**)

The test program for the exponentation operator is lpwtest. and the test program for the POWER function is pwrtest The only difference between these two functions is that lpwtest raises X to the Y power by using the expression X**Y and pwrtest raises X to the Y power by using the expression POWER(X,Y).


The test program for both the sine and cosine routine is scntest.


The test program for both the tangent and cotangent routine is tcttest.


The test program for both the arcsine and arccosine routine is asctest.


The test program for the arctangent routines is atntest.


The test program for both the hyberbolic sine and hyperbolic cosine routine is schtest.


The test program for the hyperbolic tangent routine is tnhtest.