侧边栏壁纸
博主头像
noerror

虚灵不寐,众理具而万事出。

  • 累计撰写 239 篇文章
  • 累计创建 9 个标签
  • 累计收到 2 条评论
标签搜索

目 录CONTENT

文章目录

cacosh函数用法详解

noerror
2022-10-14 / 0 评论 / 0 点赞 / 173 阅读 / 304 字 / 正在检测是否收录...

cacosh函数用法详解

cacosh函数简介

  • 头文件包含
#include <complex.h>
  • 函数定义
double complex cacosh(double complex  z );
float complex cacoshf(float complex  z );
long double complex cacoshl(long double complex  z );
  • 编译链接选项
-lm

cacosh函数常见使用错误

  • 链接错误
    undefined reference to `cacosh'
    解决办法:添加链接选项
-lm
  • 编译错误
    warning: implicit declaration of function ‘cacosh’ [-Wimplicit-function-declaration]
    解决办法:包含头文件
#include <complex.h>

cacosh函数详细描述

这些函数计算z 的复圆弧双曲余弦,如果y = cacosh(z),然后z = ccosh(y)。在区间[\-pi,pi]中选择y的虚部。选择y的实部为非负。
一个有:

   cacosh(z) = 2 * clog(csqrt((z + 1) / 2) + csqrt((z \- 1) / 2))

cacosh函数使用举例

/* Link with "\-lm" */

#include <complex.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>

int
main(int argc, char *argv[])
{
   double complex z, c, f;

   if (argc != 3) {
       fprintf(stderr, "Usage: %s <real> <imag>\en", argv[0]);
       exit(EXIT_FAILURE);
   }

   z = atof(argv[1]) + atof(argv[2]) * I;

   c = cacosh(z);
   printf("cacosh() = %6.3f %6.3f*i\en", creal(c), cimag(c));

   f = 2 * clog(csqrt((z + 1)/2) + csqrt((z \- 1)/2));
   printf("formula  = %6.3f %6.3f*i\en", creal(f2), cimag(f2));

   exit(EXIT_SUCCESS);
}
0

评论区