# Intel® C++ Compiler Classic Math Library

The Intel® C++ Compiler Classic includes a mathematical software library containing highly optimized and very accurate mathematical functions. These functions are commonly used in scientific or graphic applications, as well as other programs that rely heavily on floating-point computations. To include support for C99 _Complex data types, use the [Q]std=c99 compiler option.

Many routines in the Intel® C++ Compiler Classic Math Library are more optimized for Intel® microprocessors than for non-Intel microprocessors.

The mathimf.h header file includes prototypes for Intel® C++ Compiler Classic Math Library functions.

### Note

Intel's math.h header file is compatible with the GCC Math Library `libm`, but it does not cause the GCC Math Library to be linked. The source can be built with gcc, icc, or icl. The header file for the math library, mathimf.h, contains additional functions that are found only in the math library. The source can only be built using the compiler and libraries.

The long double functions, such as `expl` or `logl`, in the math library are ABI incompatible with the Microsoft libraries. The Intel compiler and libraries support the 80-bit long double data type (see the description of the Qlong-double option). For maximum compatibility, use math.h or mathimf.h header files along with the math library.

## Compiler Math Libraries for Linux and macOS

The math library linked to an application depends on the compilation or linkage options specified.

Library | Description
--- | ---
libimf.a | Default static math library.
libimf.so | Default shared math library.

### Note

The math libraries contain performance-optimized implementations for various Intel platforms. By default, the best implementation for the underlying hardware is selected at runtime. The library dispatch of multi-threaded code may lead to apparent data races, which may be detected by certain software analysis tools. However, as long as the threads are running on cores with the same CPUID, these data races are harmless and not a cause for concern.

## Compiler Math Libraries for Windows

The math library linked to an application depends on the compilation or linkage options specified.

Library | Option | Description
--- | --- | ---
libm.lib |  | Default static math library.
libmmt.lib | /MT | Multi-threaded static math library.
libmmd.lib | /MD | Dynamically linked math library.
libmmdd.lib | /MDd | Dynamically linked debug math library.
libmmds.lib |  | Static version compiled with /MD option.

## oneAPI and OpenCL™ Considerations

Currently, oneAPI uses the OpenCL Specification to determine the ULP accuracy for OpenCL mathematical functions. Details about their precision and accuracy, including tables for single and double precision functions, are available from the Khronos OpenCL Specification's section, Relative Error as ULPs.

Mathematical functions have different accuracy levels on different devices. The OpenCL specification sets a limit on the maximum ULP error (where applicable), but individual devices may provide a more accurate implementation. If the OpenCL implementation is optimized for CPU usage, using the same code may not work on a GPU device.

Parent topic: Optimization and Programming

- Use the Intel® C++ Compiler Classic Math Library
- Math Function List
- Trigonometric Functions
- Hyperbolic Functions
- Exponential Functions
- Special Functions
- Nearest Integer Functions
- Remainder Functions
- Miscellaneous Functions
- Complex Functions
- C99 Macros

## See Also

Math Function List
Qlong-double compiler option
MD compiler option
MT compiler option
std, Qstd compiler option