HELP REAL R. J. Duncan, September 1989 Functions on real numbers. CONTENTS - (Use g to access required sections) -- The Real Module -- Basic Functions -- Trigonometric Functions -- Real Constants -- The Real Module ---------------------------------------------------- signature Real structure Real : Real The structure -Real- is a built-in structure of PML which defines a collection of useful functions on real numbers. It has the following signature: signature Real = sig (* Basic Functions *) exception Log10 exception Power val round : real -> int val intof : real -> int val fracof : real -> real val sign : real -> real val max : real -> real -> real val min : real -> real -> real val log10 : real -> real val power : real -> real -> real val ** : real * real -> real (* Trigonometric Functions *) exception ArcSin exception ArcCos exception ArcCosh exception ArcTanh val tan : real -> real val arcsin : real -> real val arccos : real -> real val sinh : real -> real val cosh : real -> real val tanh : real -> real val arcsinh : real -> real val arccosh : real -> real val arctanh : real -> real val arctan2 : real -> real -> real (* Real Constants *) val pi : real val most_positive : real val least_positive : real val most_negative : real val least_negative : real val add_epsilon : real val sub_epsilon : real end For the definition of the type -real- see HELP * STDTYPES. For the basic mathematical operators (+, -, etc.) see HELP * STDVALUES. For a similar set of functions on integers see HELP * INT. -- Basic Functions ---------------------------------------------------- val round (r : real) : int Rounds the real number -r- to an integer. val intof (r : real) : int Truncates the real number -r- to an integer. val fracof (r : real) : real Returns the fractional part of the real number -r-. val sign (r : real) : real Returns the sign of the real number -r-, i.e., one of the real numbers ~1.0, 0.0, or 1.0 according to whether -r- is less than, equal to or greater than zero. val max (r1 : real) (r2 : real) : real Returns the greater of the real numbers -r1- and -r2-. val min (r1 : real) (r2 : real) : real Returns the lesser of the real numbers -r1- and -r2-. exception Log10 val log10 (r : real) : real Returns the base 10 logarithm of the real number -r-. Raises the exception -Log10- if -r- is non-positive. exception Power infix 8 ** val power (r : real) (m : real) : real val (r : real) ** (m : real) : real Returns the value of -r- raised to the power -m-. Raises the exception -Power- if -r- is negative, or if -r- is zero and -m- is non-positive; otherwise the result is computed as exp(m * ln r) The exception -Overflow- is raised if the result is out of range. -- Trigonometric Functions -------------------------------------------- For SIN, COS and ARCTAN functions see HELP * STDVALUES. All angles are measured in radians. val tan (r : real) : real Returns the tangent of the real angle -r-. exception ArcSin exception ArcCos val arcsin (r : real) : real val arccos (r : real) : real Return the arcsine and arccosine of the real number -r-. The exception -ArcSin- or -ArcCos- is raised as appropriate whenever abs(r) > 1.0. val sinh (r : real) : real val cosh (r : real) : real val tanh (r : real) : real Return the hyperbolic sine, cosine and tangent of the real angle -r-. exception ArcCosh exception ArcTanh val arcsinh (r : real) : real val arccosh (r : real) : real val arctanh (r : real) : real Return the hyperbolic arcsine, arccosine and arctangent of the real number -r-. The function -arccosh- raises the exception -ArcCosh- when r < 1.0; the function -arctanh- raises the exception -ArcTanh- when abs(r) > 1.0 and the exception -Overflow- when abs(r) = 1.0. val arctan2 (r1 : real) (r2 : real) : real Returns the arctangent of r1 / r2, using the signs of the two numbers to derive quadrant information. When both -r1- and -r2- are zero, the result is defined (arbitrarily) to be zero also. -- Real Constants ----------------------------------------------------- Note: the values of these constants will vary between different implementations of PML, depending on the floating-point representation of the host machine. val pi : real The best real approximation to pi. val most_positive : real The greatest positive value representable as a real number. val least_positive : real The smallest positive (non-zero) value representable as a real number. val most_negative : real The most negative (i.e. closest to negative infinity) value representable as a real number. val least_negative : real The least negative (i.e. closest to zero) value representable as a real number. val add_epsilon : real The smallest positive real number with the property: 1.0 + add_epsilon <> 1.0 val sub_epsilon : real The smallest positive real number with the property: 1.0 - sub_epsilon <> 1.0 --- C.all/pml/help/real --- Copyright University of Sussex 1991. All rights reserved. ----------