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

Comments
from : kaleja[AT]estarcion[DOT]com
comment : Divides hurt. Change your constant 6 to a constant (1.0/6.0) and change divss to mulss.

from : 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