|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1985 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted ! 6: * provided that: (1) source distributions retain this entire copyright ! 7: * notice and comment, and (2) distributions including binaries display ! 8: * the following acknowledgement: ``This product includes software ! 9: * developed by the University of California, Berkeley and its contributors'' ! 10: * in the documentation or other materials provided with the distribution ! 11: * and in all advertising materials mentioning features or use of this ! 12: * software. Neither the name of the University nor the names of its ! 13: * contributors may be used to endorse or promote products derived ! 14: * from this software without specific prior written permission. ! 15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 18: * ! 19: * All recipients should regard themselves as participants in an ongoing ! 20: * research project and hence should feel obligated to report their ! 21: * experiences (good or bad) with these elementary function codes, using ! 22: * the sendbug(8) program, to the authors. ! 23: */ ! 24: ! 25: #ifndef lint ! 26: static char sccsid[] = "@(#)log__L.c 5.5 (Berkeley) 6/1/90"; ! 27: #endif /* not lint */ ! 28: ! 29: /* log__L(Z) ! 30: * LOG(1+X) - 2S X ! 31: * RETURN --------------- WHERE Z = S*S, S = ------- , 0 <= Z <= .0294... ! 32: * S 2 + X ! 33: * ! 34: * DOUBLE PRECISION (VAX D FORMAT 56 bits or IEEE DOUBLE 53 BITS) ! 35: * KERNEL FUNCTION FOR LOG; TO BE USED IN LOG1P, LOG, AND POW FUNCTIONS ! 36: * CODED IN C BY K.C. NG, 1/19/85; ! 37: * REVISED BY K.C. Ng, 2/3/85, 4/16/85. ! 38: * ! 39: * Method : ! 40: * 1. Polynomial approximation: let s = x/(2+x). ! 41: * Based on log(1+x) = log(1+s) - log(1-s) ! 42: * = 2s + 2/3 s**3 + 2/5 s**5 + ....., ! 43: * ! 44: * (log(1+x) - 2s)/s is computed by ! 45: * ! 46: * z*(L1 + z*(L2 + z*(... (L7 + z*L8)...))) ! 47: * ! 48: * where z=s*s. (See the listing below for Lk's values.) The ! 49: * coefficients are obtained by a special Remez algorithm. ! 50: * ! 51: * Accuracy: ! 52: * Assuming no rounding error, the maximum magnitude of the approximation ! 53: * error (absolute) is 2**(-58.49) for IEEE double, and 2**(-63.63) ! 54: * for VAX D format. ! 55: * ! 56: * Constants: ! 57: * The hexadecimal values are the intended ones for the following constants. ! 58: * The decimal values may be used, provided that the compiler will convert ! 59: * from decimal to binary accurately enough to produce the hexadecimal values ! 60: * shown. ! 61: */ ! 62: ! 63: #include "mathimpl.h" ! 64: ! 65: vc(L1, 6.6666666666666703212E-1 ,aaaa,402a,aac5,aaaa, 0, .AAAAAAAAAAAAC5) ! 66: vc(L2, 3.9999999999970461961E-1 ,cccc,3fcc,2684,cccc, -1, .CCCCCCCCCC2684) ! 67: vc(L3, 2.8571428579395698188E-1 ,4924,3f92,5782,92f8, -1, .92492492F85782) ! 68: vc(L4, 2.2222221233634724402E-1 ,8e38,3f63,af2c,39b7, -2, .E38E3839B7AF2C) ! 69: vc(L5, 1.8181879517064680057E-1 ,2eb4,3f3a,655e,cc39, -2, .BA2EB4CC39655E) ! 70: vc(L6, 1.5382888777946145467E-1 ,8551,3f1d,781d,e8c5, -2, .9D8551E8C5781D) ! 71: vc(L7, 1.3338356561139403517E-1 ,95b3,3f08,cd92,907f, -2, .8895B3907FCD92) ! 72: vc(L8, 1.2500000000000000000E-1 ,0000,3f00,0000,0000, -2, .80000000000000) ! 73: ! 74: ic(L1, 6.6666666666667340202E-1, -1, 1.5555555555592) ! 75: ic(L2, 3.9999999999416702146E-1, -2, 1.999999997FF24) ! 76: ic(L3, 2.8571428742008753154E-1, -2, 1.24924941E07B4) ! 77: ic(L4, 2.2222198607186277597E-1, -3, 1.C71C52150BEA6) ! 78: ic(L5, 1.8183562745289935658E-1, -3, 1.74663CC94342F) ! 79: ic(L6, 1.5314087275331442206E-1, -3, 1.39A1EC014045B) ! 80: ic(L7, 1.4795612545334174692E-1, -3, 1.2F039F0085122) ! 81: ! 82: #ifdef vccast ! 83: #define L1 vccast(L1) ! 84: #define L2 vccast(L2) ! 85: #define L3 vccast(L3) ! 86: #define L4 vccast(L4) ! 87: #define L5 vccast(L5) ! 88: #define L6 vccast(L6) ! 89: #define L7 vccast(L7) ! 90: #define L8 vccast(L8) ! 91: #endif ! 92: ! 93: double log__L(z) ! 94: double z; ! 95: { ! 96: #if defined(vax)||defined(tahoe) ! 97: return(z*(L1+z*(L2+z*(L3+z*(L4+z*(L5+z*(L6+z*(L7+z*L8)))))))); ! 98: #else /* defined(vax)||defined(tahoe) */ ! 99: return(z*(L1+z*(L2+z*(L3+z*(L4+z*(L5+z*(L6+z*L7))))))); ! 100: #endif /* defined(vax)||defined(tahoe) */ ! 101: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.