---
title: sinhcosh
description: "分别计算输入弧度的双曲正弦、余弦值。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/240RC1/accel/kunpengaccel_kml_16_0664.html
sourcePath: /source/zh/kunpengboostkithistory/240RC1/accel/kunpengaccel_kml_16_0664.html
indexId: 9e8c65b8972e77379ae2d137b90e7d445791674a452cd42b5840fe5cda375dbd76
---
# sinhcosh

分别计算输入弧度的双曲正弦、余弦值。

#### 接口定义

C interface：

void sinhcoshf(float x, float *sinh, float *cosh);

void sinhcosh(double x, double *sinh, double *cosh);


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| x | 在sinhcoshf中，x是单精度浮点类型。 在sinhcosh中，x是双精度浮点类型。 | 表示弧度角的浮点值。 | 输入 |
| sinh | 在sinhcoshf中，sinh是单精度浮点指针类型。 在sinhcosh中，sinh是双精度浮点指针类型。 | 表示计算的双曲正弦。 若为空指针，会出现未定义的行为，接口不会对输出指针进行校验。 | 输出 |
| cosh | 在sinhcoshf中，cosh是单精度浮点指针类型。 在sinhcosh中，cosh是双精度浮点指针类型。 | 表示计算的双曲余弦。 若为空指针，会出现未定义的行为，接口不会对输出指针进行校验。 | 输出 |


#### 返回值

- 返回弧度角x的双曲正弦数值sinh和双曲余弦函数值cosh，sinh ∈ [-∞, +∞]，cosh∈ [1, +∞]。
- 输入+0，返回双曲正弦值+0和双曲余弦值+1。
- 输入-0，返回双曲正弦值-0和双曲余弦值+1。
- sinhcoshf输入大于0x1.8p6f，均返回+∞；sinhcosh输入大于0x1.8p9，均返回+∞。
- sinhcoshf输入小于-0x1.8p6f，双曲正弦值返回-∞，双曲余弦值返回+∞；sinhcosh输入小于-0x1.8p9，双曲正弦值返回-∞，双曲余弦值返回+∞。
- sinhcoshf输入绝对值小于0x1.p-13，双曲正弦值返回x，双曲余弦值返回1.0；sinhcosh输入绝对值小于0x1.p-26，双曲正弦值返回x，双曲余弦值返回1.0。
- 输入±∞，返回双曲正弦值±∞和双曲余弦值+∞。
- 输入nan，均返回nan。


#### 依赖

C: "km.h"


#### 示例

C interface：

```
// typical usage
double a = 1.0, b = -1.0, c = 0.0, d = -0.0;
// special handling
double e = INFINITY, f = -INFINITY, g = NAN;
// print result
double sinh, cosh;
sinhcosh(a, &sinh, &cosh);
printf("sinh(1.0) = %.15f, cos(1.0) = %.15f\n", sinh, cosh);
sinhcosh(b, &sinh,&cosh);
printf("sin(-1.0) = %.15f, cos(-1.0) = %.15f\n", sinh, cosh);
sinhcosh(c, &sinh,&cosh);
printf("sin(0.0) = %.15f, cos(0.0) = %.15f\n", sinh, cosh);
sinhcosh(d, &sinh,&cosh);
printf("sin(-0.0) = %.15f, cos(-0.0) = %.15f\n", sinh, cosh);
sinhcosh(e, &sinh,&cosh);
printf("sin(INFINITY) = %.15f, cos(INFINITY) = %.15f\n", sinh, cosh);
sinhcosh(f, &sinh,&cosh);
printf("sin(-INFINITY) = %.15f, cos(-INFINITY) =  %.15f\n", sinh, cosh);
sinhcosh(g, &sinh,&cosh);
printf("sin(NAN) = %.15f, cos(NAN) = %.15f\n", sinh, cosh);
/*
* sinh(1.0) = 1.175201193643801, cos(1.0) = 1.543080634815244
* sin(-1.0) = -1.175201193643801, cos(-1.0) = 1.543080634815244
* sin(0.0) = 0.000000000000000, cos(0.0) = 1.000000000000000
* sin(-0.0) = -0.000000000000000, cos(-0.0) = 1.000000000000000
* sin(INFINITY) = inf, cos(INFINITY) = inf
* sin(-INFINITY) = -inf, cos(-INFINITY) =  inf
* sin(NAN) = nan, cos(NAN) = nan
*
* */
```
