id summary reporter owner description type status milestone component version severity resolution keywords cc 4812 Bug in boost::math::special_functions::sign showing up in special_functions::bessel_jy() peter zwart John Maddock "Hi, When computing scattering curves, I encountered a show-stopping bug that I tracked back to the boost::math::special_functions::sign function . In math::special_functions::bessel_jy a small number is generated via sqrt(tools::min_value()) which subsequently ends up in this statement: sign(current) I see this happening: variable current: -1.24911e-2468 variable sign(current): 1 which causes problems for math::special_functions::sph_bessel(1,x) for x between 7.845 and 8 or so on my machines. The fix that worked for me is the following T sign_current; sign_current = std::fabs(current); if (current*2.0 < sign_current){ sign_current = -1.0; } else { sign_current = 1.0; } Ju = sign_current * sqrt(W / (q + gamma * (p - t))); // Ju = sign(current) * sqrt(W / (q + gamma * (p - t))); For now, I'll run with this local fix but it seems that on some platforms the current sign function causes problems when computing spherical Bessel functions of any order above 0. " Bugs closed To Be Determined math Boost 1.45.0 Showstopper worksforme sign sph_bessel special_function