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