C++ complex atan


The C++ complex atan function computes the arc tangent of a complex number.The declaration of the asin function is given below.

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

Parameters:
x – A complex number for which arc tangent is to be computed.

Return type
complex number -The arc tangent of ‘x’ complex number.

Some points to note:

i) The arc tangent function is computed using the formula.
complex atan function

ii)The real number of an arc sine computed complex number is outputted in the interval [-π/2 , π/2].But the imaginary value is unbound.

This function is same as the C <complex.h> header ‘catan’ function.

Code example

complex< double > c1(45.6 , 8.90);

cout<< atan( c1 ) ;

Output in Code::Blocks,

(1.54967,0.00412128)

The real value is 1.54967 and the imaginary part is 0.00412128.

Explanation

In the above program the complex number supplied is 45.6 + i8.90 ,so the using the (above)formula, atan(45.6 + i8.90 ) , can be expressed as,

i/2 [ ln( (i + 45.6 + i8.90)/(i – 45.6 + i8.90)) ]

The ‘ln’ is a natural logarithm function,which is the loge function.If you reduce the expression to a complex number form the number obtained is 1.54967 + i0.00412128.

Link : C++ cmath log function


 



*Side Note

Some cases of atan function,

  ➥atan(conj(z) )=conj( atan(z) )

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

  ➥atan(±0 + iNaN) ,returns (nan , inan).

  ➥atan(±x + i(±∞) ) , returns ±π/2 + i(±0) ,for finite x.

  ➥atan(x + iNaN) ,returns NaN + iNaN and optionally raises the invalid floating-point exception, for nonzero finite x.

  ➥atan(±∞ + iy) returns ±π/2 + i0, for positive-signed finite y.

  ➥atan(±∞ + i∞) ,returns ±π/2 +i0.

  ➥atan(±∞ + iNaN) ,returns ±π/2+i0.

  ➥atan(NaN + iy) ,returns NaN +iNaN ,and optionally raises the invalid floating-point exception, for finite y.

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

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