哈特的
Computer Approximations为不同精度的一系列函数制定了
Chebyshev-economized近似公式。
编辑:把我的副本放在架子上,原来是a different book,听起来很相似。这是一个使用其表的sin函数。 (在C测试,因为这对我来说更为方便)。我不知道这是否会比Java内置的更快,但至少保证不太准确。 :)您可能需要先缩小参数范围 – 见John Cook’s suggestions.这本书还有arcsin和arctan。
#include
#include
// Return an approx to sin(pi/2 * x) where -1 <= x <= 1.
// In that range it has a max absolute error of 5e-9
// according to Hastings, Approximations For Digital Computers.
static double xsin (double x) {
double x2 = x * x;
return ((((.00015148419 * x2
- .00467376557) * x2
+ .07968967928) * x2
- .64596371106) * x2
+ 1.57079631847) * x;
}
int main () {
double pi = 4 * atan (1);
printf ("%.10f\n", xsin (0.77));
printf ("%.10f\n", sin (0.77 * (pi/2)));
return 0;
}