This algorithm to compute sine and cosine is very clever. The fixedpoint calculation is limited to compares, shifts, complements and adds. This is a C version that concentrates on the mathematical logic. pw(j) computes 2j. The calculation of arc tangent is limited to powers of two and these values can be tabulated, and even that table can be trivially compressed by a factor of 12. Note that atan(−x) = −atan(x).

Here we compute the magic and atan(2−j) number in HEX.

It just now occurs to me that within the table of constants the beginning constants must be correct in the high order positions and the ending values are zero except for the least significant bits. If we shifted the comparands left gradually during the computations, a factor of two or three might be achieved in the space to keep the constants.