[Boost-bugs] [Boost C++ Libraries] #7290: complex acos is occasionally wrong

Subject: [Boost-bugs] [Boost C++ Libraries] #7290: complex acos is occasionally wrong
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-08-26 15:15:23


#7290: complex acos is occasionally wrong
-------------------------------------------------------------+--------------
 Reporter: Stephen Montgomery-Smith <stephen@…> | Type: Bugs
   Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.52.0
 Severity: Problem | Keywords:
-------------------------------------------------------------+--------------
 I am finding that the acos function is getting some of them wrong. For
 example, your program evaluates
 acos(1.00000002785941 + I*5.72464869028403e-200)
 as
 0 - I*0.000236048349018331
 whereas it should be
 2.42520172707401e-196 - I*0.000236048349018331.

 Looking at
 http://www.boost.org/doc/libs/1_51_0/boost/math/complex/acos.hpp, I am
 somewhat sure that the mistake is in the last line of this code fragment:

          //
          // This is the Hull et al exception handling code from Fig 6 of
 their paper:
          //
          if(y <= (std::numeric_limits<T>::epsilon() * std::fabs(xm1)))
          {
             if(x < one)
             {
                real = std::acos(x);
                imag = y / std::sqrt(xp1*(one-x));
             }
             else
             {
                real = 0;

 For asin, setting real = half_pi does just fine. But for acos, real
 should be something extremely small, but definitely not 0.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7290>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC