2004-03-03 21:24:06 +01:00
|
|
|
// exp(x) + exp(-x)
|
|
|
|
// cosh(x) = ----------------
|
|
|
|
// 2
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "defs.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
eval_cosh(void)
|
|
|
|
{
|
|
|
|
push(cadr(p1));
|
|
|
|
eval();
|
|
|
|
ycosh();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ycosh(void)
|
|
|
|
{
|
|
|
|
save();
|
|
|
|
yycosh();
|
|
|
|
restore();
|
|
|
|
}
|
|
|
|
|
2006-01-04 02:21:32 +01:00
|
|
|
void
|
2004-03-03 21:24:06 +01:00
|
|
|
yycosh(void)
|
|
|
|
{
|
|
|
|
double d;
|
|
|
|
p1 = pop();
|
2006-04-19 01:18:30 +02:00
|
|
|
if (car(p1) == symbol(ARCCOSH)) {
|
|
|
|
push(cadr(p1));
|
|
|
|
return;
|
|
|
|
}
|
2005-08-06 22:57:37 +02:00
|
|
|
if (isdouble(p1)) {
|
2004-03-03 21:24:06 +01:00
|
|
|
d = cosh(p1->u.d);
|
|
|
|
if (fabs(d) < 1e-10)
|
|
|
|
d = 0.0;
|
|
|
|
push_double(d);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (iszero(p1)) {
|
2004-06-25 22:45:15 +02:00
|
|
|
push(one);
|
2004-03-03 21:24:06 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
push_symbol(COSH);
|
|
|
|
push(p1);
|
|
|
|
list(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *s[] = {
|
|
|
|
|
|
|
|
"cosh(x)",
|
|
|
|
"cosh(x)",
|
|
|
|
|
|
|
|
"cosh(0)",
|
|
|
|
"1",
|
|
|
|
|
2006-04-19 01:18:30 +02:00
|
|
|
"cosh(arccosh(x))",
|
|
|
|
"x",
|
2004-03-03 21:24:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
test_cosh(void)
|
|
|
|
{
|
|
|
|
test(__FILE__, s, sizeof s / sizeof (char *));
|
|
|
|
}
|