This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/2182] New: cacosh() will not always return correct value after bug#2181 is fixed


After csqrt() is fixed (see bug #2181), cacosh(x+y*I) will return incorrect
values whenever (x<0) or whenever (x=0 and y<0).

I now realize that my previously suggested cacosh() patch (see bug#2153) only
adjusts for the csqrt() bug that was masking the other problem.

Going back to the original, pre-patched s_cacosh.c (s_cacoshf.c, s_cacoshl.c)

------------- unpatched s_cacosh.c near line 67 --------------
  else
    {
      __complex__ double y;

      __real__ y = (__real__ x - __imag__ x) * (__real__ x + __imag__ x) - 1.0;
      __imag__ y = 2.0 * __real__ x * __imag__ x;

      y = __csqrt (y);

      __real__ y += __real__ x;
      __imag__ y += __imag__ x;

      res = __clog (y);
    }

---------------------------------------------

since cacosh(x+y*I) gives the wrong result when (x<0) or when (x=0 and y<0),
both of these problems can be corrected by adding

------------- suggested s_cacosh.c near line 67 --------------
  else
    {
      __complex__ double y;

      __real__ y = (__real__ x - __imag__ x) * (__real__ x + __imag__ x) - 1.0;
      __imag__ y = 2.0 * __real__ x * __imag__ x;

      y = __csqrt (y);

      __real__ y += __real__ x;
      __imag__ y += __imag__ x;

      res = __clog (y);

>>>   if (__real__ res < 0.0)
>>>     res = -res;
    }

---------------------------------------------

Instead of testing y after the csqrt(), by testing res at the end it fixes the
sign problem regardless of what caused it in the first place.

One thing that should be tested is whether or not this generates negative zeros
where appropriate.

-Wes Loewer

-- 
           Summary: cacosh() will not always return correct value after
                    bug#2181 is fixed
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: aj at suse dot de
        ReportedBy: wjltemp-temp01 at yahoo dot com
                CC: glibc-bugs at sources dot redhat dot com
 BugsThisDependsOn: 2181


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

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]