|
|
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 the above copyright notice and this paragraph are
7: * duplicated in all such forms and that any documentation,
8: * advertising materials, and other materials related to such
9: * distribution and use acknowledge that the software was developed
10: * by the University of California, Berkeley. The name of the
11: * University may not be used to endorse or promote products derived
12: * from this software without specific prior written permission.
13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16: *
17: * All recipients should regard themselves as participants in an ongoing
18: * research project and hence should feel obligated to report their
19: * experiences (good or bad) with these elementary function codes, using
20: * the sendbug(8) program, to the authors.
21: */
22:
23: #ifndef lint
24: static char sccsid[] = "@(#)atan.c 5.3 (Berkeley) 6/30/88";
25: #endif /* not lint */
26:
27: /* ATAN(X)
28: * RETURNS ARC TANGENT OF X
29: * DOUBLE PRECISION (IEEE DOUBLE 53 bits, VAX D FORMAT 56 bits)
30: * CODED IN C BY K.C. NG, 4/16/85, REVISED ON 6/10/85.
31: *
32: * Required kernel function:
33: * atan2(y,x)
34: *
35: * Method:
36: * atan(x) = atan2(x,1.0).
37: *
38: * Special case:
39: * if x is NaN, return x itself.
40: *
41: * Accuracy:
42: * 1) If atan2() uses machine PI, then
43: *
44: * atan(x) returns (PI/pi) * (the exact arc tangent of x) nearly rounded;
45: * and PI is the exact pi rounded to machine precision (see atan2 for
46: * details):
47: *
48: * in decimal:
49: * pi = 3.141592653589793 23846264338327 .....
50: * 53 bits PI = 3.141592653589793 115997963 ..... ,
51: * 56 bits PI = 3.141592653589793 227020265 ..... ,
52: *
53: * in hexadecimal:
54: * pi = 3.243F6A8885A308D313198A2E....
55: * 53 bits PI = 3.243F6A8885A30 = 2 * 1.921FB54442D18 error=.276ulps
56: * 56 bits PI = 3.243F6A8885A308 = 4 * .C90FDAA22168C2 error=.206ulps
57: *
58: * In a test run with more than 200,000 random arguments on a VAX, the
59: * maximum observed error in ulps (units in the last place) was
60: * 0.86 ulps. (comparing against (PI/pi)*(exact atan(x))).
61: *
62: * 2) If atan2() uses true pi, then
63: *
64: * atan(x) returns the exact atan(x) with error below about 2 ulps.
65: *
66: * In a test run with more than 1,024,000 random arguments on a VAX, the
67: * maximum observed error in ulps (units in the last place) was
68: * 0.85 ulps.
69: */
70:
71: double atan(x)
72: double x;
73: {
74: double atan2(),one=1.0;
75: return(atan2(x,one));
76: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.