-- DragonRealFns.mesa -- Last Update by Stewart, August 27, 1982 11:21 am RealFns: CEDAR DEFINITIONS = BEGIN Exp: PROC [REAL] RETURNS [REAL]; -- For an input argument n, returns en (e=2.718...). -- Computed by continued fractions. Log: PROC [base, arg: REAL] RETURNS [REAL]; -- Computes logarithm to the base base of arg. -- Computed by Ln(arg)/Ln(base). Ln: PROC [REAL] RETURNS [REAL]; -- Computes the natural logarithm (base e) of the input argument. SqRt: PROC [REAL] RETURNS [REAL]; -- Calculates the square root of the input value by Newton's iteration. Root: PROC [index, arg: REAL] RETURNS [REAL]; -- Calculates the index root of arg by e(Ln(arg)/index). Power: PROC [base, exponent: REAL] RETURNS [REAL]; -- Calculates base to the exponent power by e(exponent*Ln(base)). Sin: PROC [radians: REAL] RETURNS [sin: REAL]; SinDeg: PROC [degrees: REAL] RETURNS [sin: REAL]; Cos: PROC [radians: REAL] RETURNS [cos: REAL]; CosDeg: PROC [degrees: REAL] RETURNS [cos: REAL]; Tan: PROC [radians: REAL] RETURNS [tan: REAL]; TanDeg: PROC [degrees: REAL] RETURNS [tan: REAL]; -- Computes the trigonometric function by polynomial; -- good to 7.33 decimal places. ArcTan: PROC [y, x: REAL] RETURNS [radians: REAL]; ArcTanDeg: PROC [y, x: REAL] RETURNS [degrees: REAL]; -- Good to 8.7 decimal places. -- AlmostZero returns TRUE if ABS[x] is smaller than 2↑distance. AlmostZero: PROC [x: REAL, distance: [-126..127]] RETURNS [BOOLEAN]; -- AlmostEqual returns TRUE if ABS[x-y]/MAX[ABS[x],ABS[y]] -- is smaller than 2↑distance. That is, the exponent of the result -- of the subtract must be ABS[distance] smaller than the larger -- exponent of the operands. AlmostEqual: PROC [y, x: REAL, distance: [-126..0]] RETURNS [BOOLEAN]; -- In both these procedures, distance should be negative! END.