Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!ucla-cs!ucla-ma!news From: barry@pico.math.ucla.edu (Barry Merriman) Newsgroups: comp.sys.next Subject: Bug in the 68040 chip Message-ID: <1991Mar4.042515.4740@math.ucla.edu> Date: 4 Mar 91 04:25:15 GMT Sender: news@math.ucla.edu Organization: UCLA Dept. of Math, UCLA Inst. for Fusion and Plasma Research Lines: 59 Don't be alarmed---but there appears to be a bug in the 68040 chip. It does not compute the hyperbolic tangent function correctly. To see this for yourself, run the following bit of C code (donated by Steve Wolfram) on a 68040 Next: printf("%g %g\n", tanh(-1.73287), tanh(-1.73288)); and you will see a clear discontinuity in the values. At best this would indicate the C math library for the 68040 has a bad tanh(x). But I think (not sure though) that the 68040 itself computes the tanh(x)---in which case the bug is at a deeper level. In the latter case, all is not lost: tanh(x) is not etched into the 68040 (unlike things like multiply, divide and sqrt), instead it is done in assembly code. Background: I originally found this bug in Mathematica on my 68040 Next when I plotted Tanh[x] is found it to be discontinuos. I thought it was a bug in Mathematica, since I assumed it computed its own special functions. However, Mathematica has been cleared by (who else) Steve Wolfram: >printf("%g %g\n", tanh(-1.73287), tanh(-1.73288)); >in a minimal C program on a NeXT under OS version 2.0 shows a >discontinuity. >Mathematica (apparently mistakenly) relies on built-in math functions. >Stephen Wolfram Contributions from other folks on the mathematica mailing list have shown that the bug occurs only on 68040 NeXTs. So, this says the problem is not M'ma, but rather either (1) the C math library for the 68040, or (2) the 68040's builtin tanh. *However*, the M'ma I run was originally compiled on a 68030 Next, and the problem does *not* occur on 030's, so this means the problem is at a deeper level than the C math library. This seems to leave only option (2). The nature of the bug is clear if you plot Tanh[x] in M'ma. Since Tanh[x] -> -1 as x -> -infinity, at some point you want to switch to an approximation of the form Tanh[x] = -1 + Correction[x], where Correction[x] is a positive correction term. From the plot, its clear they accidentally switched to Tanh[x] = -1 - Correction[x]. So, a sign error seems to underlie the problem. Does anyone know if there's a bugs@motorola.com? :-) -- Barry Merriman UCLA Dept. of Math UCLA Inst. for Fusion and Plasma Research barry@math.ucla.edu (Internet)