# 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

Parameters: The parameters used are two complex numbers where complex128 is the set of all complex numbers with float64 real and imaginary parts. The return type of this function is also a complex number.

Example 1:

 `package main ` `  `  `import ( ` `    ``"fmt"` `    ``"math/cmplx"` `) ` `  `  `func main() { ` `    ``var a complex128 ` `    ``var b complex128 ` `    ``a= complex(2,5) ` `    ``b= complex(3,7) ` `    ``fmt.Println(cmplx.Pow(a,b)) ` `} `

Output:

`(-0.03528847161704272+0.0129436389603905i)`

Example 2:

 `// Golang program to illustrate ` `// the complx.Pow() Function ` ` `  `package main ` `  `  `import ( ` `    ``"fmt"` `    ``"math/cmplx"` `) ` `  `  `func main() { ` `    ``var a complex128 ` `    ``var b complex128 ` `    ``a= complex(1,2) ` `    ``b= complex(1,0) ` `     `  `    ``// using the function ` `    ``fmt.Println(cmplx.Pow(a,b)) ` `} `

Output:

`(1.0000000000000002+2i)`
My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.