---
title: sinhcosh
description: "分别计算输入弧度的双曲正弦、余弦值。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0174.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_0174.html
indexId: 23ad97c78fc348685056489dfc50592114a010caa6aab5dda57a427a8353ddf761
---
# 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, cosh(1.0) = %.15f\n", sinh, cosh);
    sinhcosh(b, &sinh,&cosh);
    printf("sinh(-1.0) = %.15f, cosh(-1.0) = %.15f\n", sinh, cosh);
    sinhcosh(c, &sinh,&cosh);
    printf("sinh(0.0) = %.15f, cosh(0.0) = %.15f\n", sinh, cosh);
    sinhcosh(d, &sinh,&cosh);
    printf("sinh(-0.0) = %.15f, cosh(-0.0) = %.15f\n", sinh, cosh);
    sinhcosh(e, &sinh,&cosh);
    printf("sinh(INFINITY) = %.15f, cosh(INFINITY) = %.15f\n", sinh, cosh);
    sinhcosh(f, &sinh,&cosh);
    printf("sinh(-INFINITY) = %.15f, cosh(-INFINITY) =  %.15f\n", sinh, cosh);
    sinhcosh(g, &sinh,&cosh);
    printf("sinh(NAN) = %.15f, cosh(NAN) = %.15f\n", sinh, cosh);
    /* 
     * sinh(1.0) = 1.175201193643801, cosh(1.0) = 1.543080634815244
     * sinh(-1.0) = -1.175201193643801, cosh(-1.0) = 1.543080634815244
     * sinh(0.0) = 0.000000000000000, cosh(0.0) = 1.000000000000000
     * sinh(-0.0) = -0.000000000000000, cosh(-0.0) = 1.000000000000000
     * sinh(INFINITY) = inf, cosh(INFINITY) = inf
     * sinh(-INFINITY) = -inf, cosh(-INFINITY) =  inf
     * sinh(NAN) = nan, cosh(NAN) = nan
     * 
     * */
```
