diff liboctave/numeric/lo-mappers.cc @ 19935:554aaaf99644

Fix return phase of acosh to match Matlab (bug #44286). * NEWS: Announce change. * mappers.cc (Facosh): Add BIST tests for new behavior. * lo-mappers.cc: Re-write expression sqrt (x*x -1.0) as sqrt (x + 1.0) * sqrt (x - 1.0) which gets phase correct if x is complex.
author Rik <rik@octave.org>
date Tue, 17 Feb 2015 11:07:01 -0800
parents 4197fc428c7d
children 9155bab86647
line wrap: on
line diff
--- a/liboctave/numeric/lo-mappers.cc
+++ b/liboctave/numeric/lo-mappers.cc
@@ -197,7 +197,7 @@
 Complex
 acosh (const Complex& x)
 {
-  return log (x + sqrt (x*x - 1.0));
+  return log (x + sqrt (x + 1.0) * sqrt (x - 1.0));
 }
 
 Complex
@@ -434,7 +434,7 @@
 FloatComplex
 acosh (const FloatComplex& x)
 {
-  return log (x + sqrt (x*x - static_cast<float>(1.0)));
+  return log (x + sqrt (x + 1.0f) * sqrt (x - 1.0f));
 }
 
 FloatComplex