- cmath[meta header]
- std[meta namespace]
- function[meta id-type]
- [mathjax enable]
- cpp11[meta cpp]
namespace std {
float atanh(float x);
double atanh(double x);
long double atanh(long double x);
double atanh(Integral x); // C++17 から
float atanhf(float x); // C++17 から
long double atanhl(long double x); // C++17 から
}- Integral[italic]
算術型の逆双曲線正接(エリアハイパボリックタンジェント、area hyperbolic tangent)を求める。
引数 x の逆双曲線正接を返す。
x が [-1, +1] の範囲外だった場合は定義域エラーとなり、戻り値は処理系定義である。また、x が -1 か +1 と等しい場合には処理系によっては極エラーが起きる可能性がある。(備考参照)
- $$ f(x) = \mathrm{artanh}~x $$
- 定義域エラー、あるいは、極エラーが発生した場合の挙動については、
<cmath>を参照。 - 処理系が IEC 60559 に準拠している場合(
std::numeric_limits<T>::is_iec559() != false)、以下の規定が追加される。(複号同順)x = ±0の場合、戻り値は±0となる。x = ±1の場合、戻り値は±∞となり、FE_DIVBYZERO(ゼロ除算浮動小数点例外)が発生する。|x| > 1の場合、戻り値は NaN となり、FE_INVALID(無効演算浮動小数点例外)が発生する。
#include <cmath>
#include <iostream>
int main() {
std::cout << std::fixed;
std::cout << "atanh(-1.0) = " << std::atanh(-1.0) << std::endl;
std::cout << "atanh(-0.5) = " << std::atanh(-0.5) << std::endl;
std::cout << "atanh(0.0) = " << std::atanh(0.0) << std::endl;
std::cout << "atanh(0.5) = " << std::atanh(0.5) << std::endl;
std::cout << "atanh(1.0) = " << std::atanh(1.0) << std::endl;
}- std::atanh[color ff0000]
- std::fixed[link ../ios/fixed.md]
atanh(-1.0) = -inf
atanh(-0.5) = -0.549306
atanh(0.0) = 0.000000
atanh(0.5) = 0.549306
atanh(1.0) = inf
- C++11
- Clang: 2.9, 3.1
- GCC, C++11 mode: 4.3.4, 4.4.5, 4.5.2, 4.6.1, 4.7.0
特定の環境で constexpr 指定されている場合がある。(独自拡張)
- GCC 4.6.1 以上
以下のマクローリン級数を適当な次数で打ち切ることで近似的に求めることができる。
または対数に変換して求めることができる。