diff options
Diffstat (limited to 'libstdc++-v3/include/std/complex')
-rw-r--r-- | libstdc++-v3/include/std/complex | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index aa6e81d2486..da3c469f829 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -1,7 +1,7 @@ // The template and inlines for the -*- C++ -*- complex number classes. // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, -// 2006, 2007, 2008, 2009, 2010 +// 2006, 2007, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -1695,12 +1695,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::complex<_Tp> __complex_acosh(const std::complex<_Tp>& __z) { - std::complex<_Tp> __t((__z.real() - __z.imag()) - * (__z.real() + __z.imag()) - _Tp(1.0), - _Tp(2.0) * __z.real() * __z.imag()); - __t = std::sqrt(__t); - - return std::log(__t + __z); + // Kahan's formula. + return _Tp(2.0) * std::log(std::sqrt(_Tp(0.5) * (__z + _Tp(1.0))) + + std::sqrt(_Tp(0.5) * (__z - _Tp(1.0)))); } #if _GLIBCXX_USE_C99_COMPLEX_TR1 |