在 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