xref: /csrg-svn/lib/libm/common_source/atan.c (revision 34124)
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 this notice is preserved and that due credit is given
7  * to the University of California at Berkeley. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  *
12  * All recipients should regard themselves as participants in an ongoing
13  * research project and hence should feel obligated to report their
14  * experiences (good or bad) with these elementary function codes, using
15  * the sendbug(8) program, to the authors.
16  */
17 
18 #ifndef lint
19 static char sccsid[] = "@(#)atan.c	5.2 (Berkeley) 04/29/88";
20 #endif /* not lint */
21 
22 /* ATAN(X)
23  * RETURNS ARC TANGENT OF X
24  * DOUBLE PRECISION (IEEE DOUBLE 53 bits, VAX D FORMAT 56 bits)
25  * CODED IN C BY K.C. NG, 4/16/85, REVISED ON 6/10/85.
26  *
27  * Required kernel function:
28  *	atan2(y,x)
29  *
30  * Method:
31  *	atan(x) = atan2(x,1.0).
32  *
33  * Special case:
34  *	if x is NaN, return x itself.
35  *
36  * Accuracy:
37  * 1)  If atan2() uses machine PI, then
38  *
39  *	atan(x) returns (PI/pi) * (the exact arc tangent of x) nearly rounded;
40  *	and PI is the exact pi rounded to machine precision (see atan2 for
41  *      details):
42  *
43  *	in decimal:
44  *		pi = 3.141592653589793 23846264338327 .....
45  *    53 bits   PI = 3.141592653589793 115997963 ..... ,
46  *    56 bits   PI = 3.141592653589793 227020265 ..... ,
47  *
48  *	in hexadecimal:
49  *		pi = 3.243F6A8885A308D313198A2E....
50  *    53 bits   PI = 3.243F6A8885A30  =  2 * 1.921FB54442D18	error=.276ulps
51  *    56 bits   PI = 3.243F6A8885A308 =  4 * .C90FDAA22168C2    error=.206ulps
52  *
53  *	In a test run with more than 200,000 random arguments on a VAX, the
54  *	maximum observed error in ulps (units in the last place) was
55  *	0.86 ulps.      (comparing against (PI/pi)*(exact atan(x))).
56  *
57  * 2)  If atan2() uses true pi, then
58  *
59  *	atan(x) returns the exact atan(x) with error below about 2 ulps.
60  *
61  *	In a test run with more than 1,024,000 random arguments on a VAX, the
62  *	maximum observed error in ulps (units in the last place) was
63  *	0.85 ulps.
64  */
65 
66 double atan(x)
67 double x;
68 {
69 	double atan2(),one=1.0;
70 	return(atan2(x,one));
71 }
72