Mathematical floating-point values and operations.
The signature MATH specifies basic mathematical constants, the square root function, and trigonometric, hyperbolic, exponential, and logarithmic functions based on a real type. The functions defined here have roughly the same semantics as their counterparts in ISO C's math.h. The top-level structure Math provides these functions for the default real type Real.real. In the functions below, unless specified otherwise, if any argument is a NaN, the return value is a NaN. In a list of rules specifying the behavior of a function in special cases, the first matching rule defines the semantics.structure Math : MATH
signature MATH =
sig
type real
val pi : real
val e : real
val sqrt : real -> real
val sin : real -> real
val cos : real -> real
val tan : real -> real
val asin : real -> real
val acos : real -> real
val atan : real -> real
val atan2 : real * real -> real
val exp : real -> real
val pow : real * real -> real
val ln : real -> real
val log10 : real -> real
val sinh : real -> real
val cosh : real -> real
val tanh : real -> real
end
sign ( cos ( atan2 (y,x))) = sign(x)
and
sign ( sin ( atan2 (y,x))) = sign(y)
except for inaccuracies incurred by the finite precision of real and
the approximation algorithms used to compute the mathematical
functions. Rules for exceptional cases are specified in the following
table:
y x atan2(y,x)
+-0 0 < x +-0
+-0 +0 +-0
+-0 x < 0 +-pi
+-0 -0 +-pi
y, 0 < y +-0 pi/2
y, y < 0 +-0 -pi/2
+-y, finite y > 0 +infinity +-0
+-y, finite y > 0 -infinity +-pi
+-infinity finite x +-pi/2
+-infinity +infinity +-pi/4
x y pow(x,y)
x, including NaN 0 1
|x| > 1 +infinity +infinity
|x| < 1 +infinity +0
|x| > 1 -infinity +0
|x| < 1 -infinity +infinity
+infinity y > 0 +infinity
+infinity y < 0 +0
-infinity y > 0, odd integer -infinity
-infinity y > 0, not odd integer +infinity
-infinity y < 0, odd integer -0
-infinity y < 0, not odd integer +0
x NaN NaN
NaN y <> 0 NaN
+-1 +-infinity NaN
finite x < 0 finite non-integer y NaN
+-0 y < 0, odd integer +-infinity
+-0 finite y < 0, not odd integer +infinity
+-0 y > 0, odd integer +-0
sinh +-0 = +-0
sinh +-infinity = +-infinity
cosh +-0 = 1
cosh +-infinity = +-infinity
tanh +-0 = +-0