Open In App
Related Articles

sin() function for complex number in C++ with Examples

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

The sin() function for complex numbers is defined in the <complex> header file. This function is the complex version of the sin() function. This function is used to calculate the complex sine of the complex number z. This function returns the sine of the complex number z. 

Syntax

sin (z);

Parameters

  • z: This method takes a mandatory parameter z which represents the complex number.

Return value

  • This function returns the sin() of the complex number z.

Example 1

C++

// C++ program to demonstrate
// example of sin() function
// for Complex numbers
 
#include <complex>
#include <iostream>
using namespace std;
 
int main()
{
    complex<double> complexnumber(0.0, 1.0);
 
    // use of sin() function for complex number
    cout << "The sin of Complex Numbers: " << complexnumber << " is "
         << sin(complexnumber) << endl;
 
    return 0;
}

                    

Output
The sin of Complex Numbers: (0,1) is (0,1.1752)

Time Complexity: O(1)
Auxiliary Space: O(1)

Example 2

C++

// C++ program to demonstrate
// example of sin() function
// for Complex numbers
 
#include <complex>
#include <iostream>
using namespace std;
 
int main()
{
    complex<double> complexnumber(1.0, 0.0);
 
    // Use of sin() function for complex number
    cout << "The sin of Complex Number: " << complexnumber << " is "
         << sin(complexnumber) << endl;
 
    return 0;
}

                    

Output
The sin of Complex Number: (1,0) is (0.841471,0)

Time Complexity: O(1)
Auxiliary Space: O(1)



Last Updated : 28 Jun, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads