Namespaces
Variants

std:: atanh, std:: atanhf, std:: atanhl

From cppreference.net
Common mathematical functions
Nearest integer floating point operations
(C++11)
(C++11)
(C++11) (C++11) (C++11)
Floating point manipulation functions
(C++11) (C++11)
(C++11)
(C++11)
Classification and comparison
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Types
(C++11)
(C++11)
(C++11)
Macro constants
ヘッダーで定義 <cmath>
(1)
float atanh ( float num ) ;

double atanh ( double num ) ;

long double atanh ( long double num ) ;
(C++23まで)
/*floating-point-type*/
atanh ( /*floating-point-type*/ num ) ;
(C++23から)
(constexpr C++26から)
float atanhf ( float num ) ;
(2) (C++11から)
(constexpr C++26から)
long double atanhl ( long double num ) ;
(3) (C++11から)
(constexpr C++26から)
ヘッダーで定義 <simd>
template < /*math-floating-point*/ V >

constexpr /*deduced-simd-t*/ < V >

atanh ( const V & v_num ) ;
(S) (C++26から)
ヘッダーで定義 <cmath>
template < class Integer >
double atanh ( Integer num ) ;
(A) (constexpr C++26から)
1-3) num の逆双曲線正接を計算します。 ライブラリは、パラメータの型としてすべてのcv修飾されていない浮動小数点型に対する std::atanh のオーバーロードを提供します。 (C++23以降)
S) SIMDオーバーロードは v_num に対して要素ごとに std::atanh を実行します。
(詳細は math-floating-point および deduced-simd-t を参照)
(C++26以降)
A) すべての整数型に対して追加のオーバーロードが提供されており、これらは double として扱われます。
(since C++11)

目次

パラメータ

num - 浮動小数点または整数値

戻り値

エラーが発生しない場合、 num の逆双曲線正接( tanh -1
(num)
または artanh(num) )が返されます。

定義域エラーが発生した場合、実装定義の値が返されます(NaNがサポートされている場合はNaN)。

極点エラーが発生した場合、 ±HUGE_VAL ±HUGE_VALF または ±HUGE_VALL が(正しい符号で)返されます。

アンダーフローによる範囲エラーが発生した場合、正しい結果(丸め後)が返されます。

エラーハンドリング

エラーは math_errhandling で指定された通りに報告されます。

引数が区間 [ - 1 , + 1 ] 上にない場合、範囲エラーが発生します。

引数が±1の場合、極エラーが発生します。

IEEE浮動小数点演算(IEC 60559)を実装がサポートしている場合、

  • 引数が±0の場合、変更されずに返されます。
  • 引数が±1の場合、±∞が返され、 FE_DIVBYZERO が発生します。
  • |num|>1 の場合、NaNが返され、 FE_INVALID が発生します。
  • 引数がNaNの場合、NaNが返されます。

注記

C標準(C++はこの関数についてこれを参照する)ではこの関数を「逆双曲線正接」と命名しているが、双曲線関数の逆関数は面積関数である。それらの引数は双曲扇形の面積であり、弧ではない。正しい名称は「逆双曲線正接」(POSIXで使用)または「面積双曲線正接」である。

POSIXは アンダーフローが発生した場合、 num が変更されずに返され、それがサポートされていない場合は、 DBL_MIN FLT_MIN 、および LDBL_MIN を超えない実装定義の値が返されることを規定しています。

追加のオーバーロードは (A) と完全に同一である必要はありません。それらは、整数型の引数 num に対して、 std :: atanh ( num ) std :: atanh ( 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 << "atanh(0) = " << std::atanh(0) << '\n'
              << "atanh(-0) = " << std::atanh(-0.0) << '\n'
              << "atanh(0.9) = " << std::atanh(0.9) << '\n';
    // エラーハンドリング
    errno = 0;
    std::feclearexcept(FE_ALL_EXCEPT);
    std::cout << "atanh(-1) = " << std::atanh(-1) << '\n';
    if (errno == ERANGE)
        std::cout << "    errno == ERANGE: " << std::strerror(errno) << '\n';
    if (std::fetestexcept(FE_DIVBYZERO))
        std::cout << "    FE_DIVBYZERO raised\n";
}

出力例:

atanh(0) = 0
atanh(-0) = -0
atanh(0.9) = 1.47222
atanh(-1) = -inf
    errno == ERANGE: Numerical result out of range
    FE_DIVBYZERO raised

関連項目

(C++11) (C++11) (C++11)
逆双曲線正弦を計算する ( arsinh(x) )
(関数)
(C++11) (C++11) (C++11)
逆双曲線余弦を計算する ( arcosh(x) )
(関数)
(C++11) (C++11)
双曲線正接を計算する ( tanh(x) )
(関数)
複素数の逆双曲線正接を計算する ( artanh(z) )
(関数テンプレート)

外部リンク

Weisstein, Eric W. "Inverse Hyperbolic Tangent." From MathWorld — A Wolfram Web Resource.
Weisstein, Eric W. "逆双曲線正接" MathWorld — Wolfram Webリソースより