非常教程

C参考手册

数值 | Numerics

cexpf

在头文件<math.h>中定义

float complex cexpf( float complex z );

(1)

(since C99)

double complex cexp( double complex z );

(2)

(since C99)

long double complex cexpl( long double complex z );

(3)

(since C99)

Defined in header <tgmath.h>

#define exp( z )

(4)

(since C99)

1-3)计算复杂碱基Ë指数的z

4)类型 - 通用宏:如果z有类型long double complexcexpl被调用。如果z有类型double complexcexp称为,如果z有类型float complexcexpf称为。如果z是真实的或整数,则宏调用相应的实函数(expfexpexpl)。如果z是虚构的,则调用相应的复杂参数版本。

参数

z

-

复杂的论点

返回值

如果没有出现错误,e提高到电源z, ez

返回。

错误处理和特殊值

报告的错误与math_errhandling一致。

如果实现支持IEEE浮点运算,

  • cexp(conj(z)) == conj(cexp(z))
  • If z is ±0+0i, the result is 1+0i
  • If z is x+∞i (for any finite x), the result is NaN+NaNi and FE_INVALID is raised.
  • If z is x+NaNi (for any finite x), the result is NaN+NaNi and FE_INVALID may be raised.
  • If z is +∞+0i, the result is +∞+0i
  • If z is -∞+yi (for any finite y), the result is +0+cis(y)
  • If z is +∞+yi (for any finite nonzero y), the result is +∞+cis(y)
  • If z is -∞+∞i, the result is ±0±0i (signs are unspecified)
  • If z is +∞+∞i, the result is ±∞+NaNi and FE_INVALID is raised (the sign of the real part is unspecified)
  • If z is -∞+NaNi, the result is ±0±0i (signs are unspecified)
  • If z is +∞+NaNi, the result is ±∞+NaNi (the sign of the real part is unspecified)
  • If z is NaN+0i, the result is NaN+0i
  • If z is NaN+yi (for any nonzero y), the result is NaN+NaNi and FE_INVALID may be raised
  • If z is NaN+NaNi, the result is NaN+NaNi

其中cis(y)是cos(y)+ i sin(y)。

Notes

复指数函数ez

对于z = x + iy等于ex

cis(y), or, ex

(cos(y) + i sin(y)).

指数函数是复平面中的一个完整函数,并且没有分支切割。

#include <stdio.h>
#include <math.h>
#include <complex.h>
 
int main(void)
{
    double PI = acos(-1);
    double complex z = cexp(I * PI); // Euler's formula
    printf("exp(i*pi) = %.1f%+.1fi\n", creal(z), cimag(z));
 
}

输出:

exp(i*pi) = -1.0+0.0i

参考

  • C11标准(ISO / IEC 9899:2011):
    • 7.3.7.1 cexp函数(p:194)
    • 7.25类型通用数学<tgmath.h>(p:373-375)
    • G.6.3.1 cexp函数(p:543)
    • G.7类型 - 通用数学<tgmath.h>(p:545)
  • C99标准(ISO / IEC 9899:1999):
    • 7.3.7.1 cexp函数(p:176)
    • 7.22类型通用数学<tgmath.h>(p:335-337)
    • G.6.3.1 cexp函数(p:478)
    • G.7类型 - 通用数学<tgmath.h>(p:480)
C

C 语言是一门通用计算机编程语言,应用广泛。C 语言的设计目标是提供一种能以简易的方式编译、处理低级存储器、产生少量的机器码以及不需要任何运行环境支持便能运行的编程语言。