# Finding the Inverse Hyperbolic Cosine of Complex Number in Golang

Golang has a built-in math package that provides various mathematical functions. In this article, we will focus on finding the inverse hyperbolic cosine of a complex number using the math/cmplx package in Golang.

## Inverse Hyperbolic Cosine Function

The inverse hyperbolic cosine function (acosh) is the inverse function of the hyperbolic cosine function (cosh). It is defined for real numbers x ≥ 1, and its range is the set of non-negative real numbers. For complex numbers, acosh is defined as −

acosh(z) = ln(z + sqrt(z^2 - 1))


where ln is the natural logarithm, sqrt is the square root, and z is a complex number.

In Golang, the math/cmplx package provides the Acosh() function to find the inverse hyperbolic cosine of a complex number. The syntax of the Acosh() function is −

func Acosh(x complex128) complex128


The Acosh() function takes a complex number x as an argument and returns the inverse hyperbolic cosine of x.

## Example 1: Finding the Inverse Hyperbolic Cosine of a Complex Number

Let's find the inverse hyperbolic cosine of a complex number using the Acosh() function.

package main

import (
"fmt"
"math/cmplx"
)

func main() {
// Declare a complex number
z := complex(3, 4)

// Find the inverse hyperbolic cosine of z
acosh := cmplx.Acosh(z)

// Display the result
fmt.Printf("acosh(%v) = %v\n", z, acosh)
}


## Output

acosh((3+4i)) = (2.3055090312434685+0.9368124611557194i)


In this example, we first declare a complex number z using the complex() function. We then find the inverse hyperbolic cosine of z using the Acosh() function and store the result in the acosh variable. Finally, we display the result using the Printf() function.

## Example 2: Finding the Inverse Hyperbolic Cosine of a Real Number

Let's find the inverse hyperbolic cosine of a real number using the Acosh() function

package main

import (
"fmt"
"math/cmplx"
)

func main() {
// Declare a real number
x := 2.5

// Find the inverse hyperbolic cosine of x
acosh := cmplx.Acosh(complex(x, 0))

// Display the result
fmt.Printf("acosh(%v) = %v\n", x, acosh)
}


## Output

acosh(2.5) = (1.5667992369724106+0i)


In this example, we first declare a real number x. We then convert the real number to a complex number using the complex() function and find the inverse hyperbolic cosine of x using the Acosh() function. Finally, we display the result using the Printf() function.

## Conclusion

In this article, we learned how to find the inverse hyperbolic cosine of a complex number using the Acosh() function provided by the math/cmplx package in Golang. We also saw how to find the inverse hyperbolic cosine of a real number by converting it to a complex number. The Acosh() function is a useful tool for solving mathematical problems involving complex numbers.

Updated on: 12-Apr-2023

61 Views

##### Kickstart Your Career

Get certified by completing the course

Advertisements