1: /* @(#)log.c 4.2 1/22/85 */
2:
3: /*
4: log returns the natural logarithm of its floating
5: point argument.
6:
7: The coefficients are #2705 from Hart & Cheney. (19.38D)
8:
9: It calls frexp.
10: */
11:
12: #include <errno.h>
13: #include <math.h>
14:
15: int errno;
16: double frexp();
17: static double log2 = 0.693147180559945309e0;
18: static double ln10 = 2.302585092994045684;
19: static double sqrto2 = 0.707106781186547524e0;
20: static double p0 = -.240139179559210510e2;
21: static double p1 = 0.309572928215376501e2;
22: static double p2 = -.963769093377840513e1;
23: static double p3 = 0.421087371217979714e0;
24: static double q0 = -.120069589779605255e2;
25: static double q1 = 0.194809660700889731e2;
26: static double q2 = -.891110902798312337e1;
27:
28: double
29: log(arg)
30: double arg;
31: {
32: double x,z, zsq, temp;
33: int exp;
34:
35: if(arg <= 0.) {
36: errno = EDOM;
37: return(-HUGE);
38: }
39: x = frexp(arg,&exp);
40: while(x<0.5) {
41: x = x*2;
42: exp = exp-1;
43: }
44: if(x<sqrto2) {
45: x = 2*x;
46: exp = exp-1;
47: }
48:
49: z = (x-1)/(x+1);
50: zsq = z*z;
51:
52: temp = ((p3*zsq + p2)*zsq + p1)*zsq + p0;
53: temp = temp/(((1.0*zsq + q2)*zsq + q1)*zsq + q0);
54: temp = temp*z + exp*log2;
55: return(temp);
56: }
57:
58: double
59: log10(arg)
60: double arg;
61: {
62:
63: return(log(arg)/ln10);
64: }
Defined functions
log
defined in line
28; used 80 times
- in line 63
- in /usr/include/math.h line
12
- in /usr/ingres/source/ovqp/interp.c line
31,
430
- in /usr/src/games/trek/schedule.c line
124,
145
- in /usr/src/games/trek/setup.c line
111
- in /usr/src/games/trek/trek.h line
33
- in /usr/src/games/warp/util.c line
72,
81-86(3)
- in /usr/src/include/math.h line
12
- in /usr/src/new/OLD/apl/src/ao.c line
90,
100,
127(2),
147,
155,
161,
469
- in /usr/src/new/OLD/apl/src/apl.h line
447
- in /usr/src/new/PORT/B/src/bsmall/B1fun.c line
203-206(3)
- in /usr/src/new/PORT/B/src/bsmall/B1num.c line
229
- in /usr/src/new/PORT/apl/src/ao.c line
90,
100,
127(2),
147,
155,
161,
469
- in /usr/src/new/PORT/apl/src/apl.h line
447
- in /usr/src/new/PORT/apl/src/gamma.c line
60-65(2),
72,
80,
88,
98
- in /usr/src/new/PORT/perl.1.0.0/arg.c line
1201,
1922
- in /usr/src/new/PORT/perl.1.0.0/perly.c line
1834,
2010
- in /usr/src/new/PORT/perl.1.0.10/arg.c line
1229,
1950
- in /usr/src/new/PORT/perl.1.0.10/perly.c line
1868,
2044
- in /usr/src/new/PORT/perl.1.0.16/arg.c line
1248,
1974
- in /usr/src/new/PORT/perl.1.0.16/perly.c line
1869,
2045
- in /usr/src/ucb/PORT/pascal/px/interp.c line
1658
- in /usr/src/ucb/PORT/systat/main.c line
119
- in /usr/src/ucb/pascal/px/00int.s line
8
- in /usr/src/ucb/pascal/px/34fun.s line
130
- in /usr/src/usr.lib/libF77/c_log.c line
14-17(2)
- in /usr/src/usr.lib/libF77/d_log.c line
12-13(2)
- in /usr/src/usr.lib/libF77/pow_zz.c line
15-17(2)
- in /usr/src/usr.lib/libF77/r_log.c line
12-13(2)
- in /usr/src/usr.lib/libF77/z_log.c line
14-17(2)
- in /usr/src/usr.lib/libom/gamma.c line
61-66(2),
73,
81,
89,
99
- in /usr/src/usr.lib/libom/j0.c line
153,
171
- in /usr/src/usr.lib/libom/j1.c line
158,
177
- in /usr/src/usr.lib/libom/pow.c line
10,
31-36(2)
log10
defined in line
58; used 8 times
Defined variables
errno
defined in line
15; used 1 times
ln10
defined in line
18; used 1 times
log2
defined in line
17; used 1 times
p0
defined in line
20; used 1 times
p1
defined in line
21; used 1 times
p2
defined in line
22; used 1 times
p3
defined in line
23; used 1 times
q0
defined in line
24; used 1 times
q1
defined in line
25; used 1 times
q2
defined in line
26; used 1 times