Main Archive Specials Wiki | FAQ Links Submit Forum

Sin(x) Aproximation (with SSE code)

References : Posted by williamk[AT]wusik[DOT]com

Notes :
Sin Aproximation: sin(x) = x + ( x * (-x * x / 6));

This is very handy and fast, but not precise. Below you will find a simple SSE code.

Remember that all movaps command requires 16 bit aligned variables.

Code :
SSE code for computing only ONE value (scalar)
Replace all "ss" with "ps" if you want to calculate 4 values. And instead of "movps" use "movaps".

movss xmm1, xmm0 ; xmm0 = x
mulss xmm1, Filter_GenVal[k_n1] ; * -1
mulss xmm1, xmm0 ; -x * x
divss xmm1, Filter_GenVal[k_6] ; / 6
mulss xmm1, xmm0
addss xmm0, xmm1


Added on : 06/10/04 by kaleja[ AT ]estarcion[ DOT ]com
Comment :
Divides hurt. Change your constant 6 to a constant (1.0/6.0) and change divss to mulss.

Added on : 31/05/05 by little%20eeky[ AT ]aol[ DOT ]com
Comment :
error about 7.5% by +/- pi/2
you can improve this considerably by
fitting cubic at points -pi/2, 0, pi/2 i.e:
sin(x) = x - x^3 / 6.7901358

Add your own comment
Comments are displayed in fixed width, no HTML code allowed!


Are you human?

Site created and maintained by Bram
Graphic design by line.out | Server sponsered by fxpansion