class Math is ============================================================================== == Author: Michael Cahill == Version: 1.0 == Date: 15 April 1997 == Short: Standard library class containing mathematical functions == == This class contains routines to carry out the standard mathematics == functions, including constants, trigonometric functions, logarithms == and exponentials. All angles are in radians. == ============================================================================== uses interface creation is == Create a new math object do -- No creation necessary end creation routines pi -> (_pi: Real) is builtin == returns ratio of circumference to diameter of a circle end pi e -> (_e: Real) is builtin == returns the base of natural (Napier) logarithms end e sin(theta : Real) -> (result : Real) is builtin == returns the sine of theta pre theta <> nil end sin cos(theta : Real) -> (result : Real) is builtin == returns the cosine of theta pre theta <> nil end cos tan(theta : Real) -> (result : Real) is builtin == returns the tangent of theta pre theta <> nil end tan arcsin(x : Real) -> (result : Real) is builtin == returns the angle whose sine is x pre x <> nil and x >= -1.0 and x <= 1.0 end arcsin arccos(x : Real) -> (result : Real) is builtin == returns the angle whose cosine is x pre x <> nil and x >= -1.0 and x <= 1.0 end arccos arctan(x : Real) -> (result : Real) is builtin == returns the angle whose tangent is x pre x <> nil end arctan sinh(theta : Real) -> (result : Real) is builtin == returns the hyperbolic sine of theta pre theta <> nil end sinh cosh(theta : Real) -> (result : Real) is builtin == returns the hyperbolic cosine of theta pre theta <> nil end cosh tanh(theta : Real) -> (result : Real) is builtin == returns the hyperbolic tangent of theta pre theta <> nil end tanh arcsinh(x : Real) -> (result : Real) is builtin == returns the angle whose hyperbolic sine is x pre x <> nil end arcsinh arccosh(x : Real) -> (result : Real) is builtin == returns the angle whose hyperbolic cosine is x pre x <> nil and x >= 1.0 end arccosh arctanh(x : Real) -> (result : Real) is builtin == returns the angle whose hyperbolic tangent is x pre x <> nil and x < -1.0 or x > 1.0 end arctanh arctan2(y : Real, x : Real) -> (result : Real) is builtin == returns the angle whose tangent is the gradient of == the line joining (0, 0) to (x, y) pre x <> nil and y <> nil end arctan2 log(x : Real) -> (result : Real) is builtin == returns the natural logarithm of x pre x <> nil and x > 0 end log exp(x : Real) -> (result : Real) is builtin == returns the exponential of x (i.e. e ^ x) end exp log10(x : Real) -> (result : Real) is builtin == returns log to the base 10 of x pre x <> nil and x > 0 end log10 end class