Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_tlsv12/sys/src/ape/lib/ap/math/asin.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 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 <math.h>
9
#include <errno.h>
10
 
11
static double pio2	= 1.570796326794896619231e0;
12
 
13
double
14
asin(double arg)
15
{
16
	double temp;
17
	int sign;
18
 
19
	sign = 0;
20
	if(arg < 0) {
21
		arg = -arg;
22
		sign++;
23
	}
24
	if(arg > 1) {
25
		errno = EDOM;
26
		return 0;
27
	}
28
	temp = sqrt(1 - arg*arg);
29
	if(arg > 0.7)
30
		temp = pio2 - atan(temp/arg);
31
	else
32
		temp = atan(arg/temp);
33
 
34
	if(sign)
35
		temp = -temp;
36
	return temp;
37
}
38
 
39
double
40
acos(double arg)
41
{
42
	if(arg > 1 || arg < -1) {
43
		errno = EDOM;
44
		return 0;
45
	}
46
	return pio2 - asin(arg);
47
}