2004-03-03 21:24:06 +01:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "defs.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
eval_arcsin(void)
|
|
|
|
{
|
|
|
|
push(cadr(p1));
|
|
|
|
eval();
|
|
|
|
arcsin();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
arcsin(void)
|
|
|
|
{
|
|
|
|
int n;
|
|
|
|
double d;
|
|
|
|
|
|
|
|
save();
|
|
|
|
|
|
|
|
p1 = pop();
|
|
|
|
|
2005-08-06 22:57:37 +02:00
|
|
|
if (isdouble(p1)) {
|
2004-03-03 21:24:06 +01:00
|
|
|
errno = 0;
|
|
|
|
d = asin(p1->u.d);
|
|
|
|
if (errno)
|
|
|
|
stop("arcsin function argument is not in the interval [-1,1]");
|
|
|
|
push_double(d);
|
|
|
|
restore();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-08-06 22:57:37 +02:00
|
|
|
if (!isrational(p1)) {
|
2004-03-03 21:24:06 +01:00
|
|
|
push_symbol(ARCSIN);
|
|
|
|
push(p1);
|
|
|
|
list(2);
|
|
|
|
restore();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
push(p1);
|
|
|
|
push_integer(2);
|
|
|
|
multiply();
|
|
|
|
n = pop_integer();
|
|
|
|
|
|
|
|
switch (n) {
|
|
|
|
|
|
|
|
case -2:
|
|
|
|
push_rational(-1, 2);
|
|
|
|
push_symbol(PI);
|
|
|
|
multiply();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case -1:
|
|
|
|
push_rational(-1, 6);
|
|
|
|
push_symbol(PI);
|
|
|
|
multiply();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
2004-06-25 22:45:15 +02:00
|
|
|
push(zero);
|
2004-03-03 21:24:06 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
push_rational(1, 6);
|
|
|
|
push_symbol(PI);
|
|
|
|
multiply();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
push_rational(1, 2);
|
|
|
|
push_symbol(PI);
|
|
|
|
multiply();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
push_symbol(ARCSIN);
|
|
|
|
push(p1);
|
|
|
|
list(2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *s[] = {
|
|
|
|
|
|
|
|
"arcsin(-1)",
|
|
|
|
"-1/2*pi",
|
|
|
|
|
|
|
|
"arcsin(-1/2)",
|
|
|
|
"-1/6*pi",
|
|
|
|
|
|
|
|
"arcsin(0)",
|
|
|
|
"0",
|
|
|
|
|
|
|
|
"arcsin(1/2)",
|
|
|
|
"1/6*pi",
|
|
|
|
|
|
|
|
"arcsin(1)",
|
|
|
|
"1/2*pi",
|
|
|
|
|
|
|
|
"arcsin(sin(-1/2*pi))",
|
|
|
|
"-1/2*pi",
|
|
|
|
|
|
|
|
"arcsin(sin(-1/6*pi))",
|
|
|
|
"-1/6*pi",
|
|
|
|
|
|
|
|
"arcsin(sin(0))",
|
|
|
|
"0",
|
|
|
|
|
|
|
|
"arcsin(sin(1/6*pi))",
|
|
|
|
"1/6*pi",
|
|
|
|
|
|
|
|
"arcsin(sin(1/2*pi))",
|
|
|
|
"1/2*pi",
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
test_arcsin(void)
|
|
|
|
{
|
|
|
|
test(__FILE__, s, sizeof s / sizeof (char *));
|
|
|
|
}
|