![]() |
Raven Engine v0.1
|
Estrin-based polynomial evaluation for sine and cosine. More...
Namespaces | |
| namespace | Crux |
| namespace | Crux::Detail |
Functions | |
| template<int Degree> | |
| constexpr float | Crux::Detail::PolySinImpl (float x) |
| Generic Estrin-based sine polynomial of degree D on x in [-pi/4,pi/4]. | |
| template<> | |
| float | Crux::Detail::PolySinImpl< 5 > (float x) |
| template<> | |
| float | Crux::Detail::PolySinImpl< 7 > (float x) |
| template<> | |
| float | Crux::Detail::PolySinImpl< 9 > (float x) |
| template<int Degree> | |
| constexpr float | Crux::Detail::PolyCosImpl (float x) |
| Generic Estrin-based cosine polynomial of degree D on x in [-pi/4,pi/4]. | |
| template<> | |
| float | Crux::Detail::PolyCosImpl< 5 > (float x) |
| template<> | |
| float | Crux::Detail::PolyCosImpl< 7 > (float x) |
| template<> | |
| float | Crux::Detail::PolyCosImpl< 9 > (float x) |
Estrin-based polynomial evaluation for sine and cosine.
After reducing x into the primary interval \([-\pi/4, \pi/4]\), we approximate:
\[ \sin(x) \approx x \; P(y), \quad y = x^2, \quad P(y) = c_1 + c_3\,y + c_5\,y^2 + \dots + c_D\,y^{(D-1)/2}. \]
We factor out \(x\) so that the remaining polynomial \(P(y)\) is in even powers.\[ \cos(x) \approx Q(y), \quad y = x^2, \quad Q(y) = c_0 + c_2\,y + c_4\,y^2 + \dots + c_D\,y^{D/2}. \]
To minimize the FMA dependency chain, we use Estrin's method:
\[ A = c_1 + c_3\,y,\quad B = c_5 + c_7\,y,\quad \dots \]
\[ P(y) = A + B\,y^2,\quad \dots \]
This yields short, parallelizable paths (FMA height \(\approx\) 2), ideal for SIMD pipelines.