在本文中,我们将讨论tanh()
C ++ STL中复数的工作原理,语法和函数示例。
tanh()用于复数是<complex>头文件下的函数。此函数用于查找复数的双曲正切。这是tanh()
<cmath>头文件下的的复杂版本。
Tanh是双曲正切函数。为了轻松定义函数,我们可以说tanh等于双曲正弦除以双曲余弦。
complex<T> tanh(complex& num);
该函数仅接受一个复杂类型的参数num。
它返回正切数的双曲线。
Input: complex <double> num(0.0, 1.0); tanh(num); Output: (0, 1.55741) Input: complex <double> num(1.0, 0.0); tanh(num); Output: (0.761594, 0)
在主函数中,我们定义复数。
然后我们打印复合体。
最后,我们打印出复数的双曲正切值。
通过这种方法,我们可以找出复数的双曲正切。
展示tanh()函数工作的C ++代码
#include<iostream.h> #include<complex.h> #include<cmath.h> using namespace std; int main( ) { / / defining complex number Complex<double> x(1,0); Cout<< “ tanh “<<x<<” =” << tanh(x)<<endl; return 0; }
输出结果
如果我们运行上面的代码,它将生成以下输出-
tanh(1.000000,0.000000) = (0.761594, 0.000000) tanh(0.000000,1.000000) = (0.000000, 1.557408)