Boost C++ Libraries: Ticket #9512: trivial bug: sign change for negative values in bessel_i1 https://svn.boost.org/trac10/ticket/9512 <p> The function <code>bessel_i1()</code> in <code>boost/math/special_functions/detail/bessel_i1.hpp</code> ends with the following code: </p> <div class="wiki-code"><div class="code"><pre><span class="k">if</span> <span class="p">(</span><span class="n">x</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span> <span class="n">value</span> <span class="o">*=</span> <span class="o">-</span><span class="n">value</span><span class="p">;</span> <span class="o">//</span> <span class="n">odd</span> <span class="n">function</span> <span class="p">}</span> <span class="k">return</span> <span class="n">value</span><span class="p">;</span> </pre></div></div><p> Instead of taking the square root, only the sign of <code>value</code> should be changed: </p> <div class="wiki-code"><div class="code"><pre><span class="k">if</span> <span class="p">(</span><span class="n">x</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span> <span class="n">value</span> <span class="o">*=</span> <span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="o">//</span> <span class="n">odd</span> <span class="n">function</span> <span class="p">}</span> <span class="k">return</span> <span class="n">value</span><span class="p">;</span> </pre></div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9512 Trac 1.4.3 John Maddock Mon, 23 Dec 2013 10:07:20 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/9512#comment:1 https://svn.boost.org/trac10/ticket/9512#comment:1 <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> Some investigation shows that that is dead code: negative x is handled by the caller of that function. I've removed the offending code and added an assert for x &gt;= 0 instead. Fixed in Git develop. </p> Ticket