{{merge#redirect to|[[C mathematical operations|discuss=Talk:math.h#Single page for C mathematical functions|date=OctoberFunction 2011}}overview]]
{{lowercase|title=complex.h}}
{{C Standard library}}
'''complex.h''' is a [[header file]] in the [[C standard library|standard library]] of the [[C programming language]] that defines functionality for [[complex arithmetic]].<ref name="SUS">{{man|bd|complex.h|SUS|complex arithmetic}}</ref> These functions use the built-in type <code>complex</code> which was introduced with the [[C99]] revision of C.
This header should not be confused with the [[C++ standard library]] header <code><complex></code>, which implements complex numbers in a completely different way (as a template class, <code>complex<T></code>).
== Macro ==
Universal macro:
* complex - alias of _Complex
* _Complex_I - constant, which has type "const float _Complex" and value of imaginary unit I, I*I=-1
Defined only for `C99 Annex G`-compatible compiler modes - native support of imaginary types (it is very rare because Annex G is mathematically incorrect<ref>[http://books.google.com/books?id=PmNVAAAAMAAJ&q=C99+Annex+G& Dr. Dobb's journal: software tools for the professional programmer, Volume 27] "many results in Annex G are pure invention and mathematically incorrect"</ref>):
* imaginary - alias of _Imaginary
* _Imaginary_I Expands to a constant expression of type const float _Imaginary with the value of the imaginary unit.
Universal alias of I:
* I - alias of _Imaginary_I if it is defined else - alias of _Complex_I
Application may undefine complex, imaginary, and I macros if they interfere with internal values.
==Functions==
Each function declared in <code>complex.h</code> has three versions, each of which works with a different floating-point type (<code>double</code>, <code>float</code> and <code>long{{nbsp}}double</code>). Only the <code>double</code> version of each function is listed here; to use the <code>float</code> (or <code>long{{nbsp}}double</code>) version, append an <code>f</code> (or an <code>l<code>, respectively) to the function's name.
:{{note label|cproj|A|A}} cproj(''z'') projects the complex number ''z'' onto the [[Riemann sphere]]; the result is ''z'' itself, except complex infinities are mapped to positive infinity on the real axis.<ref>{{man|sh|cproj|SUS|complex projection function}}</ref>