C++ complex acos


The C++ complex acos compute the arc cosine of the complex number.The declaration of the acos function is given below.

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

Parameters:
x – A complex number for which ‘acos’ is to be calculated.

Return type
complex number -The arc cosine complex number.

Some points to note:

i) The arc cosine function is given by :
complex acos function

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

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

Link : C++ complex real

Code example

complex< double > c1(9.4 , 73.45) , c2 ;

c2=acos( c1 );

cout<< c2.real( ) << endl //get the real number of c2
<< c2.imag( ) ; //get the imaginary number of c2

Output,

1.44352
-4.99792

Link : C++ complex imag

Explanation

In the above program the complex number supplied is 9.4 + i73.45 ,so using the (above)formula,acos(9.4 + i73.45 ) can be expressed as,

iln ( 9.4 + i73.45 ± i√ (1 – (9.4 + i73.45 )2)

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.44352 –i4.99792.

Link : C++ cmath log function


 



*Side Note

Some cases of acos function,

  ➥acos(conj(z) )=conj( acos(z) )

  ➥acos(±0 + i0) ,returns π/2− i0

  ➥acos(±0 + iNaN) ,returns π/2+iNaN.

  ➥acos(x + i∞) , returns π/2 − i∞ ,for finite x.

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

  ➥acos(−∞ + iy) returns π−i∞, for positive-signed finite y.

  ➥acos(+∞ +iy) ,returns +0−i∞ ,for positive-signed finite y.

  ➥acos(−∞ + i∞) ,returns 3π/4 −i∞.

  ➥acos(+∞ + i∞) ,returns π/4−i∞ .

  ➥acos(±∞ + iNaN) ,returns NaN±i∞ , (where the sign of the imaginary part of the result is unspecified).

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

  ➥acos(NaN + i∞) ,returns NaN−i∞

  ➥acos(NaN + iNaN) ,returns NaN+iNaN