[Boost-bugs] [Boost C++ Libraries] #5385: atanh.hpp returns wrong limits for atanh(1)

Subject: [Boost-bugs] [Boost C++ Libraries] #5385: atanh.hpp returns wrong limits for atanh(1)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-03-29 10:52:51


#5385: atanh.hpp returns wrong limits for atanh(1)
--------------------------------+-------------------------------------------
 Reporter: florian@… | Owner: johnmaddock
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: math
  Version: Boost 1.46.0 | Severity: Showstopper
 Keywords: |
--------------------------------+-------------------------------------------
 Hej,

 in boost/math/special_functions/atanh.hpp the return value for 1 in case
 of ignoring overflow errors is wrong. This error is present in Boost
 1.46.1 as well in the trunk version of today.

 Starting with line 59 it states:

 59: else if(x < -1 + tools::epsilon<T>())
 60: {
 61: // -Infinity:
 62: return -policies::raise_overflow_error<T>(function, 0, pol);
 63: }
 64: else if(x > 1 - tools::epsilon<T>())
 65: {
 66: // Infinity:
 67: return -policies::raise_overflow_error<T>(function, 0, pol);
 68: }

 While the case of -Infinity works fine, the case +Infinity return the
 wrong sign.
 Thus, if I set
 #define BOOST_MATH_OVERFLOW_ERROR_POLICY ignore_error
 I expect that boost::math::atanh(1) would return +Inf, but instead I get
 -Inf, which is wrong.

 Removing the minus sign (-) from the return value in line 67 solves this
 problem and the function behaves as intended.

 66: // Infinity:
 67: return policies::raise_overflow_error<T>(function, 0, pol);

 Best regards,
 /Florian

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5385>
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:06 UTC