Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!chem.ucsd.edu!tps From: tps@chem.ucsd.edu (Tom Stockfisch) Newsgroups: comp.lang.c Subject: Re: Testing math library (libm) for new processor? Message-ID: <500@chem.ucsd.EDU> Date: 28 Jun 89 05:30:08 GMT References: <2038@hub.ucsb.edu> Reply-To: tps@chem.ucsd.edu (Tom Stockfisch) Organization: Chemistry Dept, UC San Diego Lines: 26 In article <2038@hub.ucsb.edu> grosen@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@chem.ucsd.edu