xref: /original-bsd/old/libm/libom/asin.c (revision e59fb703)
1 /*	@(#)asin.c	4.1	12/25/82	*/
2 
3 /*
4 	asin(arg) and acos(arg) return the arcsin, arccos,
5 	respectively of their arguments.
6 
7 	Arctan is called after appropriate range reduction.
8 */
9 
10 #include	<errno.h>
11 int errno;
12 double atan();
13 double sqrt();
14 static double pio2	= 1.570796326794896619;
15 
16 double
17 asin(arg) double arg; {
18 
19 	double sign, temp;
20 
21 	sign = 1.;
22 	if(arg <0){
23 		arg = -arg;
24 		sign = -1.;
25 	}
26 
27 	if(arg > 1.){
28 		errno = EDOM;
29 		return(0.);
30 	}
31 
32 	temp = sqrt(1. - arg*arg);
33 	if(arg > 0.7)
34 		temp = pio2 - atan(temp/arg);
35 	else
36 		temp = atan(arg/temp);
37 
38 	return(sign*temp);
39 }
40 
41 double
42 acos(arg) double arg; {
43 
44 	if((arg > 1.) || (arg < -1.)){
45 		errno = EDOM;
46 		return(0.);
47 	}
48 
49 	return(pio2 - asin(arg));
50 }
51