This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug math/17118] New: ctanh(INFINITY + 2 * I) returns incorrect value
- From: "kariya_mitsuru at hotmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Sun, 06 Jul 2014 08:25:19 +0000
- Subject: [Bug math/17118] New: ctanh(INFINITY + 2 * I) returns incorrect value
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=17118
Bug ID: 17118
Summary: ctanh(INFINITY + 2 * I) returns incorrect value
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: math
Assignee: unassigned at sourceware dot org
Reporter: kariya_mitsuru at hotmail dot com
ctanh(INFINITY + 2 * I) returns 1 + 0 * I, but it should return 1 - 0 * I.
According to C99(or C11) standard, ctanh(INFINITY + y * I) should return 1.0 +
I * +0.0 * sin(2.0 * y) for positive-signed finite y if an implementation
defines __STDC_IEC_559_COMPLEX__.
If y is 2, sin(2.0 * y) returns about -0.756802 so "+0.0 * sin(2.0 * y)" is
-0.0.
==== test source ========================================
#include <stdio.h>
#include <complex.h>
#include <math.h>
int main()
{
for (int i = 0; i < 5; i++) {
const complex double c = +INFINITY + i * I;
const complex double r1 = tanh(c);
const double r2 = sin(2.0 * cimag(c));
printf("ctanh(%g + %gi) = %g + %gi, sin(2 * %g) = %g\n", creal(c),
cimag(c), creal(r1), cimag(r1), cimag(c), r2);
}
}
==== output =============================================
ctanh(inf + 0i) = 1 + 0i, sin(2 * 0) = 0
ctanh(inf + 1i) = 1 + 0i, sin(2 * 1) = 0.909297
ctanh(inf + 2i) = 1 + 0i, sin(2 * 2) = -0.756802
ctanh(inf + 3i) = 1 + 0i, sin(2 * 3) = -0.279415
ctanh(inf + 4i) = 1 + 0i, sin(2 * 4) = 0.989358
--
You are receiving this mail because:
You are on the CC list for the bug.