C++ complex tan


The C++ complex ‘tan’ function compute the tangent of the complex number.The declaration of the function is given below.

template<class T> complex<T> tan(const complex<T>& x);

Parameters:
x – A complex number whose tangent is to be computed.

Return type
complex<T> -The complex tangent of ‘x’.

Some points to note:

i) The tangent is computed using the formula.

C++ complex tan

Link : C++ cmath sin

Link : C++ cmath cos

Code example

complex< double > c1(6.78 , 2.34);

cout<< tan( c1 ) ;

Output,

(0.0153946,0.989806)

Explanation

The computation process of tan( c1 ) function is easy.Simply evaluate the equation,

=sin( c1 )/cos(c1)
=[ sin( 45.67 )cosh( 9.077 ) – icos( 45.67 )sinh( 9.077 ) ] / [cos( 23 )cosh( 45.5 ) – isin( 23 )sinh( 45.5 )]

The resultant value obtained is the tangent of c1.The cos,sin , cosh and sinh functions are defined under the header <cmath> .


*Side Note

Some cases of tan function,

  ➥tan(conj(z) )=conj( tan(z) ).

  ➥tan(±0 + i(±0)) , returns (±0 + i(±0)).

  ➥tan(±0 + iNaN) ,returns (±0 , iNaN).

  ➥tan(x + i∞ ) , returns (±0 ,i(±1) ),for some finite value ‘x’.

  ➥tan(±x + iNaN) ,returns NaN + iNaN,for some finite value ‘x’.

  ➥tan(±∞ + iy) ,returns NaN + iNaN ,for some finite value ‘y’.

  ➥tan(±∞ + i∞) ,returns (±0 , i(±1)).

  ➥tan(±∞ + iNaN) ,returns NaN +iNaN

  ➥tan(NaN + iy) ,returns NaN +iNaN ,for some finite value ‘y’.

  ➥tan(NaN + i(±)∞) ,returns NaN + iNaN .

  ➥tan(NaN + iNaN) ,returns NaN+iNaN.

Link :C++ complex conj