std::acosh, std::acoshf, std::acoshl
函数 | |||||||||||||||||||||
基本运算 | |||||||||||||||||||||
|
|||||||||||||||||||||
指数函数 | |||||||||||||||||||||
幂函数 | |||||||||||||||||||||
三角与双曲函数 | |||||||||||||||||||||
误差与伽马函数 | |||||||||||||||||||||||||||||||||||||||||
临近整数的浮点运算 | |||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
浮点操作函数 | |||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
分类/比较 | |||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||
宏常量 | |||||||||||||||||||||||||||||||||||||||||
|
|
在标头
<cmath>
定义
|
||
(1) | ||
float
acosh ( float num );
double acosh (
double num ); |
(C++11 起) (C++23 前) |
|
/* 浮点类型 */
acosh( /* 浮点类型 */ num
);
|
(C++23 起) | |
float
acoshf( float num );
|
(2) | (C++11 起) |
long double acoshl( long double num );
|
(3) | (C++11 起) |
在标头
<cmath>
定义
|
||
template< class Integer >
double acosh ( Integer num ); |
(A) | (C++11 起) |
std::acosh
重载。 (C++23 起)
参数
num | - | 浮点或整数值 |
返回值
如果没有发生错误,那么返回 num 在区间 [0, +∞] 上的反双曲余弦(cosh-1
(num) 或 arcosh(num))。
如果发生定义域错误,那么返回实现定义值(在受支持平台上是 NaN)。
错误处理
报告 math_errhandling 中指定的错误。
如果参数小于 1,那么发生定义域错误。
如果实现支持 IEEE 浮点算术(IEC 60559),那么
- 如果参数小于 1,那么引发 FE_INVALID 并返回 NaN
- 如果参数是 1,那么返回 +0
- 如果参数是 +∞,那么返回 +∞
- 如果参数是 NaN,那么返回 NaN
注解
尽管(C++ 对此函数引用的)C 标准命名此函数为“弧双曲余弦”,双曲函数的反函数仍是面积函数。其参数是双曲扇形的面积,而非弧长。正确的名称是“反双曲余弦”( POSIX 所用)或“面积双曲余弦”。
额外重载不需要以 (A) 的形式提供。它们只需要能够对它们的整数类型实参 num 确保 std::acosh(num) 和 std::acosh(static_cast<double>(num)) 的效果相同。
示例
#include <cerrno> #include <cfenv> #include <cfloat> #include <cmath> #include <cstring> #include <iostream> // #pragma STDC FENV_ACCESS ON int main() { std::cout << "acosh(1) = " << std::acosh(1) << '\n' << "acosh(10) = " << std::acosh(10) << '\n' << "acosh(DBL_MAX) = " << std::acosh(DBL_MAX) << '\n' << "acosh(Inf) = " << std::acosh(INFINITY) << '\n'; // 错误处理 errno = 0; std::feclearexcept(FE_ALL_EXCEPT); std::cout << "acosh(0.5) = " << std::acosh(0.5) << '\n'; if (errno == EDOM) std::cout << " errno == EDOM: " << std::strerror(errno) << '\n'; if (std::fetestexcept(FE_INVALID)) std::cout << " 发生 FE_INVALID\n"; }
可能的输出:
acosh(1) = 0 acosh(10) = 2.99322 acosh(DBL_MAX) = 710.476 acosh(Inf) = inf acosh(0.5) = -nan errno == EDOM: Numerical argument out of domain 发生 FE_INVALID
参阅
(C++11)(C++11)(C++11)
|
计算反双曲正弦(\({\small\operatorname{arsinh}{x}
}\)arsinh(x)) (函数) |
(C++11)(C++11)(C++11)
|
计算反双曲正切(\({\small\operatorname{artanh}{x}
}\)artanh(x)) (函数) |
(C++11)(C++11)
|
计算双曲余弦(\({\small\cosh{x} }\)cosh(x)) (函数) |
(C++11)
|
计算复数的反双曲余弦(\({\small\operatorname{arcosh}{z}
}\)arcosh(z)) (函数模板) |
外部链接
Weisstein, Eric W. “反双曲余弦”来自 MathWorld--A Wolfram Web Resource 。