Overview

Package cmplx provides basic constants and mathematical functions for complex
numbers.

Index

Package files

asin.go exp.go isnan.go phase.go pow.go sin.go tan.go

func

Abs returns the absolute value (also called the modulus) of x.


Example:

  1. fmt.Printf("%.1f", cmplx.Abs(3+4i))
  2. // Output: 5.0

func Acos

  1. func Acos(x complex128)

Acos returns the inverse cosine of x.

func Acosh

  1. func Acosh(x complex128)

Acosh returns the inverse hyperbolic cosine of x.

func Asin

  1. func Asin(x complex128)

Asin returns the inverse sine of x.

func Asinh

  1. func Asinh(x complex128)

Asinh returns the inverse hyperbolic sine of x.

func Atan

  1. func Atan(x complex128)

Atan returns the inverse tangent of x.

func Atanh

  1. func Atanh(x complex128)

Atanh returns the inverse hyperbolic tangent of x.

  1. func Conj(x complex128)

Conj returns the complex conjugate of x.

func Cos

    Cos returns the cosine of x.

    func Cosh

    Cosh returns the hyperbolic cosine of x.

    func Cot

    1. func Cot(x complex128)

    Cot returns the cotangent of x.

    func Exp

    1. func Exp(x complex128)

    Exp returns e**x, the base-e exponential of x.


    Example:

    1. // Output: (0.0+0.0i)

    func

    1. func Inf()

    Inf returns a complex infinity, complex(+Inf, +Inf).

    func IsInf

    1. func IsInf(x complex128)

    IsInf returns true if either real(x) or imag(x) is an infinity.

    func IsNaN

    1. func IsNaN(x complex128)

    IsNaN returns true if either real(x) or imag(x) is NaN and neither is an
    infinity.

    func Log

    1. func Log(x complex128)

    Log returns the natural logarithm of x.

    func Log10

    1. func Log10(x complex128)

    Log10 returns the decimal logarithm of x.

    1. func NaN() complex128

    NaN returns a complex ``not-a-number’’ value.

    func

    Phase returns the phase (also called the argument) of x. The returned value is
    in the range [-Pi, Pi].

    func

    1. func Polar(x ) (r, θ float64)

    Polar returns the absolute value r and phase θ of x, such that x = r e*θi.
    The phase is in the range [-Pi, Pi].


    Example:

    1. r, theta := cmplx.Polar(2i)
    2. // Output: r: 2.0, θ: 0.5*π

    func Pow

    1. func Pow(x, y complex128)

    Pow returns x**y, the base-x exponential of y. For generalized compatibility
    with math.Pow:

    1. Pow(0, ±0) returns 1+0i

    func Rect

    1. func Rect(r, θ float64)

    Rect returns the complex number x with polar coordinates r, θ.

    func Sin

    1. func Sin(x complex128)

    Sin returns the sine of x.

    func Sinh

    1. func Sinh(x complex128)

    Sinh returns the hyperbolic sine of x.

    func Sqrt

    1. func Sqrt(x complex128)

    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).

    func Tan

      Tan returns the tangent of x.

      func Tanh