在 Golang 中求复数的反双曲正切
在数学中,复数的反双曲正切或反 tanh 定义为双曲正切函数的反函数。在 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)
结论
在本文中,我们学习了如何在 Golang 中使用 cmplx.Atanh() 函数查找复数的反双曲正切。我们还提供了一些示例来了解其实现。
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP