Golang math.Asinh() Function with Examples

Golang | math.Asinh() Function: Here, we are going to learn about the Asinh() function of the math package with its usages, syntax, and examples.
Submitted by IncludeHelp, on August 29, 2021

math.Asinh()

The Asinh() function is an inbuilt function of the math package which is used to get the inverse hyperbolic sine of the given value.

It accepts one parameter and returns the inverse hyperbolic sine.

Syntax:

func Asinh(x float64) float64

Parameter(s):

  • x : The value whose inverse hyperbolic sine value is to be found.

Return Value:

The return type of Asinh() function is a float64, it returns the inverse hyperbolic sine value of the given value.

Special cases are:

  • Asinh(±0) = ±0
    If the parameter is either positive or negative zero (±0), it returns the same (±0).
  • Asinh(±Inf) = ±Inf
    If the parameter is either positive or negative infinity (±Inf), it returns the same (±Inf).
  • Asinh(NaN) = NaN
    If the parameter is NaN (Not-A-Number), it returns the same (NaN).

Example 1:

// Golang program to demonstrate the
// example of math.Asinh() Function

package main

import (
	"fmt"
	"math"
)

func main() {
	fmt.Println(math.Asinh(1))
	fmt.Println(math.Asinh(5.34))

	fmt.Println(math.Asinh(math.Inf(3)))
	fmt.Println(math.Asinh(0.5))

	fmt.Println(math.Asinh(math.NaN()))
	fmt.Println(math.Asinh(math.Sqrt(-2)))
}

Output:

0.881373587019543
2.377026866419682
+Inf
0.48121182505960347
NaN
NaN

Example 2:

// Golang program to demonstrate the
// example of math.Asinh() Function

package main

import (
	"fmt"
	"math"
)

func main() {
	var x float64
	var AcoshX float64

	x = 1
	AcoshX = math.Asinh(x)
	fmt.Println("Inverse hyperbolic sine value of", x, "is", AcoshX)

	x = 2.5
	AcoshX = math.Asinh(x)
	fmt.Println("Inverse hyperbolic sine value of", x, "is", AcoshX)

	x = 0.5
	AcoshX = math.Asinh(x)
	fmt.Println("Inverse hyperbolic sine value of", x, "is", AcoshX)

	x = math.Sqrt(-2)
	AcoshX = math.Asinh(x)
	fmt.Println("Inverse hyperbolic sine value of", x, "is", AcoshX)
}

Output:

Inverse hyperbolic sine value of 1 is 0.881373587019543
Inverse hyperbolic sine value of 2.5 is 1.6472311463710958
Inverse hyperbolic sine value of 0.5 is 0.48121182505960347
Inverse hyperbolic sine value of NaN is NaN

Golang math Package Constants and Functions »




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.