ccosf, ccos, ccosl
来自cppreference.com
| 在标头 <complex.h> 定义
|
||
| |
(1) | (C99 起) |
| |
(2) | (C99 起) |
| |
(3) | (C99 起) |
| 在标头 <tgmath.h> 定义
|
||
| |
(4) | (C99 起) |
1-3) 计算
z 的复余弦。4) 泛型宏:若
z 拥有 long double complex 类型,则调用 ccosl,若 z 拥有 double complex 类型,则调用 ccos,若 z 拥有 float complex 类型,则调用 ccosf。若 z 为实数或整数,则此宏调用对应的实函数(cosf、cos、cosl)。若 z 是虚数,则此宏调用对应版本的 cosh 函数,实现公式 cos(iy) = cosh(y),而返回类型是实数。参数
| z | - | 复数实参 |
返回值
若无错误发生,则返回 z 的复余弦。
错误和特殊情况如同操作以 ccosh(I*z) 实现一般。
注意
余弦在复平面上是整函数,而且无分支切割。
余弦的数学定义是
cos z =| eiz +e-iz |
| 2 |
。
示例
运行此代码
#include <stdio.h>
#include <math.h>
#include <complex.h>
int main(void)
{
double complex z = ccos(1); // 表现如同沿着实轴的实余弦
printf("cos(1+0i) = %f%+fi ( cos(1)=%f)\n", creal(z), cimag(z), cos(1));
double complex z2 = ccos(I); // 表现如同沿着虚轴的实 cosh
printf("cos(0+1i) = %f%+fi (cosh(1)=%f)\n", creal(z2), cimag(z2), cosh(1));
}
输出:
cos(1+0i) = 0.540302-0.000000i ( cos(1)=0.540302)
cos(0+1i) = 1.543081-0.000000i (cosh(1)=1.543081)
引用
- C11 标准(ISO/IEC 9899:2011):
- 7.3.5.4 The ccos functions (第 191 页)
- 7.25 Type-generic math <tgmath.h> (第 373-375 页)
- G.7 Type-generic math <tgmath.h> (第 545 页)
- C99 标准(ISO/IEC 9899:1999):
- 7.3.5.4 The ccos functions (第 173 页)
- 7.22 Type-generic math <tgmath.h> (第 335-337 页)
- G.7 Type-generic math <tgmath.h> (第 480 页)
参阅
(C99)(C99)(C99) |
计算复数正弦 (函数) |
(C99)(C99)(C99) |
计算复数正切 (函数) |
(C99)(C99)(C99) |
计算复数反余弦 (函数) |
(C99)(C99) |
计算余弦(cos(x)) (函数) |
cos 的 C++ 文档
| |