MathGroup Archive 1991

[Date Index] [Thread Index] [Author Index]

Search the Archive

Another chapter in the NeXT Tanh bug saga!

  • To: mathgroup at yoda.ncsa.uiuc.edu, swolf
  • Subject: Another chapter in the NeXT Tanh bug saga!
  • From: CAMERON at midd.cc.middlebury.edu
  • Date: Mon, 4 Mar 91 01:37 EST

Well!  I've found another interesting piece of the Tanh[] puzzle!

Stephen Wolfram made a posting implying that the Tanh bug
was NeXT's fault:

> 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 <swolf at dragonfly.wri.com>

As you will see, that word "minimal" is STRICTLY true.

The following is a transcript of a brief test I ran on my NeXT.
I have NeXT's 2.0 operating system, and an '030 processor.
(Heorot is the machine's name.)

    Heorot (104) > cat testmath1.c
    #include <math.h>
    main()
    {
        printf("%g %g\n", tanh(-1.73287), tanh(-1.73288));
    }

    Heorot (105) > make testmath1
    cc   testmath1.c  -o testmath1

    Heorot (106) > testmath1
    -0.939394 -0.939395

    Heorot (107) > cat testmath2.c
    main()
    {
        printf("%g %g\n", tanh(-1.73287), tanh(-1.73288));
    }

    Heorot (108) > make testmath2
    cc   testmath2.c  -o testmath2

    Heorot (109) > testmath2
    -0.939394 -1.73288


Did you see it?  If I compile the program WITH the #include
line, then tanh works just fine!  But if I compile without the
#include line (a "minimal" program?) the promised discontinuity
appears!

I have no idea why this happens, but since the man page for
tanh does say that you must "#include <math.h>" when you use
this function, I am revising my blame conjecture and guessing
that somebody at WRI left out an #include line from a source
file, and that's what's causing the problem.

Further info from WRI representatives would be welcome!

Now I wonder why Mma doesn't misbehave on my system,
seeing that the C program does.

--Cameron Smith
  Still baffled Mma consultant
  cameron at midd.cc.middlebury.edu
>From CAMERON%midd.cc.middlebury.edu at mitvma.mit.edu Mon Mar  4 00:58:30 1991
Received: from MITVMA.MIT.EDU by dragonfly.wri.com with SMTP id AA18149
  (5.65+/IDA-1.3.4 for cat >> /users/swolf/Mail/incoming); Mon, 4 Mar 91 00:58:30 -0600
Received: from MITVMA.MIT.EDU by mitvma.mit.edu (IBM VM SMTP R1.2.1MX) with BSMTP id 3909; Mon, 04 Mar 91 01:57:28 EST
Received: from MIDD.CC.MIDDLEBURY.EDU (CAMERON) by MITVMA.MIT.EDU (Mailer
 R2.05) with BSMTP id 4394; Mon, 04 Mar 91 01:57:28 EST
Date: Mon, 4 Mar 91 01:42 EST
From: CAMERON at midd.cc.middlebury.edu
Subject: Addendum to "Another chapter..."
To: mathgroup at yoda.ncsa.uiuc.edu, swolf at dragonfly.wri.com
Message-Id: <AEB5644B91DF009794 at MIDD.CC.MIDDLEBURY.EDU>
X-Envelope-To: swolf at dragonfly.wri.com
X-Vms-To: IN%"mathgroup at yoda.ncsa.uiuc.edu"
X-Vms-Cc: IN%"swolf at dragonfly.wri.com",CAMERON

I forgot to mention in the previous posting: I repeated
the tests with and without the compiler's -O flag,
with and without stripped executables, with and without
the -object option, etc., and found nothing other than
the use/nonuse of #include that changed the behavior
of the program.  Just thought I'd be complete -- I have
no idea what might or might not affect this sort of thing.
--CS
>From mathgroup-adm at yoda.ncsa.uiuc.edu Mon Mar  4 01:19:46 1991
Received: from yoda.ncsa.uiuc.edu by dragonfly.wri.com with SMTP id AA18201
  (5.65+/IDA-1.3.4 for cat >> /users/swolf/Mail/incoming); Mon, 4 Mar 91 01:19:46 -0600
Received: by yoda.ncsa.uiuc.edu id AA20190
  (5.64+/IDA-1.3.4 for ); Sun, 3 Mar 91 23:10:22 -0600
Received: by yoda.ncsa.uiuc.edu id AA20186
  (5.64+/IDA-1.3.4 for /usr/lib/sendmail -odq -oi -fmathgroup-adm at yoda.ncsa.uiuc.edu mathgroup-out); Sun, 3 Mar 91 23:10:20 -0600
Message-Id: <9103040510.AA20186 at yoda.ncsa.uiuc.edu>
From: madler at kanga.caltech.edu (Mark Adler)
Subject: Re: Tanh
Date: Mon, 4 Mar 91 05:02:34 GMT
To: mathgroup at yoda.ncsa.uiuc.edu

In article <9103030700.AA19440 at yoda.ncsa.uiuc.edu> swolf at dragonfly.wri.com (Stephen Wolfram) writes:
>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 <swolf at dragonfly.wri.com>


On a 68030 NeXT running 2.0, the result of the above program is:

     -0.939394 -0.939395

(correct), while on a 68040 NeXT running the very same binary executable
gives (incorrectly):

     -0.939394 -1.060605

Note that on the 68040, all the transcendental functions are done in
software.  This means that you do not have to get your 68040 replaced
to fix this--just a small software upgrade.

That is not the only problem with 68040 math--I've seen the NeXT 
completely lock up as a result of simple calculation.  I'm hoping all
of this will be fixed very soon.  As it stands, I have no confidence
in any numerical results from my recently upgraded NeXT.

Mark Adler
madler at pooh.caltech.edu


  • Prev by Date: Tanh[x] OK on a MacIIfx
  • Next by Date: Tour Addendum
  • Previous by thread: Tanh[x] OK on a MacIIfx
  • Next by thread: Re: Another chapter in the NeXT Tanh bug saga!