complx.Polar() Function in Golang With Examples Last Updated : 28 Apr, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report complx.Polar() Function in Golang returns the absolute value r and phase θ of x. The phase θ will be in the range [-Pi, Pi]. Syntax: func Polar(x complex128) (r, θ float64) Here, x is a complex number. Return Value: The return value is in the range [-Pi, Pi]. Example 1: C // Golang program to illustrate // the complx.Polar() Function package main // importing fmt, math and math/cmplx import ( "fmt" "math" "math/cmplx" ) // Calling Main func main() { // getting the r and theta value r, theta := cmplx.Polar(7i) // calculate the value in Pi format. p := theta/math.Pi // printing the values r and p. fmt.Printf("rValue: %.1f, pValue: %.1f*Pi", r, p) } Output: rValue: 7.0, pValue: 0.5*Pi Example 2: C // Golang program to illustrate // the complx.Polar() Function package main // importing fmt, math and math/cmplx import ( "fmt" "math" "math/cmplx" ) // Calling Main func main() { // We can create a complex number like this also. n := complex(5, 6) // getting the r and theta value of complex number 5 + 6i r, theta := cmplx.Polar(n) // calculate the value in Pi format. p := theta/math.Pi // printing the values r and p. fmt.Printf("rValue: %.1f, pValue: %.1f*Pi", r, p) } Output: rValue: 7.8, pValue: 0.3*Pi Comment More infoAdvertise with us Next Article complx.NaN() Function in Golang With Examples P PranchalKatiyar Follow Improve Article Tags : Go Language Golang-Complex Similar Reads complx.Pow() Function in Golang With Examples complx.Pow() Function in Golang is used to find x**y, the base-x exponential of y. For this function, one need to import the "math/cmplx" package. Syntax: func Pow(x, y complex128) complex128 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 Pa 1 min read complx.Phase() Function in Golang with Examples In Go language, cmplx packages supply basic constants as well as mathematical functions for the complex numbers. The Phase() function in Go language is used to return the phase (also called the argument) of a given number. Moreover, this function is defined under the cmplx package. Here, you need to 1 min read complx.NaN() Function in Golang With Examples complx.NaN() function in Golang is used to returns a complex ânot-a-numberâ value. Syntax: func NaN() complex128 It returns the complex NaN value. Let us discuss this concept with the help of given examples: Example 1: C // Golang program to illustrate // the complx.NaN() Function package main impor 1 min read complx.Rect() Function in Golang With Examples complx.Rect() Function in Golang returns the complex number x with polar coordinates r, θ. It takes the float value as input and return complex number. This method belongs to complex package. Syntax: func Rect(r, θ float64) complex128; Here, r and θ are the complex numbers with flo 1 min read complx.IsNaN() Function in Golang With Examples In Go language, cmplx packages supply basic constants as well as mathematical functions for the complex numbers. The IsNaN() function in Go language is used to check if either the stated real(x) or imag(x) is NaN or not and is neither an infinity. Moreover, this function is defined under the cmplx p 1 min read complx.Exp() Function in Golang With Examples complx.Exp() Function in Golang is used to returns e**x, the base-e exponential of x. Syntax: func Exp(x complex128) complex128 Here, x is the set of all complex numbers real as well as imaginary parts. Return Type: The return type of this function is a complex number. Example 1: C // Golang program 1 min read Like