Module BatComplex


module BatComplex: sig .. end
Additional and modified functions for complex numbers.


Complex numbers.

This module provides arithmetic operations on complex numbers. Complex numbers are represented by their real and imaginary parts (cartesian representation). Each part is represented by a double-precision floating-point number (type float).

This module extends Stdlib's Complex module, go there for documentation on the rest of the functions and types.

val zero : Complex.t
The complex number 0.
val one : Complex.t
The complex number 1.
val i : Complex.t
The complex number i.
val neg : Complex.t -> Complex.t
Unary negation.
val conj : Complex.t -> Complex.t
Conjugate: given the complex x + i.y, returns x - i.y.
val add : Complex.t -> Complex.t -> Complex.t
Addition
val sub : Complex.t -> Complex.t -> Complex.t
Subtraction
val mul : Complex.t -> Complex.t -> Complex.t
Multiplication
val inv : Complex.t -> Complex.t
Multiplicative inverse (1/z).
val div : Complex.t -> Complex.t -> Complex.t
Division
val sqrt : Complex.t -> Complex.t
Square root. The result x + i.y is such that x > 0 or x = 0 and y >= 0. This function has a discontinuity along the negative real axis.
val norm2 : Complex.t -> float
Norm squared: given x + i.y, returns x^2 + y^2.
val norm : Complex.t -> float
Norm: given x + i.y, returns sqrt(x^2 + y^2).
val arg : Complex.t -> float
Argument. The argument of a complex number is the angle in the complex plane between the positive real axis and a line passing through zero and the number. This angle ranges from -pi to pi. This function has a discontinuity along the negative real axis.
val polar : float -> float -> Complex.t
polar norm arg returns the complex having norm norm and argument arg.
val exp : Complex.t -> Complex.t
Exponentiation. exp z returns e to the z power.
val log : Complex.t -> Complex.t
Natural logarithm (in base e).
val pow : Complex.t -> Complex.t -> Complex.t
Power function. pow z1 z2 returns z1 to the z2 power.
val operations : Complex.t BatNumber.numeric
val inv : Complex.t -> Complex.t
inv x returns the value of 1/x
val succ : Complex.t -> Complex.t
Add BatComplex.one to this number.
val pred : Complex.t -> Complex.t
Remove BatComplex.one from this number.
val abs : Complex.t -> Complex.t
abs c returns the module of this complex number, i.e. abs c = Float.sqrt((re c) *. (re c) +. (im c) *. (im c) )
val modulo : Complex.t -> Complex.t -> Complex.t
val pow : Complex.t -> Complex.t -> Complex.t
val compare : Complex.t -> Complex.t -> int
val of_int : int -> Complex.t
val to_int : Complex.t -> int
val of_string : string -> Complex.t
val to_string : Complex.t -> string
val (+) : Complex.t -> Complex.t -> Complex.t
val (-) : Complex.t -> Complex.t -> Complex.t
val ( * ) : Complex.t -> Complex.t -> Complex.t
val (/) : Complex.t -> Complex.t -> Complex.t
val ( ** ) : Complex.t -> Complex.t -> Complex.t
val (<>) : Complex.t -> Complex.t -> bool
val (>=) : Complex.t -> Complex.t -> bool
val (<=) : Complex.t -> Complex.t -> bool
val (>) : Complex.t -> Complex.t -> bool
val (<) : Complex.t -> Complex.t -> bool
val (=) : Complex.t -> Complex.t -> bool

Boilerplate code

val print : 'a BatInnerIO.output -> Complex.t -> unit
Printing