複素数ライブラリには、多くの数学関数が含まれています。複素数に特有のものもあれば、C の標準数学ライブラリの関数と同じで複素数を対象にしたものもあります。
これらの関数はすべて、あらゆる可能な引数に対して結果を返します。関数が数学的に正しい結果を返せないような場合は、complex_error を呼び出して、何らかの適切な値を返します。たとえば、関数はオーバーフローが実際に起こるのを避け、代わりにメッセージで complex_error を呼び出します。次の表で複素数ライブラリの関数を説明します。
sqrt 関数と atan2 関数は、C99 の csqrt (Annex G) の仕様に従って実装されています。
| 複素数ライブラリ関数 | 内容の説明 | 
|---|---|
| double abs(const complex) | 複素数の絶対値を返します。 | 
| double arg(const complex) | 複素数の偏角を返します。 | 
| complex conj(const complex) | 引数に対する共役複素数を返します。 | 
| double imag(const complex&) | 複素数の虚部を返します。 | 
| double norm(const complex) | 引数の絶対値の 2 乗を返します。abs より高速ですが、オーバーフローが起きやすくなります。絶対値の比較に使用します。 | 
| complex polar(double mag, double ang=0.0) | 複素数の絶対値と偏角を表す一組の極座標を引数として受け取り、それに対応する複素数を返します。 | 
| double real(const complex&) | 複素数の実部を返します。 | 
表 14–2 複素数の数学関数と三角関数
| 内容の説明 | |
|---|---|
| complex acos(const complex) | 引数が余弦となるような角度を返します。 | 
| complex asin(const complex) | 引数が正弦となるような角度を返します。 | 
| complex atan(const complex) | 引数が正接となるような角度を返します。 | 
| complex cos(const complex) | 引数の余弦を返します。 | 
| complex cosh(const complex) | 引数の双曲線余弦を返します。 | 
| complex exp(const complex) | e**x を計算します。ここで e は自然対数の底で、x は関数 exp に渡された引数です。 | 
| complex log(const complex) | 引数の自然対数を返します。 | 
| complex log10(const complex) | 引数の常用対数を返します。 | 
| complex pow(double b, const complex exp) complex pow(const complex b, int exp) complex pow(const complex b, double exp) complex pow(const complex b, const complex exp) | 引数を 2 つ持ちます。pow(b, exp).b を exp 乗します。 | 
| complex sin(const complex) | 引数の正弦を返します。 | 
| complex sinh(const complex) | 引数の双曲線正弦を返します。 | 
| complex sqrt(const complex) | 引数の平方根を返します。 | 
| complex tan(const complex) | 引数の正接を返します。 | 
| complex tanh(const complex) | 引数の双曲線正接を返します。 |