The Difference Between x87 Instructions FSIN, FCOS, FSINCOS, and FPTAN and Their Mathematical Counterparts

Published: 01/11/2016, Last Updated: 01/11/2016

Summary

In the early 1980s, the Intel® 8087 Math Coprocessor introduced hardware support for a small set of elementary transcendental functions (trigonometric, inverse trigonometric, exponential, and logarithmic), accessible through x87 instructions. In the 1990s Intel replaced the 8087’s CORDIC-based approximations of the elementary transcendental functions with polynomial-based approximations. These newer polynomial-based approximations provide a large degree of backwards compatibility with the CORDIC based approximations by approximating precisely the same functions, but with greater overall accuracy and speed.

The purpose of this paper is to inform users of many of the implementation details of the x87 trigonometric instructions. If users find that the x87 elementary transcendental instructions are not adequate for their needs, they should consider using the software libraries of transcendental functions available through the Intel® C++ Compiler and Intel® Fortran Compiler, the Intel® Math Kernel Library (Intel® MKL) product, or libraries from other providers. Just as double precision arithmetic is provided to users when single precision floating-point arithmetic is not adequate, so these software library functions provide more accurate approximations when the x87 instructions are not adequate. 

The paper explains that FSIN(x), FCOS(x), FSINCOS(x) and FPTAN(x) are approximations of the corresponding mathematical functions of argument (x • π/p), and not of argument (x). Therefore they can only be used to approximate the mathematical functions sin(x), cos(x), and tan(x) on a limited domain, outside of which a more accurate argument reduction technique is necessary in order to contain the errors, or, alternatively, accurate software implementations of these mathematical functions may to be used.

The limitations of using a 68-bit approximation of π are also explained in the Intel® 64 and IA-32 Architectures Software Developer Manuals, available online at http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html. See Vol. 1, section 8.3.8 “Approximation of Pi”, and the instruction manual pages in Vol. 2A, section 3.2.

For the complete article, please open the attached PDF file.

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804