complex - STL C++

tan()

Declaration

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

Description

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

tan(z) = (e^(iz) - e^(-iz))/(i(e^(iz) + e^(-iz))).

Header Include

#include <complex>

Example

#include <complex>
#include <iostream>

int main()
{
	using namespace std;

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

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

Output

tan() Output
 

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