Namespaces
Variants

catanf, catan, catanl

From cppreference.net
定义于头文件 <complex.h>
float complex catanf ( float complex z ) ;
(1) (C99 起)
double complex catan ( double complex z ) ;
(2) (C99 起)
long double complex catanl ( long double complex z ) ;
(3) (C99 起)
定义于头文件 <tgmath.h>
#define atan( z )
(4) (C99 起)
1-3) 计算 z 的复反正切,其分支切割沿虚轴位于区间 [−i,+i] 之外。
4) 类型泛型宏:若 z 具有类型 long double complex ,则调用 catanl ;若 z 具有类型 double complex ,则调用 catan ;若 z 具有类型 float complex ,则调用 catanf 。若 z 为实数或整数,则宏调用对应的实数函数( atanf atan atanl )。若 z 为虚数,则宏调用函数的对应实数版本 atanh ,实现公式 atan(iy) = i atanh(y) ,且宏的返回类型为虚数。

目录

参数

z - 复参数

返回值

若无错误发生,则返回 z 的复反正切,其值在虚轴方向上无界,在实轴方向上位于区间 [−π/2; +π/2] 内。

错误和特殊情况的处理方式如同该操作通过 - I * catanh ( I * z ) 实现。

注释

反正切(或称反正切函数)是一个多值函数,需要在复平面上进行分支切割。分支切割通常设置在虚轴的线段 (-∞i,-i) (+i,+∞i) 上。

The mathematical definition of the principal value of inverse tangent is atan z = -
1
2
i [ln(1 - iz) - ln (1 + iz)]

示例

#include <stdio.h>
#include <float.h>
#include <complex.h>
int main(void)
{
    double complex z = catan(2*I);
    printf("catan(+0+2i) = %f%+fi\n", creal(z), cimag(z));
    double complex z2 = catan(-conj(2*I)); // or CMPLX(-0.0, 2)
    printf("catan(-0+2i) (the other side of the cut) = %f%+fi\n", creal(z2), cimag(z2));
    double complex z3 = 2*catan(2*I*DBL_MAX); // or CMPLX(0, INFINITY)
    printf("2*catan(+0+i*Inf) = %f%+fi\n", creal(z3), cimag(z3));
}

输出:

catan(+0+2i) = 1.570796+0.549306i
catan(-0+2i) (the other side of the cut) = -1.570796+0.549306i
2*catan(+0+i*Inf) = 3.141593+0.000000i

参考文献

  • C11 标准 (ISO/IEC 9899:2011):
  • 7.3.5.3 catan 函数 (p: 191)
  • 7.25 泛型数学 <tgmath.h> (p: 373-375)
  • G.7 泛型数学 <tgmath.h> (p: 545)
  • C99 标准 (ISO/IEC 9899:1999):
  • 7.3.5.3 catan 函数 (p: 173)
  • 7.22 泛型数学 <tgmath.h> (p: 335-337)
  • G.7 泛型数学 <tgmath.h> (p: 480)

参考

(C99) (C99) (C99)
计算复数反正弦
(函数)
(C99) (C99) (C99)
计算复数反余弦
(函数)
(C99) (C99) (C99)
计算复数正切
(函数)
(C99) (C99)
计算反正切 ( arctan(x) )
(函数)
C++ 文档 for atan