Finding the Inverse Hyperbolic Tangent of Complex Number in Golang


In mathematics, the inverse hyperbolic tangent or inverse tanh of a complex number is defined as the inverse function of the hyperbolic tangent function. In Golang, this function can be implemented using the cmplx.Atanh() function.

Syntax

The syntax for finding the inverse hyperbolic tangent of a complex number is as follows −

func Atanh(z complex128) complex128

Here, z is the complex number whose inverse hyperbolic tangent is to be calculated, and the function returns the inverse hyperbolic tangent of the complex number in the form of a complex128 value.

Example 1

Let's say we have a complex number z = 3 + 4i. We can find the inverse hyperbolic tangent of this complex number using the cmplx.Atanh() function.

package main

import (
   "fmt"
   "math/cmplx"
)

func main() {
   // Creating a complex number
   z := complex(3, 4)
   
   // Finding the inverse hyperbolic tangent of the complex number
   atanh := cmplx.Atanh(z)
   
   // Displaying the result
   fmt.Println("Inverse Hyperbolic Tangent of", z, "is", atanh)
}

Output

Inverse Hyperbolic Tangent of (3+4i) is (0.1175009073114339+1.4099210495965755i)

Example 2

Let's say we have a complex number z = -5 - 12i. We can find the inverse hyperbolic tangent of this complex number using the cmplx.Atanh() function.

package main

import (
   "fmt"
   "math/cmplx"
)

func main() {
   // Creating a complex number
   z := complex(0, 1)
   
   // Finding the inverse hyperbolic tangent of the complex number
   atanh := cmplx.Atanh(z)
   
   // Displaying the result
   fmt.Println("Inverse Hyperbolic Tangent of", z, "is", atanh)
}

Output

Inverse Hyperbolic Tangent of (0+1i) is (0+0.7853981633974483i)

Conclusion

In this article, we have learned about finding the inverse hyperbolic tangent of a complex number in Golang using the cmplx.Atanh() function. We have also seen some examples to understand its implementation.

Updated on: 17-Apr-2023

113 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements