# Accelerated UFuncs¶

Variants of some Numpy UFuncs that use Intel’s Vector Math Library (VML) are found in the `accelerate.mkl` package in the `ufuncs` object. In comparison to Numpy’s built-in UFuncs, Accelerated UFuncs have the following properties:

Performance
Because Accelerated UFuncs call functions from VML, which is a library optimised for high performance using multiple threads and SIMD instructions, performance may be increased when calling Accelerated UFuncs in comparison to calling Numpy UFuncs. The performance increase will only be obtained for contiguous arguments. For non-contiguous arguments, performance comparable to Numpy’s will be observed.
Accuracy
• Accelerated UFuncs produce similar results to their Numpy equivalents for the range of finite values, up to a given relative tolerance.
• The tolerance varies between functions and data types, and is specified for each combination in the following section.
• For the range of infinite and NaN values, the majority of results computed by Accelerated UFuncs will be equal to those computed by their Numpy counterparts. However, this is not guaranteed; for example, an input for which the Numpy UFunc produces a result of `x + inf*j`, the equivalent Accelerated UFunc may produce a result of `y + inf*j`, where `x != y`.
• Towards the edge of the domain of a data type (e.g. near `3.4e+38` for `float` and `1.79e+308` for `double` and values of similar magnitude at the negative end of the domain) some Accelerated UFuncs may produce results which differ from Numpy UFuncs, or may raise `FloatingPointError` or `ZeroDivisionError` exceptions. These functions are marked domain edge warning in the Accuracy column of the tables in the following sections.
• Denormal input values may be treated as zero by Accelerated UFuncs, and denormal output values may be flushed to zero.
Exception handling
For the range of finite values, exceptions will not be raised by Accelerated UFuncs, just as they would not by Numpy. For the infinite and NaN ranges, Accelerated UFuncs may raise `FloatingPointError` or `ZeroDivisionError` exceptions in cases when Numpy would not, and vice-versa.

Supported functions are described in the following sections.

## Arithmetic Functions¶

Function Type Accuracy
`add(x, y)` `f4` `rtol=1.0e-7`
`f8` `rtol=1.0e-15`
`c8` `rtol=1.0e-7`
`c16` `rtol=1.0e-15`
`subtract(x, y)` `f4` `rtol=1.e-7`
`f8` `rtol=1.e-15`
`c8` `rtol=1.e-7`
`c16` `rtol=1.e-15`
`square(x)` `f4` `rtol=1.e-7`
`f8` `rtol=1.e-15`
`multiply(x, y)` `f4` `rtol=1.e-7`
`f8` `rtol=1.e-15`
`c8` `rtol=1.e-6`
`c16` `rtol=1.e-15`
`absolute(x)` `f4` `rtol=1.e-6`
`f8` `rtol=1.e-15`

## Power and Root Functions¶

Function Type Accuracy
`reciprocal(x)` `f4` `rtol=1.e-7`
`f8` `rtol=1.e-15`
`true_divide(x, y)` `f4` `rtol=1.e-7`
`f8` `rtol=1.e-15`
`c8` `rtol=1.e-7`
`c16` `rtol=1.e-15`
`sqrt(x, y)` `f4` `rtol=1.e-6`
`f8` `rtol=1.e-15`
`c8` `rtol=1.e-6`, domain edge warning
`c16` `rtol=1.e-15`, domain edge warning
`power(x, y)` `f4` `rtol=1.e-7`
`f8` `rtol=1.e-15`
`hypot(x, y)` `f4` `rtol=1.e-7`
`f8` `rtol=1.e-15`

## Exponential and Logarithmic Functions¶

Function Type Accuracy
`exp(x, y)` `f4` `rtol=1.e-6`
`f8` `rtol=1.e-15`
`c8` `rtol=1.e-6`, domain edge warning
`c16` `rtol=1.e-15`, domain edge warning
`expm1(x, y)` `f4` `rtol=1.e-6`
`f8` `rtol=1.e-15`
`log(x, y)` `f4` `rtol=1.e-6`
`f8` `rtol=1.e-15`
`c8` `rtol=1.e-5`
`c16` `rtol=1.e-13`
`log10(x, y)` `f4` `rtol=1.e-6`
`f8` `rtol=1.e-15`
`c8` `rtol=1.e-5`, domain edge warning
`c16` `rtol=1.e-13`, domain edge warning
`log1p(x, y)` `f4` `rtol=1.e-6`
`f8` `rtol=1.e-15`

## Trigonometric Functions¶

Function Type Accuracy
`cos(x, y)` `f4` `rtol=1.e-6`, domain edge warning
`f8` `rtol=1.e-15`, domain edge warning
`c8` `rtol=1.e-6`, domain edge warning
`c16` `rtol=1.e-15`, domain edge warning