Go language has a huge library with various constants and functions for any type of data that provides inbuilt support for the basic constants and mathematical constants for complex numbers also. To work with complex numbers, the Go language has complex data types (complex64, complex128) and "math/cmplx" package. The "math/cmplx" package has various functions for different tasks.
To find the square root of the complex number – we use Sqrt() function of cmplx package.
Syntax:
func Sqrt(x complex128) complex128
The function accepts a complex number as a parameter and returns the square root of the same type.
Consider the below examples explaining – how to find the square root of the complex numbers in Golang?
Example 1:
Output:
Example 2:
Output: