Finding the Square Root of the Complex Number in Golang
Go language provides inbuilt support for basic constants and mathematical functions for complex numbers with the help of the cmplx package. You are allowed to find the square root of the specified complex number with the help of Sqrt() function provided by the math/cmplx package. In this function, q is chosen so that real(q) >= 0 and imag(q) has the same sign as imag(y). So, to access the Sqrt() function you need to add a math/cmplx package in your program with the help of the import keyword.
func Sqrt(y complex128) complex128
Let us discuss this concept with the help of the given examples:
Result 1: (3.00-1.00i) Result 2: (2.08+2.89i) Result 3: (1.80-2.50i)
Complex Number 1: (0+2i) Square Root 1: (1.0+1.0i) Complex Number 2: (4+6i) Square Root: (2.4+1.3i) Sum : (3.4+2.3i)
My Personal Notes arrow_drop_up
Please Login to comment...