How to find the Hyperbolic Sine of a given radian value in Golang?



In this tutorial, we will learn how to find the Hyperbolic Sine of a given radian value in the Golang programming Language. Golang language has many packages with predefined functions that the developer can use without writing the complete logic.

To perform the mathematical operations and logic we have a math package in Golang. We will use this package only to find the Hyperbolic Sine of a given radian value. We will also see how to import the package and also how to call a function this package consists of by writing a Golang code.

Hyperbolic Sine

Definition

Hyperbolic Sine is a function similar to trigonometry functions. The algebraic expression helps in finding the hyperbolic functions that include the exponential function(e^x). The formula for hyperbolic sine is written below and the value of Hyperbolic Sine is at different angles.

Syntax

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

Graph


Value of Hyperbolic Sine at different angles

  • sinh(0) = 0

  • sinh(30) = 5.3432373e+12

  • sinh(45) = 1.7467136e+19

  • sinh(60) = 5.7100369e+25

  • sinh(90) = 6.1020165e+38

Algorithm

Step 1 - Declaring the variable to store the value of the guardian and answer of float32 type.

Step 2 - Initializing the variable of a radian.

Step 3 - Call the function of hyperbolic sine and pass the radian value.

Step 4 - Printing the result.

Example

In this example, we will write a Golang program in which we will import a math package and call the hyperbolic sine function.

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)
} 

Output

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

Algorithm

Step 1 - Declaring the variable to store the value of the guardian and answer of float32 type.

Step 2 - Initializing the variable of a radian.

Step 3 - Call the function of hyperbolic sine defined by us and pass the radian value as a parameter.

Step 4 - Printing the result.

Example

In this example, we will write a Golang program in which we will import a math package and call the hyperbolic sine function in a separate function and call that function 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 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)
} 

Output

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

Conclusion

These are two ways to find the hyperbolic sine by using the function in the math package and passing the radian value as a parameter. The second approach will provide abstraction in the program. To learn more about Golang you can explore these tutorials.


Advertisements