Module Math


module Math: sig  end
Type-generic math, constants, useful functions, etc.



Modules that allows functors that do generic math without needing a specific type



This describes the type of math.


type integer


type real
module type Ops = sig  end
This describes the type-generic operations that can be performed
module IntOps: sig  end
Specializations for all the built-in integer and real types
module Int32Ops: sig  end
module Int64Ops: sig  end
module NativeOps: sig  end
module FloatOps: sig  end


Useful functions


val succ_float : float -> float
Returns n+1.0
val pred_float : float -> float
Returns n-1.0
val fcmp : epsilon:float -> float -> float -> int
Like compare, but takes an extra epsilon value to use in figuring out if the floats are 'close enough' to be considered equal. See The Art of Computer Programming, 4.2.2. As an example, fcmp ~epsilon:0.00001 5.000005 5.000006 returns 0, meaning 5.000005 ~~ 5.000006.


Classification


val isfinite : float -> bool
Returns True if x is a finite value
val isinf : float -> bool
Returns True if x is infinite
val isnan : float -> bool
Returns True if x is nan
val isnormal : float -> bool
Returns True if x is a normal number
val iszero : float -> bool
Returns True if x is 0.0 or -0.0


C99 functions



If these functions aren't provided by a system's libc, they raise Failure.

val fma : float -> float -> float -> float
The C99 function fma()
val fdim : float -> float -> float
The C99 function fdim().
Returns The positive difference between its arguments.
val nextafter : float -> float -> float
The C99 function nextafter().
Returns The next representable value after x in the direction of y.
val remainder : float -> float -> float
The C99 function remainder()
Returns x REM y. See IEC 60559.
val trunc : float -> float
The C99 function trunc()
Returns The integer value nearest to but no larger in magnitude than x.
val round : float -> float
The C99 function round()
Returns X rounded to the nearest integer value, rounding halfway cases away from zero.
val nearbyint : float -> float
The C99 function nearbyint()
Returns x, rounded to the nearest integer value, using the current rounding direction.
val tgamma : float -> float
The C99 function tgamma()
Returns The gamma function of x.
val lgamma : float -> float
The C99 function lgamma()
Returns The natural logarithm of the absolute value of gamma of x.
val erfc : float -> float
The C99 function erfc()
Returns The complementry error function of x.
val erf : float -> float
The C99 function erf()
Returns The error function of x.
val hypot : float -> float -> float
The C99 function hypot()
Returns The square root of the sum of the squares of x and y.
val cbrt : float -> float
The C99 function cbrt()
Returns the cube root of its argument
val scalbn : float -> int -> float
The C99 function scalbn()
Returns x * (FLT_RADIX ^ n)
val logb : float -> float
The C99 function logb()
Returns the exponent of x, as a signed integer value in float format.
val log2 : float -> float
The C99 function log2()
Returns The log base 2 of its argument.
val log1p : float -> float
The C99 function log1p()
Returns The base-e logarithm of 1 plus x.
val ilogb : float -> int
The C99 function ilogb()
Returns The exponent of x.
val expm1 : float -> float
The C99 function expm1()
Returns The base-e exponential of x, minus 1.
val exp2 : float -> float
The C99 function exp2()
Returns The base-2 exponential of x.
val atanh : float -> float
The C99 function atanh()
Returns The hyperbolic arc cotangent of x.
val asinh : float -> float
The C99 function asinh()
Returns The hyperbolic arc sine of x.
val acosh : float -> float
The C99 function acosh()
Returns The hyperbolic arc cosine of x.


Useful constants


val e : float
Euler? ... Euler? ... Euler?
val log2e : float
Math.log2 Math.e
val log10e : float
log10 Math.e
val ln2 : float
log 2
val ln10 : float
log 10
val pi : float
Cherry
val pi2 : float
Math.pi /. 2.
val pi4 : float
Math.pi /. 4.
val invpi : float
1. /. Math.pi
val invpi2 : float
2. /./ Math.pi
val sqrtpi2 : float
2. *. sqrt Math.pi
val sqrt2 : float
sqrt 2.
val invsqrt2 : float
1. /. sqrt 2.