快速弧余弦算法? [英] Fast Arc Cos algorithm?
本文介绍了快速弧余弦算法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我自己的,非常快的余弦函数:
I have my own, very fast cos function:
float sine(float x)
{
const float B = 4/pi;
const float C = -4/(pi*pi);
float y = B * x + C * x * abs(x);
// const float Q = 0.775;
const float P = 0.225;
y = P * (y * abs(y) - y) + y; // Q * y + P * y * abs(y)
return y;
}
float cosine(float x)
{
return sine(x + (pi / 2));
}
但现在,当我的空间,我看到ACOS()被杀害的处理器。我不需要instense precision。什么是一个快速的方法来计算ACOS(X) 谢谢你。
But now when I profile, I see that acos() is killing the processor. I don't need instense precision. What is a fast way to calculate acos(x) Thanks.
推荐答案
一个简单立方近似,拉格朗日多项式对于x∈{-1,-½,0,½,1},是:
A simple cubic approximation, the Lagrange polynomial for x ∈ {-1, -½, 0, ½, 1}, is:
double acos(x) {
return (-0.69813170079773212 * x * x - 0.87266462599716477) * x + 1.5707963267948966;
}
它具有约0.18弧度的最大误差。
It has a maximum error of about 0.18 rad.
这篇关于快速弧余弦算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文