473,805 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Testing math.h

Folks,

Looking at the sanity checks for math.h/math.c in "The Standard C library"
they use 4* DBL_EPSILON as the error range, which I think is equivalent to
three bits of error. Is this appropriate on old style IBM 370 libraries with
its nasty drifting prescion? If not what would be an appropriate value.

Dave.

P.S. Its just I am having problems with exp() and log() I expected these to
be tricky.
Dec 24 '06 #1
1 2079
"David Wade" <g8***@yahoo.co mwrote in message
news:no******** *************** *******@eclipse .net.uk...
Folks,

Looking at the sanity checks for math.h/math.c in "The Standard C library"
they use 4* DBL_EPSILON as the error range, which I think is equivalent to
three bits of error. Is this appropriate on old style IBM 370 libraries
with
its nasty drifting prescion? If not what would be an appropriate value.

Dave.

P.S. Its just I am having problems with exp() and log() I expected these
to
be tricky.
The C Standard says nothing about accuracy. I chose a test criterion
which all sane libraries seemed to pass, but which quickly spotted
truly erroneous implementations . With hindsight, however, I can say
that such a criterion is rather naive, at least for anything more
than basic sanity.

First, DBL_EPSILON is only a coarse approximation to one "unit in the
least significant place" (ulp) when testing (d2 - d1) / d2. More
serious testers tend to report errors in ulps, except at zeros.

Second, even the concept of ulp is shaky in the presence of shifting
exponents, which change the weight of a ulp in different directions
for larger and smaller answers. We (Dinkumware) now use "reps" or
number of distinct representations between the ideal and actual
answer.

Third, even the concept of rep is shaky in regions where functions
are hypersensitive to the change of one rep in the argument. It has
long been known, for example, that sin(1e40) is not worth computing;
now we know it's because the answer depends way too sensitively on
small changes in the argument. You get similar sensitivity near
irrational zeros, such as sin(pi).

We now test math functions for worst case error in reps, over several
thousand representative arguments and paying particular attention to
corner cases. Good implementations tend to be correct to a few reps
for the common functions in their not-terribly-sensitive regions.
Amusingly enough, that hard-won sophistication leads to a sanity
check that doesn't differ all that much from what I made up fifteen
years ago.

Go figure.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Dec 25 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2728
by: Rahul | last post by:
HI. Python , with its support of arbit precision integers, can be great for number theory. So i tried writing a program for testing whether a number is prime or not. But then found my function painfully slow.Here is the function : from math import sqrt def isPrime(x): if x%2==0 or x%3==0: return 0
0
1213
by: George Sakkis | last post by:
How one goes on testing a threaded program, apart from doing a few successful runs and crossing his fingers that it at least follows the 'correct 99.9999% of the time' rule ? I've written a stripped-down python version of Doug Lea's PooledExecutor thread pool class (http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/PooledExecutor.html), I ran a few simple examples that seem to work as expected, but I still wouldn't bet...
1
1694
by: Gernot Frisch | last post by:
Hi, I have a fixed point math class, that completely should replace "float" on PocketPC. However the 3D graphics created look a bit odd. I think there's some bug somewhere. Is there any source code that "tests" math classes like these, or do I have to write one myself? Thank you, --
21
21228
by: scandal | last post by:
I am a javascript newbie working on a script that checks whether a "path" from one element in an array to another is "blocked." Currently, the script pushes an already processed cell index (hence an integer) into an array. To prevent rechecking already processed cells, the script iterates through the (sorted) array to see whether that integer is an element of the array. After reading about javascript arrays a bit more, I thought...
4
43876
by: OutdoorGuy | last post by:
Greetings, I was wondering if it is possible to test for a range of values in a "Switch" statement? I have the following code, but it is generating an error when I attempt to compile it. Any suggestions? Thanks in advance! public static String getMessageSwitch(int score) {
72
5286
by: Jacob | last post by:
I have compiled a set og unit testing recommendations based on my own experience on the concept. Feedback and suggestions for improvements are appreciated: http://geosoft.no/development/unittesting.html Thanks.
1
2157
by: google1 | last post by:
Has anyone written this one? Seen such a thing? Please send me a link: Skill Testing Question Exploder --------------------------------------------- Basically the plan is to create the javascript powered form one can surf to to bypass cheating via Window calculator for Skill Testing Question tests. One simply copys the Skill Testing Question from the Contest Webpage
11
2385
by: VK | last post by:
In the continuation of the discussion at "Making Site Opaque -- This Strategy Feasible?" and my comment at http://groups.google.com/group/comp.lang.javascript/msg/b515a4408680e8e2 I have realized that despite suggestions to use DHTML-based modal dialogs are very common? there is not a single fully functional reliable copyright-free cross-browser alternative to say MsgBox (VBScript) or showModalDialog (IE). This way such suggestions up to...
3
1179
by: darrel | last post by:
I often want to test a simple snippet of ASP.net code. Something usually less than a full function such as a quick if/then loop or math function. To do that, I usually create a new page, put my code on there, do some response.writes, then compile and run. But this is tedius and I'm sure there's a better way. Is there a way in VS.net, or perhaps some 3rd party tool to, say, type in this:
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10109
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.