sqrt() function for complex number in C++
The complex version of sqrt() function is defined in the complex header file. This function is used to calculate the square root of the complex number z with a branch cut along the negative real axis.
template <class T> complex<T> sqrt(const complex<T>& z);
Parameters: This method takes a mandatory parameter z which represents the complex number whose square root is to be calculated.
Return Value: This function returns the square root of the complex number z.
Below program illustrate the sqrt() function for complex number in C++:
Square root of -9 is (0,3) Square root of (-9, -0) is (0,-3)
Time Complexity: O(√(a2+b2)) where a and b are the real and imaginary part of complex number.
Auxiliary Space: O(1)