Reverse-engineering the Intel 8087's tangent algorithm: more than CORDIC
First reported by Righto ·
The Intel 8087's tangent algorithm combined two methods, a strategy still relevant for optimizing complex calculations.
Ken Shirriff's analysis of the Intel 8087's tangent algorithm reveals a sophisticated approach that combines CORDIC and polynomial approximation for high accuracy and performance. Introduced in 1980, the 8087 significantly accelerated floating-point operations, computing a tangent in 90 microseconds compared to the 8086's 13,000 microseconds. Shirriff examined the chip's circuitry and microcode, identifying the FPTAN instruction's algorithm. The CORDIC part breaks down an angle into a sum of special angles using shift-and-add operations for initial accuracy, while a rational polynomial approximation refines the result for remaining small angles. This hybrid method enabled the 8087 to achieve 64-bit accuracy, a remarkable feat for its time, by efficiently handling trigonometric calculations.
Shirriff's detailed reverse-engineering demonstrates that the 8087's tangent function, FPTAN, employed a hybrid algorithm. It leveraged the CORDIC method for an initial approximation of the angle, benefiting from its hardware efficiency with shifts and adds. For the remaining small angular error, it utilized a rational polynomial approximation (3x/(3-x²)) to achieve high precision without requiring further complex CORDIC iterations. This dual approach allowed the 8087 to deliver accurate results rapidly, a significant engineering achievement for 1980s hardware.
This meticulous deconstruction highlights how early pioneers optimized complex mathematical functions within hardware constraints, offering lessons for modern chip design focused on AI and specialized processing. The 8087's strategy of segmenting a problem into computationally efficient stages, combining lookup tables with targeted approximations, remains a cornerstone of efficient algorithm design. Understanding these foundational techniques can inform current efforts to build faster and more accurate processing units for emerging computational demands.
AI-written summary. May contain errors.