.TH "Complex" 3o source: 2019-01-25 OCamldoc "OCaml library" .SH NAME Complex \- Complex numbers. .SH Module Module Complex .SH Documentation .sp Module .BI "Complex" : .B sig end .sp Complex numbers\&. .sp 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 .B float )\&. .sp .sp .sp .I type t = { re : .B float ; im : .B float ; } .sp The type of complex numbers\&. .B re is the real part and .B im the imaginary part\&. .sp .I val zero : .B t .sp The complex number .B 0 \&. .sp .I val one : .B t .sp The complex number .B 1 \&. .sp .I val i : .B t .sp The complex number .B i \&. .sp .I val neg : .B t -> t .sp Unary negation\&. .sp .I val conj : .B t -> t .sp Conjugate: given the complex .B x + i\&.y , returns .B x \- i\&.y \&. .sp .I val add : .B t -> t -> t .sp Addition .sp .I val sub : .B t -> t -> t .sp Subtraction .sp .I val mul : .B t -> t -> t .sp Multiplication .sp .I val inv : .B t -> t .sp Multiplicative inverse ( .B 1/z )\&. .sp .I val div : .B t -> t -> t .sp Division .sp .I val sqrt : .B t -> t .sp Square root\&. The result .B x + i\&.y is such that .B x > 0 or .B x = 0 and .B y >= 0 \&. This function has a discontinuity along the negative real axis\&. .sp .I val norm2 : .B t -> float .sp Norm squared: given .B x + i\&.y , returns .B x^2 + y^2 \&. .sp .I val norm : .B t -> float .sp Norm: given .B x + i\&.y , returns .B sqrt(x^2 + y^2) \&. .sp .I val arg : .B t -> float .sp 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 .B \-pi to .B pi \&. This function has a discontinuity along the negative real axis\&. .sp .I val polar : .B float -> float -> t .sp .B polar norm arg returns the complex having norm .B norm and argument .B arg \&. .sp .I val exp : .B t -> t .sp Exponentiation\&. .B exp z returns .B e to the .B z power\&. .sp .I val log : .B t -> t .sp Natural logarithm (in base .B e )\&. .sp .I val pow : .B t -> t -> t .sp Power function\&. .B pow z1 z2 returns .B z1 to the .B z2 power\&. .sp