News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Decomposition sinus in a Taylor series using SSE-instructions

Started by Mikl__, February 28, 2014, 04:54:09 PM

Previous topic - Next topic

Mikl__

Series expansion of sin (x)
that is, I have an array of coefficients a [4] = {1, -0.16666667, 0.0083333333, -0.0001984127}
first step - I build an array b [4] = {x, x3, x5, x7}
second step - multiplies the elements of arrays a and b, to obtain partial sums of a[1]*b[1] + a[2]*b [2], a[3]b[3]+a[4]b[4];
third step - gives the total amount of arrays a[1]*b[1]+a[2]b[2]+a[3]*b[3]+a[4]*b[4].
True if the algorithm? And which of the SSE-instructions better to use?

qWord

You forgot to mention the range reduction and selection of the quadrant:
     xr = x MOD pi/2 = x - Pi/2*Floor(x*2/Pi)
To reduce precision lost of the subtraction (especially for larger values), you should do the subtraction as
    k = Floor(x*2/Pi)
    xr = (x - C0*k) - C1*k
whereas C0 + C1 == Pi/2 with an higher precision than the working precision. For example C0 holds the upper 24 bits (correctly rounded) of Pi/2 and C1= pi/2 - C0.
When using CVTTSD/SS2SI to get the Floor()-value, the returned integer could also be used to get the current quadrant.
For evaluation of the polynomial you can use Horner's form:
T(f) = x(1 + x2( -1/!3 + x2(1/!5 - 1/!7*x2)))
MREAL macros - when you need floating point arithmetic while assembling!

Mikl__