Namespaces
Variants

atan, atanf, atanl

From cppreference.net
< c ‎ | numeric ‎ | math
Common mathematical functions
Functions
Basic operations
(C99)
(C99)
(C99)
(C99) (C99) (C99) (C23)
Maximum/minimum operations
Exponential functions
Power functions
Trigonometric and hyperbolic functions
Nearest integer floating-point
(C99) (C99) (C99)
(C23) (C23) (C23) (C23)
Floating-point manipulation
Narrowing operations
(C23)
(C23)
(C23)
(C23)
(C23)
(C23)
Quantum and quantum exponent
Decimal re-encoding functions
Total order and payload functions
Classification
Error and gamma functions
(C99)
(C99)
(C99)
(C99)
Types
Macro constants
Special floating-point values
Arguments and return values
Error handling
Fast operation indicators
ヘッダーで定義 <math.h>
float atanf ( float arg ) ;
(1) (C99以降)
double atan ( double arg ) ;
(2)
long double atanl ( long double arg ) ;
(3) (C99以降)
_Decimal32  atand32 ( _Decimal32 arg ) ;
(4) (C23以降)
_Decimal64  atand64 ( _Decimal64 arg ) ;
(5) (C23以降)
_Decimal128 atand128 ( _Decimal128 arg ) ;
(6) (C23以降)
ヘッダーで定義 <tgmath.h>
#define atan( arg )
(7) (C99以降)
1-6) arg の逆正接の主値を計算します。
7) 型総称マクロ: 引数の型が long double の場合、 (3) ( atanl ) が呼び出される。そうでなく、引数が整数型または double 型の場合、 (2) ( atan ) が呼び出される。それ以外の場合、 (1) ( atanf ) が呼び出される。引数が複素数の場合、マクロは対応する複素数関数( catanf catan catanl )を呼び出す。

関数 (4-6) は、実装が __STDC_IEC_60559_DFP__ を事前定義する場合にのみ宣言される(すなわち、実装が十進浮動小数点数をサポートする場合)。

(C23以降)

目次

パラメータ

arg - 浮動小数点値

戻り値

If no errors occur, the arc tangent of arg ( arctan(arg) ) in the range [-
π
2
; +
π
2
]
radians, is returned.

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

エラー処理

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

IEEE浮動小数点演算(IEC 60559)が実装でサポートされている場合:

  • 引数が±0の場合、変更されずに返されます;
  • 引数が+∞の場合、+π/2が返されます;
  • 引数が-∞の場合、-π/2が返されます;
  • 引数がNaNの場合、NaNが返されます。

注記

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

#include <math.h>
#include <stdio.h>
int main(void)
{
    printf("atan(1) = %f, 4*atan(1)=%f\n", atan(1), 4 * atan(1));
    // special values
    printf("atan(Inf) = %f, 2*atan(Inf) = %f\n", atan(INFINITY), 2 * atan(INFINITY));
    printf("atan(-0.0) = %+f, atan(+0.0) = %+f\n", atan(-0.0), atan(0));
}

出力:

atan(1) = 0.785398, 4*atan(1)=3.141593
atan(Inf) = 1.570796, 2*atan(Inf) = 3.141593
atan(-0.0) = -0.000000, atan(+0.0) = +0.000000

参考文献

  • C23規格 (ISO/IEC 9899:2024):
  • 7.12.4.3 atan関数群 (p: TBD)
  • 7.25 総称数学 <tgmath.h> (p: TBD)
  • F.10.1.3 atan関数群 (p: TBD)
  • C17規格 (ISO/IEC 9899:2018):
  • 7.12.4.3 atan関数群 (p: 174)
  • 7.25 総称数学 <tgmath.h> (p: 272-273)
  • F.10.1.3 atan関数群 (p: 378)
  • C11規格 (ISO/IEC 9899:2011):
  • 7.12.4.3 atan関数群 (p: 238-239)
  • 7.25 総称数学 <tgmath.h> (p: 373-375)
  • F.10.1.3 atan関数群 (p: 519)
  • C99標準 (ISO/IEC 9899:1999):
  • 7.12.4.3 atan関数群 (p: 219)
  • 7.22 型総称数学 <tgmath.h> (p: 335-337)
  • F.9.1.3 atan関数群 (p: 456)
  • C89/C90標準 (ISO/IEC 9899:1990):
  • 4.5.2.3 atan関数

関連項目

符号を使用して象限を決定するアークタンジェントを計算する
(関数)
(C99) (C99)
アークサインを計算する ( arcsin(x) )
(関数)
(C99) (C99)
アークコサインを計算する ( arccos(x) )
(関数)
(C99) (C99)
タンジェントを計算する ( tan(x) )
(関数)
(C99) (C99) (C99)
複素数のアークタンジェントを計算する
(関数)