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.
Syntax:
template <class T> complex<T>
sqrt(const complex<T>& z);
Parameters: This method takes a mandaory 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++:
Example:-
// C++ program to demonstrate // example of sqrt() function. #include <bits/stdC++.h> using namespace std; int main() { cout << "Square root of -9 is ="; cout << sqrt(complex<double>(-9, 0)) << endl; cout << "Square root of (-9, -0), is = "; cout << sqrt(complex<double>(-9, -0.0)) << endl; return 0; } |
Square root of -9 is =(0,3) Square root of (-9, -0) is = (0,-3)
Recommended Posts:
- cos() function for complex number in C++
- tan() function for complex number in C++
- arg() function for Complex Number in C++
- abs() function for complex number in c++
- pow() function for complex number in C++
- log() function for complex number in C++
- exp() function for complex number in C++
- acosh() function for complex number in C++
- sin() function for complex number in C++ with Examples
- asinh() function for complex number in C++
- sinh() function for Complex Number in C++
- atan() function for complex number in C++
- polar() function for complex number in C++
- log10() function for complex number in C++
- tanh() function for Complex Number in C++
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.



