在本文中,我们将讨论tan()C ++ STL中复数的工作原理,语法和函数示例。
tan()用于复数是<complex>头文件下的函数。此函数用于查找与其关联的复数的切线。此功能是tan()<cmath>头文件下的simple的复杂版本。
复数是由实数和虚数组成的数字。
它们写为:a + bi
其中a和b是实数,而i是虚数。
template<class T> complex<T> tan (const complex<T>& num);
该函数仅接受一个参数num,它是一个复杂值。
它返回num的正切值。
Input: complex <double> num(0.0, 1.0); tan(num); Output: (0, 1.55741)
#include <iostream>
#include <complex>
using namespace std;
int main () {
complex<double> tan_num(9.1, 2.6);
cout<<"tan of "<<tan_num<<" is "<<tan(tan_num);
return 0;
}输出结果
如果我们运行上面的代码,它将生成以下输出-
tan of (9.1, 2.6) is (-0.00661488, 0.99123)
#include <iostream>
#include <complex>
using namespace std;
int main () {
complex<double> tan_num(1.0, 0.0);
cout<<"tan of "<<tan_num<<" is "<<tan(tan_num);
return 0;
}输出结果
如果我们运行上面的代码,它将生成以下输出-
tan of (1, 0) is (1.55741, 0)