Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

cplxtrig Trigonometric and hyperbolic functions

&pagelevel(3)&pagelevel

This section describes the trigonometric and hyperbolic functions for the data typecomplex.


#include <complex.h>

class complex
{

public:

friend complex sin(complex);
friend complex cos(complex);

friend complex sinh(complex);
friend complex cosh(complex);
};


complex y = sin(complex x)

Returns the sine of x.

complex y = cos(complex x)
Returns the cosine of x.

complex y = sinh(complex x)
Returns the hyperbolic sine of x.

complex y = cosh(complex x)
Returns the hyperbolic cosine of x.

RETURN VALUES


This section describes the trigonometric and hyperbolic functions for the data type complex.


#include <complex.h>

class complex
{

public:

friend complex sin(complex);
friend complex cos(complex);

friend complex sinh(complex);
friend complex cosh(complex);

};



complex y = sin(complex x)

Returns the sine of x.

complex y = cos(complex x)

Returns the cosine of x.

complex y = sinh(complex x)

Returns the hyperbolic sine of x.

complex y = cosh(complex x)

Returns the hyperbolic cosine of x.

RETURN VALUES


If the imaginary part of x causes an overflow, sinh and cosh return (0.0, 0.0). When the real part is large enough to cause an overflow, sinh and cosh return:

  • (HUGE, HUGE) if the cosine and sine of the imaginary part of x are >= 0;
  • (HUGE, -HUGE) if the cosine is >= 0 and the sine is < 0;
  • (-HUGE, HUGE) if the sine is >= 0 and the cosine is < 0.
  • (-HUGE, -HUGE) if both sine and cosine are < 0.

In all these cases, errno is set to ERANGE.
These error handling routines may be changed with the function complex_error() (see cplxerr).

EXAMPLE

The following program prints a range of complex numbers with their associated cosh() values:

#include <iostream.h>
#include <complex.h>
main()
{
  complex c;
  while (norm(c) < 10.0)
  {
    cout << c <<" " <<cosh(c) << "\n";
    c += complex(1.0, 1.0);
  }
  return 0;
}

The result of executing the program is:

( 0, 0)  ( 1, 0)
( 1, 1)  ( 0.83373, 0.988898)
( 2, 2)  ( -1.56563, 3.29789)
%  CCM0998 CPU time used: 0.0017 seconds

Note

The result of the cosh() function is a complex object.

The constants of type double (e.g. 10.0, 1.0 etc) are used to construct complex numbers.

SEE ALSO


cplxcartpol, cplxerr, cplxexp, cplxops