(FILECREATED "24-JAN-84 11:03:16" {SDCRDCF}</EA/DARREL/DARRELJ>TRANSCEND.;1 7359 changes to: (VARS TRANSCENDCOMS) (FNS ANTILOG ARCSIN ARCTAN LOG SIN SQRT TAN TANSERIES)) (PRETTYCOMPRINT TRANSCENDCOMS) (RPAQQ TRANSCENDCOMS ((FNS ANTILOG ARCSIN ARCTAN LOG SIN SQRT TAN TANSERIES))) (DEFINEQ (ANTILOG [LAMBDA (X) (* DJVB "19-JAN-84 15:56") (PROG ((EXP (FIX X / .6931472)) (FRAC (ABS (FREMAINDER X .6931472))) (SSUM -.0001413161)) (* POLYNOMIAL FROM HANDBOOK OF MATHEMATICAL FUNCTIONS (EDITED BY ARAMOWITZ) PAGE 71 ACCURACY 32 BITS OF THE 24 AVAILABLE!) (for COEF in '(.001329882 -.00830136 .04165735 -.1666653 .4999999 -1.0 1.0) do SSUM ← (FPLUS (FTIMES SSUM FRAC) COEF)) (if (FGREATERP X 0) then SSUM ← 1.0 / SSUM) (* DEPENDS ON USE OF IEEE-488 FORMAT TO SMASH THE EXPONENT. COMING IN, SSUM IS IN THE RANGE .5 TO 2 (AND SERIES PRODUCED .5 TO 1)) (\PUTBASE SSUM 0 128 * EXP + (\GETBASE SSUM 0)) (RETURN SSUM]) (ARCSIN [LAMBDA (X RADIANSFLG) (* DJVB "23-JAN-84 10:25") (PROG ((SIGN (if (FLESSP X 0) then -1.0 else 1.0)) (SSUM -.001262491) (PI/2 1.570796) (180/PI 57.29578)) (* POLYNOMIAL FROM HANDBOOK OF MATHEMATICAL FUNCTIONS (EDITED BY ARAMOWITZ) PAGE 81 ACCURACY 28 BITS) (if (FLESSP X -1.0) or (FGREATERP X 1.0) then (ERROR "ARCSIN: arg not in range" X)) (X ← (FLOAT (ABS X))) (for COEF in '(.00667009 -.01708813 .03089188 -.0501743 .088979 -.2145988 1.570796) do SSUM ← (FPLUS (FTIMES SSUM X) COEF)) [SSUM ← (FTIMES SIGN (FDIFFERENCE PI/2 (FTIMES (SQRT 1.0 - X) SSUM] (RETURN (if RADIANSFLG then SSUM else (FTIMES SSUM 180/PI]) (ARCTAN [LAMBDA (X RADIANSFLG) (* DJVB "20-JAN-84 16:59") (PROG (FLIPPED X2 (SSUM .002866226) (180/PI 57.29578) (PI/2 1.570796) (-PI/2 -1.570796)) (* POLYNOMIAL FROM HANDBOOK OF MATHEMATICAL FUNCTIONS (EDITED BY ARAMOWITZ) PAGE 81 ACCURACY 28 BITS) (if (FLESSP X -1.0) or (FGREATERP X 1.0) then FLIPPED ← (if (FLESSP X 0.0) then FLIPPED ← -PI/2 else FLIPPED ← PI/2) X ← 1.0 / X) (X2 ← (FTIMES X X)) (for COEF in '(-.01616574 .04290961 -.07528964 .1065626 -.142089 .1999355 -.3333315 1.0) do SSUM ← (FPLUS (FTIMES SSUM X2) COEF)) (SSUM ← (FTIMES SSUM X)) (SSUM ← (if FLIPPED then (FDIFFERENCE FLIPPED SSUM) else SSUM)) (RETURN (if RADIANSFLG then SSUM else (FTIMES SSUM 180/PI]) (LOG [LAMBDA (X) (* DJVB "23-JAN-84 10:26") (SELECTQ (SYSTEMTYPE) [D (PROG ((SX (X + 0.0)) EXP (SSUM -.006453544) (LN2 .6931472) (2↑-126 1.175494E-38)) (if ~ (FGREATERP X 0.0) then (ERROR "LOG OF NON-POSITIVE NUMBER:" X)) (* DEPENDS ON INTERLISP D%'S USE OF IEEE 32 BIT FLOAT FORMAT INTERNALLY AND SMASHES THE NUMBER TO THE RANGE 1 TO 2 AND SAVES THE EXPONENT) (EXP ← (while (FLESSP SX 2↑-126) count SX ← SX * 2.0)) (EXP ← (LRSH (LOGAND (\GETBASE SX 0) 32640) 7) - 127 - EXP) (\PUTBASE SX 0 16256 + (LOGAND (\GETBASE SX 0) 127)) (SX ← SX - 1.0) (* POLYNOMIAL FROM HANDBOOK OF MATHEMATICAL FUNCTIONS (EDITED BY ARAMOWITZ) PAGE 69 ACCURACY 28 BITS) (for COEF in '(.03608849 -.0953294 .1676541 -.2407338 .331799 -.4998741 .9999964 0.0) do SSUM ← (FPLUS (FTIMES SSUM SX) COEF)) (RETURN (FPLUS SSUM (FTIMES LN2 EXP] (HELP "MACHINE DEPENDENT LOG ON WRONG MACHINE"]) (SIN [LAMBDA (X RADIANSFLG) (* DJVB "23-JAN-84 10:27") (PROG (X2 (2PI 6.283185) (PI/180 .01745329) (-PI/2 -1.570796) (3PI/2 4.712389) (PI/2 1.570796) (PI 3.141593) (SUMMATION -2.39E-8)) (* POLYNOMIAL APPROXIMATION FROM HANDBOOK OF MATHEMATICAL FUNCTIONS (EDITED BY ABRAMOWITZ) PAGE 76 ACCURATE TO 26 BITS (OF 24 AVAILABLE IN DOLPHIN)) (if RADIANSFLG then X ← (FREMAINDER X 2PI) else X ← (FTIMES (FREMAINDER X 360.0) PI/180)) (if (FLESSP X -PI/2) then X ← (FPLUS X 2PI)) (if (FGREATERP X 3PI/2) then X ← (FDIFFERENCE X 2PI) elseif (FGREATERP X PI/2) then X ← (FDIFFERENCE PI X)) (X2 ← (FTIMES X X)) (for COEF in '(2.7526E-6 -.000198409 .008333332 -.1666667 1.0) do SUMMATION ← (FPLUS (FTIMES SUMMATION X2) COEF)) (RETURN (FTIMES SUMMATION X]) (SQRT [LAMBDA (X) (* DJVB "23-JAN-84 10:29") (SELECTQ (SYSTEMTYPE) (D (PROG ((P .75)) (DECLARE: LOCALVARS P) (if (FLESSP X 0.0) then (ERROR "SQRT of negative value" X) elseif (FEQP X 0.0) then (RETURN X)) (X ← (FLOAT X)) (* FOLLOWING depends on Interlisp D%'s use of IEEE 32-bit float format. Initial guess is 1 * 2↑half-of-exponent or 1.5 * for odd exponent. Worst case convergence is 4 steps!) (\PUTBASE P 0 (LOGAND (\GETBASE X 0) 32767)/ 2 + 8128) (for I from (if (FLESSP X 1.175494E-38) then 12 else 4) to 1 by -1 do P ← (FQUOTIENT (FPLUS P (FQUOTIENT X P)) 2)) (RETURN P))) (HELP "Machine specific sqrt on wrong machine"]) (TAN [LAMBDA (X RADIANSFLG) (* DJVB "17-JAN-84 16:44") (PROG ((PI 3.141593) (PI/2 1.570796) (-PI/2 -1.570796) (PI/4 .7853982) (-PI/4 -.7853982) (PI/180 .01745329)) (if RADIANSFLG then X ← (FREMAINDER X PI) else X ← (FTIMES (FREMAINDER X 180) PI/180)) (if (FGREATERP X PI/2) then X ← (FDIFFERENCE X PI) elseif (FLESSP X -PI/2) then X ← (FPLUS X PI)) (RETURN (if (FGREATERP X PI/4) then 1.0 / (TANSERIES (FDIFFERENCE PI/2 X)) elseif (FLESSP X -PI/4) then 1.0 / (TANSERIES (FDIFFERENCE -PI/2 X)) else (TANSERIES X]) (TANSERIES [LAMBDA (X) (* DJVB "23-JAN-84 10:29") (PROG ((SSUM .00951681) (X2 (FTIMES X X))) (* POLYNOMIAL APPROXIMATION FROM HANDBOOK OF MATHEMATICAL FUNCTIONS (EDITED BY ABRAMOWITZ) PAGE 76 GOOD TO ALMOST 26 BITS) (for COEF in '(.002900525 .02456509 .05337406 .1333924 .3333314 1.0) do SSUM ← (FPLUS (FTIMES SSUM X2) COEF)) (RETURN (FTIMES X SSUM]) ) (DECLARE: DONTCOPY (FILEMAP (NIL (307 7337 (ANTILOG 317 . 1152) (ARCSIN 1154 . 2039) (ARCTAN 2041 . 3009) (LOG 3011 . 4177) (SIN 4179 . 5219) (SQRT 5221 . 6096) (TAN 6098 . 6825) ( TANSERIES 6827 . 7335))))) STOP