From ba1358602769acf2989f419ba5995eef209ad202 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sat, 6 Oct 2012 16:53:15 +0000 Subject: [PATCH] Fix asinh and acosh to work with very large arguments without overflow. [SVN r80884] --- include/boost/math/special_functions/acosh.hpp | 3 ++- include/boost/math/special_functions/asinh.hpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/boost/math/special_functions/acosh.hpp b/include/boost/math/special_functions/acosh.hpp index 40ca985ed..5a43ae57d 100644 --- a/include/boost/math/special_functions/acosh.hpp +++ b/include/boost/math/special_functions/acosh.hpp @@ -21,6 +21,7 @@ #include #include #include +#include // This is the inverse of the hyperbolic cosine function. @@ -58,7 +59,7 @@ namespace boost { // http://functions.wolfram.com/ElementaryFunctions/ArcCosh/06/01/06/01/0001/ // approximation by laurent series in 1/x at 0+ order from -1 to 0 - return( log( x * 2) ); + return log(x) + constants::ln_two(); } else if(x < 1.5f) { diff --git a/include/boost/math/special_functions/asinh.hpp b/include/boost/math/special_functions/asinh.hpp index cf2a343e6..0534f550d 100644 --- a/include/boost/math/special_functions/asinh.hpp +++ b/include/boost/math/special_functions/asinh.hpp @@ -22,6 +22,7 @@ #include #include #include +#include // This is the inverse of the hyperbolic sine function. @@ -52,7 +53,7 @@ namespace boost { // http://functions.wolfram.com/ElementaryFunctions/ArcSinh/06/01/06/01/0001/ // approximation by laurent series in 1/x at 0+ order from -1 to 1 - return log(x * 2) + 1/ (4 * x * x); + return constants::ln_two() + log(x) + 1/ (4 * x * x); } else if(x < 0.5f) {