xref: /csrg-svn/lib/libm/common_source/atan.c (revision 24706)
1 /*
2  * Copyright (c) 1985 Regents of the University of California.
3  *
4  * Use and reproduction of this software are granted  in  accordance  with
5  * the terms and conditions specified in  the  Berkeley  Software  License
6  * Agreement (in particular, this entails acknowledgement of the programs'
7  * source, and inclusion of this notice) with the additional understanding
8  * that  all  recipients  should regard themselves as participants  in  an
9  * ongoing  research  project and hence should  feel  obligated  to report
10  * their  experiences (good or bad) with these elementary function  codes,
11  * using "sendbug 4bsd-bugs@BERKELEY", to the authors.
12  */
13 
14 #ifndef lint
15 static char sccsid[] =
16 "@(#)atan.c	1.1 (Berkeley) 8/21/85; 1.2 (ucb.elefunt) 09/11/85";
17 #endif not lint
18 
19 /* ATAN(X)
20  * RETURNS ARC TANGENT OF X
21  * DOUBLE PRECISION (IEEE DOUBLE 53 bits, VAX D FORMAT 56 bits)
22  * CODED IN C BY K.C. NG, 4/16/85, REVISED ON 6/10/85.
23  *
24  * Required kernel function:
25  *	atan2(y,x)
26  *
27  * Method:
28  *	atan(x) = atan2(x,1.0).
29  *
30  * Special case:
31  *	if x is NaN, return x itself.
32  *
33  * Accuracy:
34  * 1)  If atan2() uses machine PI, then
35  *
36  *	atan(x) returns (PI/pi) * (the exact arc tangent of x) nearly rounded;
37  *	and PI is the exact pi rounded to machine precision (see atan2 for
38  *      details):
39  *
40  *	in decimal:
41  *		pi = 3.141592653589793 23846264338327 .....
42  *    53 bits   PI = 3.141592653589793 115997963 ..... ,
43  *    56 bits   PI = 3.141592653589793 227020265 ..... ,
44  *
45  *	in hexadecimal:
46  *		pi = 3.243F6A8885A308D313198A2E....
47  *    53 bits   PI = 3.243F6A8885A30  =  2 * 1.921FB54442D18	error=.276ulps
48  *    56 bits   PI = 3.243F6A8885A308 =  4 * .C90FDAA22168C2    error=.206ulps
49  *
50  *	In a test run with more than 200,000 random arguments on a VAX, the
51  *	maximum observed error in ulps (units in the last place) was
52  *	0.86 ulps.      (comparing against (PI/pi)*(exact atan(x))).
53  *
54  * 2)  If atan2() uses true pi, then
55  *
56  *	atan(x) returns the exact atan(x) with error below about 2 ulps.
57  *
58  *	In a test run with more than 1,024,000 random arguments on a VAX, the
59  *	maximum observed error in ulps (units in the last place) was
60  *	0.85 ulps.
61  */
62 
63 double atan(x)
64 double x;
65 {
66 	double atan2(),one=1.0;
67 	return(atan2(x,one));
68 }
69