/*============================================================================= Copyright (c) 2011-2017 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_COMPLEX_ACOSH_HPP #define SPROUT_COMPLEX_ACOSH_HPP #include #include #include #include #include #include #include #include #include namespace sprout { // // acosh // // G.6.2.1 The cacosh functions // cacosh(conj(z)) = conj(cacosh(z)). // cacosh(}0 + i0) returns +0 + ip /2. // cacosh(x + i‡) returns +‡+ ip /2, for finite x. // cacosh(x + iNaN) returns NaN + iNaN and optionally raises the eeinvalidff floating-point exception, for finite x. // cacosh(-‡+ iy) returns +‡+ ip , for positive-signed finite y. // cacosh(+‡+ iy) returns +‡+ i0, for positive-signed finite y. // cacosh(-‡+ i‡) returns +‡+ i3p /4. // cacosh(+‡+ i‡) returns +‡+ ip /4. // cacosh(}‡+ iNaN) returns +‡+ iNaN. // cacosh(NaN + iy) returns NaN + iNaN and optionally raises the eeinvalidff floating-point exception, for finite y. // cacosh(NaN + i‡) returns +‡+ iNaN. // cacosh(NaN + iNaN) returns NaN + iNaN. // template inline SPROUT_CONSTEXPR sprout::complex acosh(sprout::complex const& x) { typedef sprout::complex type; return sprout::math::isnan(x.real()) ? sprout::math::isnan(x.imag()) ? x : sprout::math::isinf(x.imag()) ? type(sprout::numeric_limits::infinity(), x.real()) : type(x.real(), x.real()) : sprout::math::isnan(x.imag()) ? sprout::math::isinf(x.real()) ? type(sprout::numeric_limits::infinity(), x.imag()) : type(sprout::numeric_limits::quiet_NaN(), x.imag()) : x.real() == sprout::numeric_limits::infinity() ? sprout::math::isinf(x.imag()) ? type(sprout::numeric_limits::infinity(), sprout::math::copysign(sprout::math::quarter_pi(), x.imag())) : type(sprout::numeric_limits::infinity(), (x.imag() == 0 ? x.imag() : sprout::math::copysign(T(0), x.imag()))) : x.real() == -sprout::numeric_limits::infinity() ? sprout::math::isinf(x.imag()) ? type(sprout::numeric_limits::infinity(), sprout::math::copysign(sprout::math::three_quarters_pi(), x.imag())) : type(sprout::numeric_limits::infinity(), sprout::math::copysign(sprout::math::pi(), x.imag())) : sprout::math::isinf(x.imag()) ? type(sprout::numeric_limits::infinity(), sprout::math::copysign(sprout::math::half_pi(), x.imag())) : x.real() == 0 && x.imag() == 0 ? type(T(0), sprout::math::copysign(sprout::math::half_pi(), x.imag())) : T(2) * sprout::log(sprout::sqrt(sprout::math::half() * (x + T(1))) + sprout::sqrt(sprout::math::half() * (x - T(1)))) ; } } // namespace sprout #endif // #ifndef SPROUT_COMPLEX_ACOSH_HPP