Boost C++ Libraries: Ticket #5385: atanh.hpp returns wrong limits for atanh(1) https://svn.boost.org/trac10/ticket/5385 <p> Hej, </p> <p> 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. </p> <p> Starting with line 59 it states: </p> <p> 59: else if(x &lt; -1 + tools::epsilon&lt;T&gt;()) 60: { 61: <em> -Infinity: 62: return -policies::raise_overflow_error&lt;T&gt;(function, 0, pol); 63: } 64: else if(x &gt; 1 - tools::epsilon&lt;T&gt;()) 65: { 66: </em> Infinity: 67: return -policies::raise_overflow_error&lt;T&gt;(function, 0, pol); 68: } </p> <p> 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. </p> <p> Removing the minus sign (-) from the return value in line 67 solves this problem and the function behaves as intended. 66: <em> Infinity: 67: return policies::raise_overflow_error&lt;T&gt;(function, 0, pol); </em></p> <p> Best regards, /Florian </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5385 Trac 1.4.3 florian@… Tue, 29 Mar 2011 11:01:24 GMT <link>https://svn.boost.org/trac10/ticket/5385#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5385#comment:1</guid> <description> <p> Sorry, I screwed up the formatting: </p> <p> The original source code in boost/math/special_functions/atanh.hpp </p> <pre class="wiki">59: else if(x &lt; -1 + tools::epsilon&lt;T&gt;()) 60: { 61: // -Infinity: 62: return -policies::raise_overflow_error&lt;T&gt;(function, 0, pol); 63: } 64: else if(x &gt; 1 - tools::epsilon&lt;T&gt;()) 65: { 66: // Infinity: 67: return -policies::raise_overflow_error&lt;T&gt;(function, 0, pol); 68: } </pre><p> should be changed to </p> <pre class="wiki">66: // Infinity: 67: return policies::raise_overflow_error&lt;T&gt;(function, 0, pol); </pre><p> where in line 67 the minus sign was removed to return +Infinity if the overflow error is ignored. </p> <p> /Florian </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Tue, 29 Mar 2011 11:18:00 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5385#comment:2 https://svn.boost.org/trac10/ticket/5385#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/70692" title="Fix value returned for atanh(1). Fixes #5385.">[70692]</a>) Fix value returned for atanh(1). Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5385" title="#5385: Bugs: atanh.hpp returns wrong limits for atanh(1) (closed: fixed)">#5385</a>. </p> Ticket