std::cos(std::complex)

Header: <complex>

Computes complex cosine of a complex value z.

# Declarations

template< class T >
complex<T> cos( const complex<T>& z );

# Parameters

# Return value

If no errors occur, the complex cosine of z is returned.

# Notes

The cosine is an entire function on the complex plane, and has no branch cuts.

# Example

#include <cmath>
#include <complex>
#include <iostream>
 
int main()
{
    std::cout << std::fixed;
    std::complex<double> z(1.0, 0.0); // behaves like real cosine along the real line
    std::cout << "cos" << z << " = " << std::cos(z)
              << " ( cos(1) = " << std::cos(1) << ")\n";
 
    std::complex<double> z2(0.0, 1.0); // behaves like real cosh along the imaginary line
    std::cout << "cos" << z2 << " = " << std::cos(z2)
              << " (cosh(1) = " << std::cosh(1) << ")\n";
}

# See also