C++ Standard Library C++ STL Library

C++ <complex> - sin() Function



The C++ <complex> sin() function returns the complex sine of a complex number z. It is a function on complex plane, and has no branch cuts. Mathematically, it can be expressed as:

complex sin

Syntax

template<class T> complex<T> sin (const complex<T>& z);

Parameters

z Specify the complex number, representing an angle expressed in radians.

Return Value

Returns the complex sine of z.

Example:

The example below shows the usage of <complex> sin() function.

#include <iostream>
#include <complex>
using namespace std;
 
int main (){
  complex<double> z1 (2, 2);
  complex<double> z2 (2, 0);
  complex<double> z3 (0, 2);

  //calculate the complex sine
  cout<<"sin(z1): "<<sin(z1)<<"\n";
  cout<<"sin(z2): "<<sin(z2)<<"\n";
  cout<<"sin(z3): "<<sin(z3)<<"\n";

  return 0;
}

The output of the above code will be:

sin(z1): (3.42095,-1.50931)
sin(z2): (0.909297,-0)
sin(z3): (0,3.62686)

❮ C++ <complex> Library