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