Acosh()

Published Sep 27, 2023
Contribute to Docs

The Acosh() function returns the inverse hyperbolic cosine of a number.

Syntax

result := math.Acosh(number)

The Acosh() function takes one parameter, number, of type float64. And the method also returns a float64. This value represents the inverse hyperbolic cosine, or arccosh, of number. It’s important to note that the returned value is in radians. If the value of number is:

  • Not defined (undefined), then it returns NaN (Not a Number)
  • Less than 1, including negative infinity (-Inf) or equivalent, then it returns NaN
  • Greater than or equal to 1, including positive infinity (+Inf) or equivalent, then it returns +Inf

Note: The math library must be imported first to use this function.

Example

The following example first calculates the inverse hyperbolic cosine of num and then prints out the result to the console:

package main
import (
"fmt"
"math"
)
func main() {
num := 16.0
inverseHyperbolicCosine := math.Acosh(num)
fmt.Printf("The inverse hyperbolic cosine of %f is %f\n", num, inverseHyperbolicCosine)
}

The output will be:

The inverse hyperbolic cosine of 16.000000 is 3.464758

Codebyte Example

The following example is runnable and uses the Acosh() function with two values: positive infinity and 0.5:

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn Go on Codecademy