pow() function for complex number in C++
The pow() function for complex number is defined in the complex header file. This function is the complex version of the pow() function. This function is used to calculate the complex power of base x raised to the y-th power.
Syntax:
template<class T> complex<T> pow (const complex<T>& x, int y);
or,
template<class T> complex<T> pow (const complex<T>& x, const complex<T>& y);or,
template<class T> complex<T> pow (const complex<T>& x, const T& y);or,
template<class T> complex<T> pow (const T& x, const complex<T>& y);
Parameter: This method accepts two parameters:
- x: It represents the base as a complex value.
- y: It represents the exponent as a complex value.
Return value: This function returns the complex power of base x raised to the y-th power.
Below programs illustrate the pow() function in C++:
Example 1:-
// c++ program to demonstrate // example of pow() function. #include <bits/stdc++.h> using namespace std; // driver program int main() { // initializing the complex: (1.0+2.0i) complex<double> complexnumber(1.0, 2.0); // use of pow() function for complex number cout << "(1.0, 2.0)^2 = " << pow(complexnumber, 2) << endl; return 0; } |
(1.0, 2.0)^2 = (-3,4)
Example 2:-
// c++ program to demonstrate // example of pow() function. #include <bits/stdc++.h> using namespace std; // driver program int main() { // initializing the complex: (2.0+1.0i) complex<double> complexnumber(2.0, 1.0); // use of pow() function for complex number cout << "(2.0, 1.0)^3 = " << pow(complexnumber, 3) << endl; return 0; } |
(2.0, 1.0)^3 = (2,11)
Recommended Posts:
- log() function for complex number in C++
- arg() function for Complex Number in C++
- tan() function for complex number in C++
- cos() function for complex number in C++
- exp() function for complex number in C++
- asin() function for complex number in C++
- atan() function for complex number in C++
- tanh() function for Complex Number in C++
- atanh() function for complex number in C++
- asinh() function for complex number in C++
- cosh() function for complex number in C++
- acos() function for complex number in C++
- polar() function for complex number in C++
- sinh() function for Complex Number in C++
- acosh() 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.



