math function speed

ggs at ulysses.UUCP ggs at ulysses.UUCP
Sat Feb 21 09:58:13 AEST 1987


In article <5640 at brl-smoke.ARPA>, gwyn at brl-smoke.UUCP writes:
> 
> In a test where the result of "sqrt" was compared to known correct
> answers, for the following arguments:
> 
> 	0	1/5	1/3	1/2	1	2	e
> 	3	pi	4	5	9	10	16
> 	49	100	10000
> 
> I got the following results:
> 
> SVR2 function "sqrt":
> 
>     max abs error:	  2.7755576e-17
>     max rel error:	  2.4037034e-17
> 
> 4.3BSD function "sqrt":
> 
>     max abs error:	  5.5511151e-17
>     max rel error:	  3.3669215e-17

I thought the usual measure of accuracy was in units of "least
significant bits".  I repeated my test that compared a "best" solution
with a library version, this time with the sqrt that I got from the BRL
System V emulation package (sorry, I don't have a real VAX System V to
try, and the 3B20 is a different beast).  My result, using 100000 random
positive doubles:

SVR2 function "sqrt"

    one bit errors:	20356
    two bit errors:	0

4.3BSD function "sqrt"

    one bit errors:	8634
    two bit errors;	0

I question your choice of test numbers: any sqrt function that misses
0 is broken.  Seven of the seventeen numbers are perfect squares,
and six are powers of two.  They are excellent boundary value tests, but
statistically unusual.

I would like to add a cheer to the group at Berkeley who re-worked the
math library for 4.3BSD.  It looks like a good start, and some people
seem to have put a lot of thought into it.
-- 
Griff Smith	AT&T (Bell Laboratories), Murray Hill
Phone:		1-201-582-7736
UUCP:		{allegra|ihnp4}!ulysses!ggs
Internet:	ggs at ulysses.uucp



More information about the Comp.lang.c mailing list