Testing math library (libm) for new processor?
Tom Stockfisch
tps at chem.ucsd.edu
Wed Jun 28 15:30:08 AEST 1989
In article <2038 at hub.ucsb.edu> grosen at amadeus.ucsb.edu (Mark D. Grosen) writes:
>
>I am writing a math library (equivalent to libm.a on most UNiX systems) for
>a new processor. (Functions like sin, cos, log, etc.) I would appreciate
>any suggestions on how to test these routines.
The first place I start testing mathematical functions is with bc(1). If
you use the -l option you even get sin,cos,tan,exp,log already defined.
In case you don't know, bc is an arbitrary precision language with a C-like
syntax. For the other functions I would write
brute force power series expansions evaluated to very
high terms to ensure there can be no round off errors in any digits of
interest. It should also be simple
(and preferably different than your production algorithms)
so that gross errors in logic are less likely.
One thing you have to be careful about when you are determining the accuracy
of your routines: bc(1) uses binary coded decimal, so that you have
to consider representational error in the arguments to functions.
E.g., sin(0.1) will have an error in the representation of its argument
in C (assuming binary), but not in bc.
--
|| Tom Stockfisch, UCSD Chemistry tps at chem.ucsd.edu
More information about the Comp.lang.c
mailing list