473,327 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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 2043
"David Wade" <g8***@yahoo.comwrote 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
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...
0
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...
1
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...
21
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...
4
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...
72
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: ...
1
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...
11
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...
3
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.