Golang 如何找到给定弧度值的双曲正弦函数

Golang 如何找到给定弧度值的双曲正弦函数

在本教程中,我们将学习如何在Golang编程语言中找到给定弧度值的双曲正弦函数。Golang语言具有许多预定义函数的包,开发人员可以在不编写完整逻辑的情况下使用。

为了执行数学运算和逻辑运算,我们使用Golang中的math包。我们只需使用该包来找到给定弧度值的双曲正弦函数。我们还将看到如何导入该包以及如何通过编写Golang代码调用该包中的函数。

双曲正弦

定义

双曲正弦是一种类似于三角函数的函数。这个代数表达式有助于找到包括指数函数(e^x)的双曲函数。双曲正弦的公式如下,其值在不同角度上有所不同。

语法

Sinhx = (e^x - e^-x) / 2

图形

Golang 如何找到给定弧度值的双曲正弦函数

不同角度的双曲正弦值

  • sinh(0) = 0

  • sinh(30) = 5.3432373e+12

  • sinh(45) = 1.7467136e+19

  • sinh(60) = 5.7100369e+25

  • sinh(90) = 6.1020165e+38

步骤

步骤 1 - 声明一个浮点型的变量来存储守卫和答案的值。

步骤 2 - 初始化一个弧度的变量。

步骤 3 - 调用双曲正弦函数并传入弧度值。

步骤 4 - 打印结果。

示例

在这个示例中,我们将编写一个Golang程序,引入一个 math 包并调用双曲正弦函数。

package main
import (

   // fmt package provides the function to print anything
   "fmt"

   // math package provides multiple functions for different

   // mathematical operations
   "math"
)
func main() {

   // declaring the variables to store the value of radian value and answer
   var radianValue, answer float64
   fmt.Println("Program to find the hyperbolic sine of a given radian value in the Golang programming language using a math package.")

   // initializing the value of radian value
   radianValue = 4.5

   // finding hyperbolic sine for the given radian value
   answer = math.Sinh(radianValue)

   // printing the result
   fmt.Println("The hyperbolic sine value with the value of radian", radianValue, "is", answer)
}

输出

Program to find the hyperbolic sine of a given radian value in the Golang programming language using a math package.
The hyperbolic sine value with the value of radian 4.5 is 45.003011151991785

步骤

步骤1 - 声明用于存储守护者的值和float32类型答案的变量。

步骤2 - 初始化弧度变量。

步骤3 - 调用我们定义的双曲正弦函数,并将弧度值作为参数传递。

步骤4 - 打印结果。

示例

在这个示例中,我们将编写一个Golang程序,在其中导入一个 math 包,并在一个单独的函数中调用双曲正弦函数,并调用该函数作为主函数。

package main
import (

   // fmt package provides the function to print anything
   "fmt"

   // math package provides multiple functions for different

   // mathematical operations
   "math"
)

// this is a function with a parameter of float64 type and a return type of float64
func HyperbolicSine(angle float64) float64 {

   // returning the Hyperbolic Sine of the angle
   return math.Sinh(angle)
}
func main() {

   // declaring the variables to store the value of radian value and answer
   var radianValue, answer float64 
   fmt.Println("Program to find the Hyperbolic Sine of a given radian value in the Golang programming language using a separate function in the same program.")

   // initializing the value of the radian value
   radianValue = 4.5

   // finding hypsine for the given radian value in separate function
   answer = HyperbolicSine(radianValue)

   // printing the result
   fmt.Println("The Hyperbolic Sine value with the value of radian", radianValue, "is", answer)
}

输出

Program to find the Hyperbolic Sine of a given radian value in the Golang programming language using a separate function in the same program.
The Hyperbolic Sine value with the value of radian 4.5 is 45.003011151991785

结论

使用数学包中的函数并将弧度值作为参数传递有两种方法来找到双曲正弦值。第二种方法将为程序提供抽象性。要了解更多关于Golang的信息,您可以探索这些教程。

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程