math.pc (plain text)
- pi() returns pi (3.14592653589793238463)
- e() returns e (2.71828182845904523536)
- abs(float x) returns the absolute value of x
- sinh(float x) returns the hyperbolic sine of x
- cosh(float x) returns the hyperbolic cosine of x
- tanh(float x) returns the hyperbolic tangent of x
- asinh(float x) returns the inverse hyperbolic sine of x
- acosh(float x) returns the inverse hyperbolic cosine of x
- atanh(float x) returns the inverse hyperbolic tangent of x
- fac(float x) returns x! (= Gamma(x-1))
/* Math */
pi()
{ return 3.14592653589793238463; }
e()
{ return 2.71828182845904523536; }
abs(float x)
{ if (x < 0) return -x;
else return x;
}
sinh(float x)
{ float u;
u = exp(x);
return 0.5 * (u - 1/u);
}
cosh(float x)
{ float u;
u = exp(x);
return 0.5 * (u + 1/u);
}
tanh(float x)
{ float u;
u = exp(2 * x);
return (u - 1)/(u + 1);
}
asinh(float x)
{ return log(x + sqrt(x * x + 1)); }
acosh(float x)
{ if (x < 1) return;
return log(x + sqrt(x * x - 1));
}
atanh(float x)
{ if ((x <= -1) || (x >= 1)) return;
return 0.5 * log((1 + x)/(1 - x));
}
fac(float x)
{ float u;
if (x >= 1) u = x * fac(x - 1);
else {
u = (((((((0.035867343 *x - 0.193527818) * x +
0.482199394) * x - 0.756704078) * x +
0.918206857) * x - 0.897056937) * x +
0.988205891) * x - 0.577191652) * x + 1;
}
return u;
}