RealFns.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Stewart, August 27, 1982 11:21 am
Russ Atkinson (RRA) February 19, 1985 4:11:34 pm PST
Doug Wyatt, February 27, 1985 8:41:51 am PST
RealFns: CEDAR DEFINITIONS
= BEGIN
Exp:
PROC [
REAL]
RETURNS [
REAL];
For an input argument n, returns e^n (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 functions 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:
PROC [x:
REAL, distance: [-126..127]]
RETURNS [
BOOL];
AlmostZero returns TRUE if ABS[x] is smaller than 2^distance.
AlmostEqual:
PROC [y, x:
REAL, distance: [-126..0]]
RETURNS [
BOOL];
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.
END.