Golang 找到复数的反双曲正切值
在数学中,复数的反双曲正切或反正切h是双曲正切函数的反函数。在Golang中,可以使用cmplx.Atanh()函数来实现这个功能。
语法
找到复数的反双曲正切值的语法如下:
func Atanh(z complex128) complex128
在这里,z是要计算其反双曲正切的复数,该函数以complex128值的形式返回复数的反双曲正切。
示例1
假设我们有一个复数z = 3 + 4i。我们可以使用cmplx.Atanh()函数找到该复数的反双曲正切。
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)
}
输出
Inverse Hyperbolic Tangent of (3+4i) is (0.1175009073114339+1.4099210495965755i)
示例2
假设我们有一个复数 z = -5 – 12i。我们可以使用 cmplx.Atanh() 函数找到此复数的反双曲正切。
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)
}
输出
Inverse Hyperbolic Tangent of (0+1i) is (0+0.7853981633974483i)
结论
在本文中,我们学习了如何使用cmplx.Atanh()函数在Golang中找到复数的反双曲正切。我们也看了一些示例来理解它的实现。