
普通三角函数类似于双曲函数,它们是使用双曲线而不是圆来定义的。在双曲几何中,双曲函数用于计算角度和距离。此外,它们还出现在许多线性微分方程、三次方程等的答案中。对于给定的角度$theta$。双曲正弦函数 sinh$(theta)$ 如下所示。
$$mathrm{sinh(x):=:frac{e^x:-:e^{-x}}{2}:=:frac{e^{2x }-1}{2e^x}:=:frac{1-e^{-2x}}{2e^{-x}}}$$
在本文中,我们将讨论当角度以弧度单位给出时,在 C++ 中获取 sinh$(theta)$ 值的技术。
sinh()函数
要计算sinh$(theta)$,将使用cmath包中的sinh()函数。该函数通过将弧度角作为输入,返回双曲正弦的结果。在这里,使用简单的语法:
立即学习“C++免费学习笔记(深入)”;
语法
#include sinh( )
算法
将角度 x(以弧度表示)作为输入。使用 sinh( x ) 计算 sinh (x)。返回结果。
示例
#include #include using namespace std;float solve( float x ) { float answer; answer = sinh( x ); return answer;}int main() { cout << "The value of sinh( pi/2 ) is: " << solve( 3.14159 / 2 ) << endl; cout << "The value of sinh( pi ) is: " << solve( 3.14159 ) << endl; cout << "The value of sinh with an angle of 90 degrees is: " << solve( 90 * 3.14159 / 180 ) << endl; cout <<"The value of sinh with an angle of 45 degrees is: " << solve( 45 * 3.14159 / 180 ) << endl;}
输出
The value of sinh( pi/2 ) is: 2.3013The value of sinh( pi ) is: 11.5487The value of sinh with an angle of 90 degrees is: 2.3013The value of sinh with an angle of 45 degrees is: 0.86867
此示例中的前两个输入值以弧度为单位,而后两个输入值以度为单位,已使用以下公式转换为弧度 –
$$mathrm{theta_{rad}:=:theta_{deg}:times:frac{pi}{180}}$$
结论
要在 C++ 中查找给定角度的双曲正弦值(以弧度为单位),请使用 sinh() 函数。尽管此函数是标准库的一部分,但我们的 C++ 代码需要包含 cmath 头文件才能使用它。如果结果太大,则 sinh() 函数返回值 HUGE_VAL(正或负,具体取决于 x 的值)并将错误号设置为 ERANGE。 C++ 的更高版本提供了 float 和 long double 的重载方法,以及整数类型的增强型泛型(模板)用法,但 C90 版本的 C++ 具有 double 返回类型。本文使用了该函数的各种参数,以弧度或度为单位;但是,对于度数,将使用上面给出的公式将值转换为弧度。
以上就是C++程序来计算给定弧度值的双曲正弦的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1443350.html
微信扫一扫
支付宝扫一扫