Golang 如何找到给定值的双曲反正弦

Golang 如何找到给定值的双曲反正弦

在本教程中,我们将学习如何在Golang编程语言中找到给定值的双曲反正弦。Golang语言有许多预定义函数的包,开发者可以直接使用,而无需编写完整的逻辑。

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

双曲反正弦

定义

双曲反正弦是一种类似于三角函数的函数。双曲反正弦等于三角函数的类似物。双曲反正弦的公式如下,双曲反正弦的值在不同的角度下。

语法

asinh(x) = ln(x + √x^2 + 1)

图表

Golang 如何找到给定值的双曲反正弦

不同角度的双曲反正弦值

  • asinh(0) = 0

  • asinh(30) = 4.094622224331

  • asinh(45) = 4.499933104264

  • asinh(60) = 4.787561179994

  • asinh(90) = 5.192987713659

步骤

第一步 - 声明一个变量,用于存储守护者的值和float32类型的答案。

第二步 - 初始化一个变量的值。

第三步 - 调用双曲反正弦函数并传入该值。

第四步 - 打印结果。

示例

在这个示例中,我们将编写一个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 \value and answer
   var value, answer float64
   fmt.Println("Program to find the Hyperbolic Arc sine of a given value in the Golang programming language using a math package.")

   // initializing the value of the variable value
   value = 4.5

   // finding Hyperbolic Arc sine for the given value
   answer = math.Asinh(value)

   // printing the result
   fmt.Println("The Hyperbolic Arc sine value with the value of", value, "is", answer)
}

输出

Program to find the Hyperbolic Arc sine of a given value in the Golang programming language using a math package.
The Hyperbolic Arc sine value with the value of 4.5 is 2.209347708615334

步骤

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

步骤2 - 初始化变量值。

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

步骤4 - 打印结果。

示例

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

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 HyperbolicArcSine(angle float64) float64 {

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

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

   // initializing the value of the value
   value = 1

   // finding Hyperbolic Arc sine for the given value in a separate function
   answer = HyperbolicArcSine(value)

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

输出

Program to find the Hyperbolic Arc Sine of a given value in the Golang programming language using a separate function in the same program.
The Hyperbolic Arc Sine value with the value of 1 is 0.8813735870195432

结论

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

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程