The `complex`

class provides a useful way to deal with complex numbers. It is defined as a basic template class in the `std`

namespace in the `<complex>`

header file.

template<typename Num> struct complex;

The type parameter `Num`

is the type that is used for each of the real and imaginary components of the complex number. It must be one of: `float`

, `double`

, or `long double`

.

Constructors | create complex numbers from the real and imaginary parts or other complex numbers |

Operators | arithmetic of complex numbers, equality of complex numbers, IO of complex numbers |

abs | absolute value of a complex number |

arg | argument (angle) of a complex number |

conj | conjugate of a complex number |

cos | cosine of a complex number |

cosh | hyperbolic cosine of a complex number |

exp | exponential of a complex number |

imag | imaginary part of a complex number |

log | natural logarithm of a complex number |

log10 | base-10 logarithm of a complex number |

norm | square of the absolute value of a complex number |

polar | constructs a complex number from polar coordinates |

pow | raising a complex number to a power, raising to a complex number power, or both |

real | real part of a complex number |

sin | sine of a complex number |

sinh | hyperbolic sine of a complex number |

sqrt | square root of a complex number |

tan | tangent of a complex number |

tanh | hyperbolic tangent of a complex number |