From: Bill Joy Date: Sun, 3 Feb 1980 07:11:08 +0000 (-0800) Subject: BSD 3 development X-Git-Tag: BSD-3~36 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/b302fb5760d9701e0660ee0f18518ac5fca481db BSD 3 development Work on file usr/src/lib/libm/asin.c Synthesized-from: 3bsd --- diff --git a/usr/src/lib/libm/asin.c b/usr/src/lib/libm/asin.c new file mode 100644 index 0000000000..cacb6b4fb1 --- /dev/null +++ b/usr/src/lib/libm/asin.c @@ -0,0 +1,48 @@ +/* + asin(arg) and acos(arg) return the arcsin, arccos, + respectively of their arguments. + + Arctan is called after appropriate range reduction. +*/ + +#include +int errno; +double atan(); +double sqrt(); +static double pio2 = 1.570796326794896619; + +double +asin(arg) double arg; { + + double sign, temp; + + sign = 1.; + if(arg <0){ + arg = -arg; + sign = -1.; + } + + if(arg > 1.){ + errno = EDOM; + return(0.); + } + + temp = sqrt(1. - arg*arg); + if(arg > 0.7) + temp = pio2 - atan(temp/arg); + else + temp = atan(arg/temp); + + return(sign*temp); +} + +double +acos(arg) double arg; { + + if((arg > 1.) || (arg < -1.)){ + errno = EDOM; + return(0.); + } + + return(pio2 - asin(arg)); +}