public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug math/11521] New: Ctanh Returns Incorrect Values
@ 2010-04-19 17:43 tomdean at speakeasy dot org
  2010-04-22  3:52 ` [Bug math/11521] " jstorrs at gmail dot com
  2010-04-22 20:24 ` jstorrs at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: tomdean at speakeasy dot org @ 2010-04-19 17:43 UTC (permalink / raw)
  To: glibc-bugs

ctanh returns incorrect values.  Code below.

Build test-tanh: gcc test-tanh.c -o test-tanh -lm

./test-tanh-c 711
libc version 2.10.1
libc release stable
arg        = 7.110000e+02 + 7.110000e+02 * i
sinh (arg) = inf + inf * i
cosh (arg) = inf + inf * i
s/c         = nan + nan * i   (should be 1 + 0 * i)
tanh (arg) = 0.000000e+00 + 0.000000e+00 * i   (should be 1 + 0 * i)

==== test-tanh.c ========================================
#include <math.h>
#include <complex.h>
#include <stdio.h>
#define _GNU_SOURCE
#include <gnu/libc-version.h>

int main (int argc, char **argv)
{
  long double complex arg = 1 + _Complex_I;
  long double complex s, c, r, t;
  long mult;
  if (argc == 2) {
	mult = atol(argv[1]);
  } else {
	mult = 50000L;
  }

  arg *= mult;
  
  s = csinh (arg);
  c = ccosh (arg);
  r = s / c;
  t = ctanh (arg);
  
  printf ("libc version %s\n", gnu_get_libc_version ());
  printf ("libc release %s\n", gnu_get_libc_release ());
  printf ("arg        = %e + %e * i\n", creal (arg), cimag
		  (arg));
  printf ("sinh (arg) = %e + %e * i\n",
		  creal (s), cimag (s));
  printf ("cosh (arg) = %e + %e * i\n",
		  creal (c), cimag (c));
  printf("s/c         = %e + %e * i   (should be 1 + 0 * i)\n",
		 creal (r), cimag (r));
  printf ("tanh (arg) = %e + %e * i   (should be 1 + 0 * i)\n",
		  creal (t), cimag (t));
    
  return 0;
}

-- 
           Summary: Ctanh Returns Incorrect Values
           Product: glibc
           Version: 2.10
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
        AssignedTo: aj at suse dot de
        ReportedBy: tomdean at speakeasy dot org
                CC: glibc-bugs at sources dot redhat dot com,tomdean at
                    speakeasy dot org
  GCC host triplet: ubuntu 9.10
GCC target triplet: ubuntu 9.10


http://sourceware.org/bugzilla/show_bug.cgi?id=11521

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug math/11521] Ctanh Returns Incorrect Values
  2010-04-19 17:43 [Bug math/11521] New: Ctanh Returns Incorrect Values tomdean at speakeasy dot org
@ 2010-04-22  3:52 ` jstorrs at gmail dot com
  2010-04-22 20:24 ` jstorrs at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: jstorrs at gmail dot com @ 2010-04-22  3:52 UTC (permalink / raw)
  To: glibc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jstorrs at gmail dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=11521

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug math/11521] Ctanh Returns Incorrect Values
  2010-04-19 17:43 [Bug math/11521] New: Ctanh Returns Incorrect Values tomdean at speakeasy dot org
  2010-04-22  3:52 ` [Bug math/11521] " jstorrs at gmail dot com
@ 2010-04-22 20:24 ` jstorrs at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: jstorrs at gmail dot com @ 2010-04-22 20:24 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From tomdean at speakeasy dot org  2010-04-22 04:21 -------
Subject: Re:  Ctanh Returns Incorrect Values

On Thu, 2010-04-22 at 03:51 +0000, jstorrs at gmail dot com wrote:
> 
A patch to glibc-2.11.1

------- Additional Comments From tomdean at speakeasy dot org  2010-04-22 04:21 -------
Created an attachment (id=4746)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=4746&action=view)

------- Additional Comments From jstorrs at gmail dot com  2010-04-22 20:23 -------
Created an attachment (id=4748)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=4748&action=view)
C99 program that demonstrates the problem

Without the patch this is the output:

Expect: 1 0	Got: nan 0
Expect: 1 0	Got: nan 0
Expect: 1 0	Got: nan 0
Expect: -1 0	Got: nan 0
Expect: -1 0	Got: nan 0
Expect: -1 0	Got: nan 0

With the patch applied:

Expect: 1 0	Got: 1 0
Expect: 1 0	Got: 1 0
Expect: 1 0	Got: 1 0
Expect: -1 0	Got: -1 0
Expect: -1 0	Got: -1 0
Expect: -1 0	Got: -1 0

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=11521

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-04-22 20:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-19 17:43 [Bug math/11521] New: Ctanh Returns Incorrect Values tomdean at speakeasy dot org
2010-04-22  3:52 ` [Bug math/11521] " jstorrs at gmail dot com
2010-04-22 20:24 ` jstorrs at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).