BSD 4_1c_2 release
[unix-history] / usr / src / usr.lib / libm / asin.c
CommitLineData
e804469b 1/* @(#)asin.c 4.1 12/25/82 */
c8c4d6b2
SL
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>
11int errno;
12double atan();
13double sqrt();
14static double pio2 = 1.570796326794896619;
15
16double
17asin(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
41double
42acos(arg) double arg; {
43
44 if((arg > 1.) || (arg < -1.)){
45 errno = EDOM;
46 return(0.);
47 }
48
49 return(pio2 - asin(arg));
50}