## Abstract

Complex numbers parameterised over the representation of their real parts.

Divided into a module type for modules that implement complex numbers, and a parametric module that can construct such modules.

## Synopsis

module type complex = {
| |||||||||||||||||||||||||||||||||||||||||||||||||||||

module mk_complex | : | (T: real) -> (complex with real = T.t with complex = (T.t, T.t)) |

## Description

- ↑module type complex
The type of modules that implement a notion of complex numbers. Semantically, a complex number can be seen as a pair of two numbers (but this need not be the representation).

- ↑type real
The type of the components of the complex number.

- ↑type complex
The type of complex numbers.

- ↑val mk: real -> real -> complex
Construct a complex number from real and imaginary components.

- ↑val mk_re: real -> complex
Construct a complex number from just the real component. The imaginary part will be zero.

- ↑val mk_im: real -> complex
Construct a complex number from just the imaginary component. The real part will be zero.

- ↑val conj: complex -> complex
Conjugate a complex number.

- ↑val re: complex -> real
The real part of a complex number.

- ↑val im: complex -> real
The imaginary part of a complex number.

- ↑val mag: complex -> real
The magnitude (or modulus, or absolute value) of a complex number.

- ↑val arg: complex -> real
The argument (or phase) of a complex number.

- ↑val +: complex -> complex -> complex
- ↑val -: complex -> complex -> complex
- ↑val *: complex -> complex -> complex
- ↑val /: complex -> complex -> complex
- ↑val sqrt: complex -> complex
- ↑val exp: complex -> complex
- ↑val log: complex -> complex

- ↑module mk_complex
Given a module describing a number type, construct a module implementing complex numbers.