complex - STL C++

sin()

Declaration

complex<X> sin(const complex<X>& kqrZ);

Description

This is the friend function sin() for complex numbers. It returns the sine of the complex number kqrZ, which is equal to (exp(i*kqrZ) - exp(-i*kqrZ))/2i. The formula for the sine of a complex number z is

sin(z) = (e^(iz) - e^(-iz))/2i.

Header Include

#include <complex>

Example

#include <complex>
#include <iostream>

int main()
{
	using namespace std;

	// Create a complex number and calculate its sine
	complex<double> qZ(2.0, 4.0);
	cout << "Complex Number : "<< qZ << endl;
	cout << "The sine is "<< sin(qZ) << endl;

	// Keep the window open
	cin.get();
	return 0;
}

Output

sin() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.