package cmplx
Import Path
math/cmplx (on go.dev)
Dependency Relation
imports 2 packages, and imported by 0 packages
Involved Source Files
Package cmplx provides basic constants and mathematical functions for
complex numbers. Special case handling conforms to the C99 standard
Annex G IEC 60559-compatible complex arithmetic.
asin.go
conj.go
exp.go
isinf.go
isnan.go
log.go
phase.go
polar.go
pow.go
rect.go
sin.go
sqrt.go
tan.go
Code Examples
package main
import (
"fmt"
"math/cmplx"
)
func main() {
fmt.Printf("%.1f", cmplx.Abs(3+4i))
}
package main
import (
"fmt"
"math"
"math/cmplx"
)
func main() {
fmt.Printf("%.1f", cmplx.Exp(1i*math.Pi)+1)
}
package main
import (
"fmt"
"math"
"math/cmplx"
)
func main() {
r, theta := cmplx.Polar(2i)
fmt.Printf("r: %.1f, θ: %.1f*π", r, theta/math.Pi)
}
Package-Level Functions (total 27)
Abs returns the absolute value (also called the modulus) of x.
Acos returns the inverse cosine of x.
Acosh returns the inverse hyperbolic cosine of x.
Asin returns the inverse sine of x.
Asinh returns the inverse hyperbolic sine of x.
Atan returns the inverse tangent of x.
Atanh returns the inverse hyperbolic tangent of x.
Conj returns the complex conjugate of x.
Cos returns the cosine of x.
Cosh returns the hyperbolic cosine of x.
Cot returns the cotangent of x.
Exp returns e**x, the base-e exponential of x.
Inf returns a complex infinity, complex(+Inf, +Inf).
IsInf reports whether either real(x) or imag(x) is an infinity.
IsNaN reports whether either real(x) or imag(x) is NaN
and neither is an infinity.
Log returns the natural logarithm of x.
Log10 returns the decimal logarithm of x.
NaN returns a complex “not-a-number” value.
Phase returns the phase (also called the argument) of x.
The returned value is in the range [-Pi, Pi].
Polar returns the absolute value r and phase θ of x,
such that x = r * e**θi.
The phase is in the range [-Pi, Pi].
Pow returns x**y, the base-x exponential of y.
For generalized compatibility with [math.Pow]:
Pow(0, ±0) returns 1+0i
Pow(0, c) for real(c)<0 returns Inf+0i if imag(c) is zero, otherwise Inf+Inf i.
Rect returns the complex number x with polar coordinates r, θ.
Sin returns the sine of x.
Sinh returns the hyperbolic sine of x.
Sqrt returns the square root of x.
The result r is chosen so that real(r) ≥ 0 and imag(r) has the same sign as imag(x).
Tan returns the tangent of x.
Tanh returns the hyperbolic tangent of x.
The pages are generated with Golds v0.7.0-preview. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |