Standard library / math/cmplx

cmplx.Polar()

Returns magnitude and phase in radians. Phase uses the principal argument. Expected stdout: '2 0\n'.

Formal Syntax & Structure

go syntaxgo
func Polar(x complex128) (r, θ float64)

Parameters & Attributes

NameTypeDescription
xcomplex128First input operand (or sole input if unary).

Return Value

(r, θ float64)

Returns magnitude and phase in radians. Phase uses the principal argument.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/cmplx")
func main() {  r, t := cmplx.Polar(2)  fmt.Println(r, t)}
Go Reference