在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