barry@pico.math.ucla.edu (Barry Merriman) (03/04/91)
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)
carlton@aldebaran (Mike Carlton) (03/05/91)
In article <1991Mar4.042515.4740@math.ucla.edu> barry@pico.math.ucla.edu (Barry Merriman) writes: >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. ... >Barry Merriman >UCLA Dept. of Math >UCLA Inst. for Fusion and Plasma Research >barry@math.ucla.edu (Internet) I believe that tanh is handled in software, not hardware, so at least it is possible to fix this. The following came across comp.sys.next a while ago: --The 040 floating point hardware instructions are -- FADD, FSUB, FMUL, FDIV, FSQRT, FMOVE (most addressing modes), -- FABS, FNEG, FMOVEM, FCMP, FSAVE, FScc, FDBcc, FBcc, FRESTORE -- --The 040 floating point software instructions are -- FACOS, FASIN, FATAN, FATANH, FCOS, FCOSH, FETOX, FETOXL, FGETEXP, -- FGETMAN, FINT, FINTRZ, FLOG10, FLOG2, FLOGN, FLOGNP1, FMOD, FMOVECR, -- FREM, FSCALE, FSIN, FSINCOS, FSINH, FTAN, FTANH, FTENTOX, FTWOTOX -- --Hope this helps. -- -- --morris -- --Morris Meyer NeXT, Inc. --Software Engineer 900 Chesapeake Drive --NeXT OS Group Redwood City, CA 94063 --mmeyer@next.com Cheers, --mike Mike Carlton carlton@cs.berkeley.edu
mmeyer@next.com (Morris Meyer) (03/06/91)
In article <1991Mar4.042515.4740@math.ucla.edu> barry@pico.math.ucla.edu (Barry Merriman) writes: > Don't be alarmed---but there appears to be a bug in the 68040 > chip. It does not compute the hyperbolic tangent function > correctly. > We have already seen this bug. The bug is not in the 68040, but rather the software floating point emulation code that gets executed when the chip traps these instructions. It is fixed in our 2.1 software release. Hope this helps --morris Morris Meyer NeXT, Inc. Software Engineer 900 Chesapeake Drive NeXT OS Group Redwood City, CA 94063 mmeyer@next.com
charlie@wam.umd.edu (Charles William Fletcher) (03/06/91)
See my follow up Post on the thread 'Mathematica bug' -Charlie