在Golang中查找指定数字的反双曲正切
在Golang中,math/cmplx包提供了用于计算复数各种数学运算的函数。反双曲正切函数,也称为arctanh,是该包提供的众多函数之一。反双曲正切函数用于查找双曲正切为给定数字的角度。本文解释了如何在Golang中查找指定数字的反双曲正切。
语法
查找复数的反双曲正切的语法如下:
func Acctanh(x complex128) complex128
参数
Acctanh()函数接受一个参数:一个复数。
返回值
Acctanh()函数返回给定复数的反双曲正切。
示例1:查找复数的反双曲正切
假设我们想找到复数(2+3i)的反双曲正切。以下是查找它的代码:
package main
import (
"fmt"
"math/cmplx"
)
func main() {
// Creating a complex number
z := complex(2, 3)
// Finding the inverse hyperbolic tangent of the complex number
actanh := cmplx.Atanh(z)
// Displaying the result
fmt.Println("Inverse Hyperbolic Tangent of", z, "is", actanh)
}
输出
Inverse Hyperbolic Tangent of (2+3i) is (0.14694666622552977+1.3389725222944935i)
示例2:查找负复数的反双曲正切
假设我们想找到负复数(-4-5i)的反双曲正切。以下是查找它的代码:
package main
import (
"fmt"
"math/cmplx"
)
func main() {
// Creating a complex number
z := complex(-4, -5)
// 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 (-4-5i) is (-0.09641562020299616-1.4483069952314644i)
示例3:查找零复数的反双曲正切
假设我们想找到零复数(0+0i)的反双曲正切。以下是查找它的代码:
package main
import (
"fmt"
"math/cmplx"
)
func main() {
// Creating a complex number
z := complex(0, 0)
// 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+0i) is (0+0i)
结论
使用math/cmplx包的Acctanh()函数,在Golang中查找指定数字的反双曲正切是一项简单的任务。它接受一个复数作为输入,并返回该数的反双曲正切。
广告
数据结构
网络
关系数据库管理系统 (RDBMS)
操作系统
Java
iOS
HTML
CSS
Android
Python
C语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP