Menu Close

Go – How to get the inverse hyperbolic tangent of number

Here, We will learn how to get the inverse hyperbolic tangent of number in go. We can get it by using Atanh() function in math package in go golang.

Function prototype:

func Atanh(x float64) float64

Return value:

Atanh() function in math package returns
the inverse hyperbolic tangent of number.

Example with code:

package main

import (
  "fmt"
  "math"
)

func main() {

  no := math.Atanh(0.25)
  fmt.Printf("%.2f\n", no)

  no = math.Atanh(0)
  fmt.Printf("%.2f\n", no)

  no = math.Atanh(2)
  fmt.Printf("%.2f\n", no)

  no = math.Atanh(0.75)
  fmt.Printf("%.2f\n", no)

  no = math.Atanh(1)
  fmt.Printf("%.2f\n", no)
}

Output:

0.26
0.00
NaN
0.97
+Inf

To learn more about golang, Please refer given below link:

https://www.techieindoor.com/go-lang-tutorial/

References:

https://golang.org/doc/
https://golang.org/pkg/
Posted in golang, math

Leave a Reply

Your email address will not be published. Required fields are marked *