DRealFns: CEDAR DEFINITIONS = BEGIN Exp: PROC [x: DREAL] RETURNS [DREAL]; Ln: PROC [x: DREAL] RETURNS [DREAL]; Log: PROC [base, arg: DREAL] RETURNS [DREAL]; Power: PROC [base, exponent: DREAL] RETURNS [DREAL]; Root: PROC [index, arg: DREAL] RETURNS [DREAL]; SqRt: PROC [x: DREAL] RETURNS [DREAL]; Sin: PROC [radians: DREAL] RETURNS [DREAL]; SinDeg: PROC [degrees: DREAL] RETURNS [DREAL]; Cos: PROC [radians: DREAL] RETURNS [DREAL]; CosDeg: PROC [degrees: DREAL] RETURNS [DREAL]; Tan: PROC [radians: DREAL] RETURNS [DREAL]; TanDeg: PROC [degrees: DREAL] RETURNS [DREAL]; ArcTan: PROC [y, x: DREAL] RETURNS [radians: DREAL]; ArcTanDeg: PROC [y, x: DREAL] RETURNS [degrees: DREAL]; SinH: PROC [x: DREAL] RETURNS [DREAL]; CosH: PROC [x: DREAL] RETURNS [DREAL]; TanH: PROC [x: DREAL] RETURNS [DREAL]; CotH: PROC [x: DREAL] RETURNS [DREAL]; InvSinH: PROC [x: DREAL] RETURNS [DREAL]; InvCosH: PROC [x: DREAL] RETURNS [DREAL]; InvTanH: PROC [x: DREAL] RETURNS [DREAL]; InvCotH: PROC [x: DREAL] RETURNS [DREAL]; LnGamma: PROC [x: DREAL] RETURNS [DREAL]; Gamma: PROC [x: DREAL] RETURNS [DREAL]; J0: PROC [x: DREAL] RETURNS [DREAL]; J1: PROC [x: DREAL] RETURNS [DREAL]; Jn: PROC [n: INT, x: DREAL] RETURNS [DREAL]; Y0: PROC [x: DREAL] RETURNS [DREAL]; Y1: PROC [x: DREAL] RETURNS [DREAL]; Yn: PROC [n: INT, x: DREAL] RETURNS [DREAL]; Rational: TYPE ~ RECORD [numerator: INT, denominator: INT]; RationalFromDReal: PROC [x: DREAL, limit: INT ¬ INT.LAST] RETURNS [Rational]; AlmostZero: PROC [x: DREAL, distance: INTEGER] RETURNS [BOOL]; AlmostEqual: PROC [y, x: DREAL, distance: INTEGER] RETURNS [BOOL]; END. F DRealFns.mesa Copyright Σ 1989, 1991 by Xerox Corporation. All rights reserved. Russ Atkinson (RRA) June 22, 1989 9:40:11 pm PDT Exponent and logarithm functions For an input argument x, returns e^x (e=2.718...). Computes the natural logarithm (base e) of x. Computes logarithm to the base of arg. Calculates base to the exponent power by e(exponent*Ln(base)). Calculates the index root of arg by e(Ln(arg)/index). Calculates the square root of the input value by Newton's iteration. Trigonometric functions Hyperbolic circle functions Hyperbolic sine Hyperbolic cosine Hyperbolic tangent Hyperbolic cotangent ...defined for x >= 1.0, returns non-negative result ...defined for x IN (-1.0..1.0) ...defined for x NOT IN [-1.0..1.0] Gamma functions .. defined for x>0 .. defined for x>0; computed by Exp[LnGamma[x]] Gamma[x+1] = x! for integer x. Bessel functions Bessel function of first kind of order 0 Bessel function of first kind of order 1 Bessel function of first kind of order n Bessel function of second kind of order 0 Bessel function of second kind of order 1 Bessel function of second kind of order n Rational approximation ... computes the best rational approximation to a real using continued fractions. |numerator| <= limit, 0 < denominator <= limit. Approximate equality AlmostZero[x, distance] == ABS[x] < 2^distance AlmostEqual[y, x, distance] == NotNaN[x] AND NotNaN[y] AND ABS[x-y] <= MAX[ABS[x], ABS[y]] * 2^distance Notes: When either number is a Nan (not-a-number), then equality is never guaranteed, so FALSE is a conservative answer. Comparing anything against 0.0 can give surprising results using the above definition, since ABS[x-0] = MAX[ABS[x], ABS[0]], which implies that AlmostEqual[0, x, distance] is only true for distance = 0. Russ Atkinson (RRA) May 29, 1989 5:05:29 pm PDT Adapted from RealFns Κ«–(cedarcode) style•NewlineDelimiter ™codešœ ™ Kšœ Οeœ7™BK™0—IheadšΟnœΟkœŸ œŸ˜#™ š žœŸœŸœŸœŸœ˜%Kšœ2™2K™—š žœŸœŸœŸœŸœ˜$Kšœ-™-K™—š žœŸœ ŸœŸœŸœ˜-Kšœ&™&K™—š žœŸœŸœŸœŸœ˜4Kšœ>™>K™—š žœŸœŸœŸœŸœ˜/Kšœ5™5K™—š žœŸœŸœŸœŸœ˜&KšœD™DK™——™Kš žœŸœ ŸœŸœŸœ˜+š žœŸœ ŸœŸœŸœ˜.K˜—Kš žœŸœ ŸœŸœŸœ˜+š žœŸœ ŸœŸœŸœ˜.K˜—Kš žœŸœ ŸœŸœŸœ˜+š žœŸœ ŸœŸœŸœ˜.K™—Kš žœŸœŸœŸœ Ÿœ˜4Kš ž œŸœŸœŸœ Ÿœ˜7—šœ™š ΟbœŸœŸœŸœŸœ˜&Jšœ™K˜—š  œŸœŸœŸœŸœ˜&Jšœ™K˜—š  œŸœŸœŸœŸœ˜&Jšœ™K˜—š ΠbnœŸœŸœŸœŸœ˜&Jšœ™K˜—š žœŸœŸœŸœŸœ˜)K˜—š žœŸœŸœŸœŸœ˜)Jšœ4™4J™—š žœŸœŸœŸœŸœ˜)JšœŸœ ™J™—š žœŸœŸœŸœŸœ˜)JšœŸœŸœ ™#J™——šœ™š žœŸœŸœŸœŸœ˜)J™K˜—š ‘œŸœŸœŸœŸœ˜'Jšœ Οc™/J™J™——šœ™š žœŸœŸœŸœŸœ˜$Jšœ(™(J™—š žœŸœŸœŸœŸœ˜$Jšœ(™(J™—š žœŸœŸœŸœŸœŸœ˜,Jšœ(™(J™—š žœŸœŸœŸœŸœ˜$Jšœ)™)J™—š žœŸœŸœŸœŸœ˜$Jšœ)™)J™—š žœŸœŸœŸœŸœŸœ˜,Jšœ)™)J™——K˜™š œ ŸœŸœ ŸœŸœ˜;K˜—šžœŸœŸœ ŸœŸœŸœŸœ ˜MJšœQ™QJšœ0™0J™——™š ž œŸœŸœ ŸœŸœŸœ˜>šœ™Kšœ™—K™—š ž œŸœŸœ ŸœŸœŸœ˜Bšœ™šœ Ÿœ Ÿ™KšŸœ ŸœŸœŸœ™,——™KšœRŸœ™qKš œ]ŸœŸœŸœŸœS™Κ—K™K™——šŸœ˜K˜—™/K™—K™—…—H9