From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,88ed72d98e6b3457 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-09 19:29:14 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!wn14feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!rwcrnsc52.ops.asp.att.net.POSTED!not-for-mail Message-ID: <3F86195B.3040209@comcast.net> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Standard Library Interest? References: <3F81700B.1050701@noplace.com> <3F82014E.2040002@noplace.com> <3F8485B3.8010109@comcast.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.34.139.183 X-Complaints-To: abuse@comcast.net X-Trace: rwcrnsc52.ops.asp.att.net 1065752953 24.34.139.183 (Fri, 10 Oct 2003 02:29:13 GMT) NNTP-Posting-Date: Fri, 10 Oct 2003 02:29:13 GMT Organization: Comcast Online Date: Fri, 10 Oct 2003 02:29:13 GMT Xref: archiver1.google.com comp.lang.ada:566 Date: 2003-10-10T02:29:13+00:00 List-Id: Ole-Hjalmar Kristensen wrote: > OK, I'll bite. What's wrong with Cody-Waite? Nothing, they were both members of NumWG/NRG that developed the Ada numerics standards. > (W.J. Cody and W. Waite, Software manual for the elementary functions, > Prentice Hall, 1980). Oh, that Cody and Waite. Same people, but I think you have to realize that the Prentice Hall book was at best a working draft for the over 10 years of work that ended up in the DIS. And remember the timing. The Cody and Waite book was published about the same time as Mil Std 1815 (Ada 80) which was the basis for ANSI/Mil-Std 1815A (Ada 83). Adding Cody and Waite to the draft standard, as I said was not done, because all the Bills involved Cody, Waite, and Wittaker, (and Bob Mathis) knew how much more work was needed. See if you can find a copy of "Proposed Standard for a Generic Package of Elementary Functions for Ada," Ada Letters - A Special Edition from SIGAda, Volume XI, Number 7, Fall 1991. (There are actually four draft NRG standards in there, including the complex versions, with complete generic implementations. There are a couple of typos, and I think one of the names was changed in the final standard, but the code is all good.) If you can find it, burn your copy of Cody and Waite. Otherwise it is better than nothing. (Actually I prefer Abramowitz, M., and Stegun, I. A., Eds. Handbook of mathematical functions with formulas, graphs, and mathematical tables. Dover Publications Inc., New York, 1972 for completeness, and the Ada Letters Special Edition for the reference implementations of the functions that are provided.) Seriously, if I sat down and looked through the original Cody and Waite book, I don't think I would find a single function that wasn't significantly improved in both performance and accuracy, usually several times over the next ten years. As for the square root in particular, there are two basic algorithms. One is to use the N-R approach which doubles accuracy at each step with a good starting guess. But in requires a divide at each iteration, and, on modern CPUs, divides are slow. The algorithm you may have learned in school (in decimal) works very nicely in binary with only additions, subtractions, compares and shifts. Since it uses two-bits at each step in binary, you can often write a machine code version that is faster than hardware division. But don't bother, except for very special uses, such as arbitrary precision arithmetic. The computer you use, unless it is ancient, should have this algorithm in microcode as part of the IEEE floating point functions. If I thought it was worth writing the code today, I'd show you the tricks that speed up the code. (Basically you want to do compare, adjust, then subtract.) -- Robert I. Eachus "Quality is the Buddha. Quality is scientific reality. Quality is the goal of Art. It remains to work these concepts into a practical, down-to-earth context, and for this there is nothing more practical or down-to-earth than what I have been talking about all along...the repair of an old motorcycle." -- from Zen and the Art of Motorcycle Maintenance by Robert Pirsig