SLEEF Documentation

# SLEEF Documentation - Math library reference

## Table of contents

- Introduction
- Compiling and installing the library
- Math library reference
  - Data types and functions for all architectures
  - Data types
  - Trigonometric functions
  - Power, exponential, and logarithmic functions
  - Inverse trigonometric functions
  - Hyperbolic functions and inverse hyperbolic functions
  - Error and gamma functions
  - Nearest integer functions
  - Other functions
  - Data types and functions for x86 architectures
  - Data types and functions for AArch64 architectures
  - Data types and functions for AArch32 architectures
  - Data types and functions for PPC64 architecture
- DFT library reference
- Other tools included in the package
- Benchmark results
- Additional notes

## Data types

Sleef_double2

Description

Sleef_double2 is a generic data type for storing two double-precision floating point values, which is defined in <sleef.h> as follows:

    typedef struct {
          double x, y;
    } Sleef_double2;

Sleef_float2

Description

Sleef_float2 is a generic data type for storing two single-precision floating point values, which is defined in <sleef.h> as follows:

    typedef struct {
          float x, y;
    } Sleef_float2;

Sleef_longdouble2

Description

Sleef_longdouble2 is a generic data type for storing two extended-precision (80-bit) floating point values, which is defined in <sleef.h> as follows:

    typedef struct {
          long double x, y;
    } Sleef_longdouble2;

## Trigonometric Functions

Sleef_sin_u10, Sleef_sinf_u10 - sine functions with 1.0 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_sin_u10(double a);
float Sleef_sinf_u10(float a);
Link with -lsleef.

Description

These functions evaluates the sine function of a value in a. The error bound of the returned value is 1.0 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_sin_u35, Sleef_sinf_u35 - sine functions with 3.5 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_sin_u35(double a);
float Sleef_sinf_u35(float a);
Link with -lsleef.

Description

These functions evaluates the sine function of a value in a. The error bound of the returned value is 3.5 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_cos_u10, Sleef_cosf_u10 - cosine functions with 1.0 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_cos_u10(double a);
float Sleef_cosf_u10(float a);
Link with -lsleef.

Description

These functions evaluates the cosine function of a value in a. The error bound of the returned value is 1.0 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_cos_u35, Sleef_cosf_u35 - cosine functions with 3.5 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_cos_u35(double a);
float Sleef_cosf_u35(float a);
Link with -lsleef.

Description

These functions evaluates the cosine function of a value in a. The error bound of the returned value is 3.5 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_sincos_u10, Sleef_sincosf_u10 - evaluate sine and cosine functions simultaneously with 1.0 ULP error bound

Synopsis

#include <sleef.h>
Sleef_double2 Sleef_sincos_u10(double a)
Sleef_float2 Sleef_sincosf_u10(float a)
Link with -lsleef.

Description

Evaluates the sine and cosine functions of a value in a at a time, and store the two values in x and y elements in the returned value, respectively. The error bound of the returned values is 1.0 ULP. If a is a NaN or infinity, a NaN is returned.

Sleef_sincos_u35, Sleef_sincosf_u35 - evaluate sine and cosine functions simultaneously with 3.5 ULP error bound

Synopsis

#include <sleef.h>
Sleef_double2 Sleef_sincos_u35(double a)
Sleef_float2 Sleef_sincosf_u35(float a)
Link with -lsleef.

Description

Evaluates the sine and cosine functions of a value in a at a time, and store the two values in x and y elements in the returned value, respectively. The error bound of the returned values is 3.5 ULP. If a is a NaN or infinity, a NaN is returned.

Sleef_sincospi_u05, Sleef_sincospif_u05, Sleef_sincospil_u05 - evaluate sin( πa ) and cos( πa ) for given a simultaneously with 0.506 ULP error bound

Synopsis

#include <sleef.h>
Sleef_double2 Sleef_sincospi_u05(double a)
Sleef_float2 Sleef_sincospif_u05(float a)
Sleef_longdouble2 Sleef_sincospil_u05(long double a)
Link with -lsleef.

Description

Evaluates the sine and cosine functions of πa at a time, and store the two values in x and y elements in the returned value, respectively. The error bound of the returned value are max(0.506 ULP, DBL_MIN) if a is in [-1e+9, 1e+9] for double-precision function, or max(0.506 ULP, FLT_MIN) if [-1e+7, 1e+7] for the single-precision function. If a is a finite value out of this range, an arbitrary value within [-1, 1] is returned. If a is a NaN or infinity, a NaN is returned.

Sleef_sincospi_u35, Sleef_sincospif_u35, Sleef_sincospil_u35 - evaluate sin( πa ) and cos( πa ) for given a simultaneously with 3.5 ULP error bound

Synopsis

#include <sleef.h>
Sleef_double2 Sleef_sincospi_u35(double a)
Sleef_float2 Sleef_sincospif_u35(float a)
Sleef_longdouble2 Sleef_sincospil_u35(long double a)
Link with -lsleef.

Description

Evaluates the sine and cosine functions of πa at a time, and store the two values in x and y elements in the returned value, respectively. The error bound of the returned values is 3.5 ULP if a is in [-1e+9, 1e+9] for double-precision function or [-1e+7, 1e+7] for the single-precision function. If a is a finite value out of this range, an arbitrary value within [-1, 1] is returned. If a is a NaN or infinity, a NaN is returned.

Sleef_sinpi_u05, Sleef_sinpif_u05 - evaluate sin( πa ) for given a with 0.506 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_sinpi_u05(double a);
float Sleef_sinpif_u05(float a);
Link with -lsleef.

Description

These functions evaluates the sine functions of πa . The error bound of the returned value are max(0.506 ULP, DBL_MIN) if a is in [-1e+9, 1e+9] for double-precision function, or max(0.506 ULP, FLT_MIN) if [-1e+7, 1e+7] for the single-precision function. If a is a finite value out of this range, an arbitrary value within [-1, 1] is returned. If a is a NaN or infinity, a NaN is returned.

Sleef_cospi_u05, Sleef_cospif_u05 - evaluate cos( πa ) for given a with 0.506 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_cospi_u05(double a);
float Sleef_cospif_u05(float a);
Link with -lsleef.

Description

These functions evaluates the cosine functions of πa . The error bound of the returned value are max(0.506 ULP, DBL_MIN) if a is in [-1e+9, 1e+9] for double-precision function, or max(0.506 ULP, FLT_MIN) if [-1e+7, 1e+7] for the single-precision function. If a is a finite value out of this range, an arbitrary value within [-1, 1] is returned. If a is a NaN or infinity, a NaN is returned.

Sleef_tan_u10, Sleef_tanf_u10 - tangent functions with 1.0 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_tan_u10(double a);
float Sleef_tanf_u10(float a);
Link with -lsleef.

Description

These functions evaluates the tangent function of a value in a. The error bound of the returned value is 1.0 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_tan_u35, Sleef_tanf_u35 - tangent functions with 3.5 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_tan_u35(double a);
float Sleef_tanf_u35(float a);
Link with -lsleef.

Description

These functions evaluates the tangent function of a value in a. The error bound of the returned value is 3.5 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

## Power, exponential, and logarithmic functions

Sleef_pow_u10, Sleef_powf_u10 - power functions

Synopsis

#include <sleef.h>
double Sleef_pow_u10(double x, double y);
float Sleef_powf_u10(float x, float y);
Link with -lsleef.

Description

These functions return the value of x raised to the power of y. The error bound of the returned value is 1.0 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_log_u10, Sleef_logf_u10 - natural logarithmic functions with 1.0 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_log_u10(double a);
float Sleef_logf_u10(float a);
Link with -lsleef.

Description

These functions return the natural logarithm of a. The error bound of the returned value is 1.0 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_log_u35, Sleef_logf_u35 - natural logarithmic functions with 3.5 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_log_u35(double a);
float Sleef_logf_u35(float a);
Link with -lsleef.

Description

These functions return the natural logarithm of a. The error bound of the returned value is 3.5 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_log10_u10, Sleef_log10f_u10 - base-10 logarithmic functions

Synopsis

#include <sleef.h>
double Sleef_log10_u10(double a);
float Sleef_log10f_u10(float a);
Link with -lsleef.

Description

These functions return the base-10 logarithm of a. The error bound of the returned value is 1.0 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_log2_u10, Sleef_log2f_u10 - base-10 logarithmic functions

Synopsis

#include <sleef.h>
double Sleef_log2_u10(double a);
float Sleef_log2f_u10(float a);
Link with -lsleef.

Description

These functions return the base-2 logarithm of a. The error bound of the returned value is 1.0 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_log1p_u10, Sleef_log1pf_u10 - logarithm of one plus argument

Synopsis

#include <sleef.h>
double Sleef_log1p_u10(double a);
float Sleef_log1pf_u10(float a);
Link with -lsleef.

Description

These functions return the natural logarithm of (1+a). The error bound of the returned value is 1.0 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_exp_u10, Sleef_expf_u10 - base-e exponential functions

Synopsis

#include <sleef.h>
double Sleef_exp_u10(double a);
float Sleef_expf_u10(float a);
Link with -lsleef.

Description

These functions return the value of e raised to a. The error bound of the returned value is 1.0 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_exp2_u10, Sleef_exp2f_u10 - base-2 exponential functions

Synopsis

#include <sleef.h>
double Sleef_exp2_u10(double a);
float Sleef_exp2f_u10(float a);
Link with -lsleef.

Description

These functions return 2 raised to a. The error bound of the returned value is 1.0 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_exp10_u10, Sleef_exp10f_u10 - base-10 exponential functions

Synopsis

#include <sleef.h>
double Sleef_exp10_u10(double a);
float Sleef_exp10f_u10(float a);
Link with -lsleef.

Description

These functions return 10 raised to a. The error bound of the returned value is 1.09 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_expm1_u10, Sleef_expm1f_u10 - base-e exponential functions minus 1

Synopsis

#include <sleef.h>
double Sleef_expm1_u10(double a);
float Sleef_expm1f_u10(float a);
Link with -lsleef.

Description

These functions return the value one less than e raised to a. The error bound of the returned value is 1.0 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_sqrt_u05, Sleef_sqrtf_u05 - square root function with 0.5001 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_sqrt_u05(double x);
float Sleef_sqrtf_u05(float x);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of sqrt and sqrtf functions. The error bound of the returned value is 0.5001 ULP. These functions do not set errno nor raise an exception.

Sleef_sqrtf_u35 - square root function with 3.5 ULP error bound

Synopsis

#include <sleef.h>
float Sleef_sqrt_u35(float x);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of sqrt and sqrtf functions. The error bound of the returned value is 3.5 ULP. These functions do not set errno nor raise an exception.

Sleef_cbrt_u10, Sleef_cbrtf_u10 - cube root function with 1.0 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_cbrt_u10(double a);
float Sleef_cbrtf_u10(float a);
Link with -lsleef.

Description

These functions return the real cube root of a. The error bound of the returned value is 1.0 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_cbrt_u35, Sleef_cbrtf_u35 - cube root function with 3.5 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_cbrt_u35(double a);
float Sleef_cbrtf_u35(float a);
Link with -lsleef.

Description

These functions return the real cube root of a. The error bound of the returned value is 1.0 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_hypot_u05, Sleef_hypotf_u05 - 2D Euclidian distance function with 0.5 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_hypot_u05(double x, double y);
float Sleef_hypotf_u05(float x, float y);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of hypot and hypotf functions. The error bound of the returned value is 0.5001 ULP. These functions do not set errno nor raise an exception.

Sleef_hypot_u35, Sleef_hypotf_u35 - 2D Euclidian distance function with 3.5 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_hypot_u35(double x, double y);
float Sleef_hypotf_u35(float x, float y);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of hypot and hypotf functions. The error bound of the returned value is 0.5001 ULP. These functions do not set errno nor raise an exception.

## Inverse Trigonometric Functions

Sleef_asin_u10, Sleef_asinf_u10 - arc sine functions with 1.0 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_asin_u10(double a);
float Sleef_asinf_u10(float a);
Link with -lsleef.

Description

These functions evaluates the arc sine function of a value in a. The error bound of the returned value is 1.0 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_asin_u35, Sleef_asinf_u35 - arc sine functions with 3.5 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_asin_u35(double a);
float Sleef_asinf_u35(float a);
Link with -lsleef.

Description

These functions evaluates the arc sine function of a value in a. The error bound of the returned value is 3.5 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_acos_u10, Sleef_acosf_u10 - arc cosine functions with 1.0 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_acos_u10(double a);
float Sleef_acosf_u10(float a);
Link with -lsleef.

Description

These functions evaluates the arc cosine function of a value in a. The error bound of the returned value is 1.0 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_acos_u35, Sleef_acosf_u35 - arc cosine functions with 3.5 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_acos_u35(double a);
float Sleef_acosf_u35(float a);
Link with -lsleef.

Description

These functions evaluates the arc cosine function of a value in a. The error bound of the returned value is 3.5 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_atan_u10, Sleef_atanf_u10 - arc tangent functions with 1.0 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_atan_u10(double a);
float Sleef_atanf_u10(float a);
Link with -lsleef.

Description

These functions evaluates the arc tangent function of a value in a. The error bound of the returned value is 1.0 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_atan_u35, Sleef_atanf_u35 - arc tangent functions with 3.5 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_atan_u35(double a);
float Sleef_atanf_u35(float a);
Link with -lsleef.

Description

These functions evaluates the arc tangent function of a value in a. The error bound of the returned value is 3.5 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_atan2_u10, Sleef_atan2f_u10 - arc tangent functions of two variables with 1.0 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_atan2_u10(double y, double x);
float Sleef_atan2f_u10(float y, float x);
Link with -lsleef.

Description

These functions evaluates the arc tangent function of (y / x). The quadrant of the result is determined according to the signs of x and y. The error bounds of the returned values are max(1.0 ULP, DBL_MIN) and max(1.0 ULP, FLT_MIN), respectively. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_atan2_u35, Sleef_atan2f_u35 - arc tangent functions of two variables with 3.5 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_atan2_u35(double y, double x);
float Sleef_atan2f_u35(float y, float x);
Link with -lsleef.

Description

These functions evaluates the arc tangent function of (y / x). The quadrant of the result is determined according to the signs of x and y. The error bound of the returned value is 3.5 ULP. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

## Hyperbolic functions and inverse hyperbolic functions

Sleef_sinh_u10, Sleef_sinhf_u10 - hyperbolic sine functions

Synopsis

#include <sleef.h>
double Sleef_sinh_u10(double a);
float Sleef_sinhf_u10(float a);
Link with -lsleef.

Description

These functions evaluates the hyperbolic sine function of a value in a. The error bound of the returned value is 1.0 ULP if a is in [-709, 709] for the double-precision function or [-88.5, 88.5] for the single-precision function . If a is a finite value out of this range, infinity with a correct sign or a correct value with 1.0 ULP error bound is returned. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_sinh_u35, Sleef_sinhf_u35 - hyperbolic sine functions

Synopsis

#include <sleef.h>
double Sleef_sinh_u35(double a);
float Sleef_sinhf_u35(float a);
Link with -lsleef.

Description

These functions evaluates the hyperbolic sine function of a value in a. The error bound of the returned value is 3.5 ULP if a is in [-709, 709] for the double-precision function or [-88, 88] for the single-precision function . If a is a finite value out of this range, infinity with a correct sign or a correct value with 3.5 ULP error bound is returned. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_cosh_u10, Sleef_coshf_u10 - hyperbolic cosine functions

Synopsis

#include <sleef.h>
double Sleef_cosh_u10(double a);
float Sleef_coshf_u10(float a);
Link with -lsleef.

Description

These functions evaluates the hyperbolic cosine function of a value in a. The error bound of the returned value is 1.0 ULP if a is in [-709, 709] for the double-precision function or [-88.5, 88.5] for the single-precision function . If a is a finite value out of this range, infinity with a correct sign or a correct value with 1.0 ULP error bound is returned. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_cosh_u35, Sleef_coshf_u35 - hyperbolic cosine functions

Synopsis

#include <sleef.h>
double Sleef_cosh_u35(double a);
float Sleef_coshf_u35(float a);
Link with -lsleef.

Description

These functions evaluates the hyperbolic cosine function of a value in a. The error bound of the returned value is 3.5 ULP if a is in [-709, 709] for the double-precision function or [-88, 88] for the single-precision function . If a is a finite value out of this range, infinity with a correct sign or a correct value with 3.5 ULP error bound is returned. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_tanh_u10, Sleef_tanhf_u10 - hyperbolic tangent functions

Synopsis

#include <sleef.h>
double Sleef_tanh_u10(double a);
float Sleef_tanhf_u10(float a);
Link with -lsleef.

Description

These functions evaluates the hyperbolic tangent function of a value in a. The error bound of the returned value is 1.0 ULP for the double-precision function or 1.0001 ULP for the single-precision function. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_tanh_u35, Sleef_tanhf_u35 - hyperbolic tangent functions

Synopsis

#include <sleef.h>
double Sleef_tanh_u35(double a);
float Sleef_tanhf_u35(float a);
Link with -lsleef.

Description

These functions evaluates the hyperbolic tangent function of a value in a. The error bound of the returned value is 3.5 ULP for the double-precision function or 3.5 ULP for the single-precision function. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_asinh_u10, Sleef_asinhf_u10 - inverse hyperbolic sine functions

Synopsis

#include <sleef.h>
double Sleef_asinh_u10(double a);
float Sleef_asinhf_u10(float a);
Link with -lsleef.

Description

These functions evaluates the inverse hyperbolic sine function of a value in a. The error bound of the returned value is 1.0 ULP if a is in [-1.34e+154, 1.34e+154] for the double-precision function or 1.001 ULP if a is in [-1.84e+19, 1.84e+19] for the single-precision function . If a is a finite value out of this range, infinity with a correct sign or a correct value with 1.0 ULP error bound is returned. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_acosh_u10, Sleef_acoshf_u10 - inverse hyperbolic cosine functions

Synopsis

#include <sleef.h>
double Sleef_acosh_u10(double a);
float Sleef_acoshf_u10(float a);
Link with -lsleef.

Description

These functions evaluates the inverse hyperbolic cosine function of a value in a. The error bound of the returned value is 1.0 ULP if a is in [-1.34e+154, 1.34e+154] for the double-precision function or 1.001 ULP if a is in [-1.84e+19, 1.84e+19] for the single-precision function . If a is a finite value out of this range, infinity with a correct sign or a correct value with 1.0 ULP error bound is returned. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_atanh_u10, Sleef_atanhf_u10 - inverse hyperbolic tangent functions

Synopsis

#include <sleef.h>
double Sleef_atanh_u10(double a);
float Sleef_atanhf_u10(float a);
Link with -lsleef.

Description

These functions evaluates the inverse hyperbolic tangent function of a value in a. The error bound of the returned value is 1.0 ULP for the double-precision function or 1.0001 ULP for the single-precision function. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

## Error and gamma functions

Sleef_erf_u10, Sleef_erff_u10 - error functions with 1.0 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_erf_u10(double x);
float Sleef_erff_u10(float x);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of erf and erff functions. The error bound of the returned value is 1.0 ULP. These functions do not set errno nor raise an exception.

Sleef_erfc_u15, Sleef_erfcf_u15 - complementary error functions

Synopsis

#include <sleef.h>
double Sleef_erfc_u15(double x);
float Sleef_erfcf_u15(float x);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of erfc and erfcf functions. The error bound of the returned value for the DP function is max(1.5 ULP, DBL_MIN) if the argument is less than 26.2, and max(2.5 ULP, DBL_MIN) otherwise. For the SP function, the error bound is max(1.5 ULP, FLT_MIN). These functions do not set errno nor raise an exception.

Sleef_tgamma_u10, Sleef_tgammaf_u10 - gamma functions with 1.0 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_tgamma_u10(double x);
float Sleef_tgammaf_u10(float x);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of tgamma and tgammaf functions. The error bound of the returned value is 1.0 ULP. These functions do not set errno nor raise an exception.

Sleef_lgamma_u10, Sleef_lgammaf_u10 - log gamma functions with 1.0 ULP error bound

Synopsis

#include <sleef.h>
double Sleef_lgamma_u10(double x);
float Sleef_lgammaf_u10(float x);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of lgamma and lgammaf functions. The error bound of the returned value is 1.0 ULP if the argument is positive. If the argument is larger than 2e+305 for the DP function and 4e+36 for the SP function, it may return infinity instead of the correct value. The error bound is max(1 ULP, 1e-15) for the DP function and max(1 ULP and 1e-8) for the SP function, if the argument is negative. These functions do not set errno nor raise an exception.

## Nearest integer functions

Sleef_trunc, Sleef_truncf - round to integer towards zero

Synopsis

#include <sleef.h>
double Sleef_trunc(double x);
float Sleef_truncf(float x);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of trunc and truncf functions. These functions do not set errno nor raise an exception.

Sleef_floor, Sleef_floorf - round to integer towards minus infinity

Synopsis

#include <sleef.h>
double Sleef_floor(double x);
float Sleef_floorf(float x);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of floor and floorf functions. These functions do not set errno nor raise an exception.

Sleef_ceil, Sleef_ceilf - round to integer towards plus infinity

Synopsis

#include <sleef.h>
double Sleef_ceil(double x);
float Sleef_ceilf(float x);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of ceil and ceilf functions. These functions do not set errno nor raise an exception.

Sleef_round, Sleef_roundf - round to integer away from zero

Synopsis

#include <sleef.h>
double Sleef_round(double x);
float Sleef_roundf(float x);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of round and roundf functions. These functions do not set errno nor raise an exception.

Sleef_rint, Sleef_rintf - round to integer, ties round to even

Synopsis

#include <sleef.h>
double Sleef_rint(double x);
float Sleef_rintf(float x);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of rint and rintf functions. These functions do not set errno nor raise an exception.

## Other functions

Sleef_fma, Sleef_fmaf - fused multiply and accumulate

Synopsis

#include <sleef.h>
double Sleef_fma(double x, double y, double z);
float Sleef_fmaf(float x, float y, float z);
Link with -lsleef.

Description

These functions compute (x × y + z) without rounding, and then return the rounded value of the result. These functions may return infinity with a correct sign if the absolute value of the correct return value is greater than 1e+300 and 1e+33, respectively. The error bounds of the returned values are 0.5 ULP and max(0.50001 ULP, FLT_MIN), respectively.

Sleef_fmod, Sleef_fmodf - FP remainder

Synopsis

#include <sleef.h>
double Sleef_fmod(double x, double y);
float Sleef_fmodf(float x, float y);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of fmod and fmodf functions, if |x / y| is smaller than 1e+300 and 1e+38, respectively. The returned value is undefined, otherwise. These functions do not set errno nor raise an exception.

Sleef_ldexp, Sleef_ldexpf - multiply by integral power of 2

Synopsis

#include <sleef.h>
double Sleef_ldexp(double m, int x);
float Sleef_ldexpf(float m, int x);
Link with -lsleef.

Description

These functions return the result of multiplying m by 2 raised to the power x. These functions treat the non-number arguments and return non-numbers as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_frfrexp, Sleef_frfrexpf - fractional component of an FP number

Synopsis

#include <sleef.h>
double Sleef_frfrexp(double x);
float Sleef_frfrexpf(float x);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of frexp and frexpf functions. These functions do not set errno nor raise an exception.

Sleef_expfrexp, Sleef_expfrexpf - exponent of an FP number

Synopsis

#include <sleef.h>
int Sleef_expfrexp(double x);
int Sleef_expfrexpf(float x);
Link with -lsleef.

Description

These functions return the exponent returned by frexp and frexpf functions as specified in the C99 specification. These functions do not set errno nor raise an exception.

Sleef_ilogb, Sleef_ilogbf - integer exponent of an FP number

Synopsis

#include <sleef.h>
int Sleef_ilogb(double m, int x);
int Sleef_ilogbf(float m, int x);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of ilogb and ilogbf functions. These functions do not set errno nor raise an exception.

Sleef_modf, Sleef_modff - integral and fractional value of FP number

Synopsis

#include <sleef.h>
Sleef_double2 Sleef_modf(double x);
Sleef_float2 Sleef_modff(float x);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of modf and modff functions. These functions do not set errno nor raise an exception.

Sleef_fabs, Sleef_fabsf - absolute value

Synopsis

#include <sleef.h>
double Sleef_fabs(double x);
float Sleef_fabsf(float x);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of fabs and fabsf functions. These functions do not set errno nor raise an exception.

Sleef_fmax, Sleef_fmaxf - maximum of two numbers

Synopsis

#include <sleef.h>
double Sleef_fmax(double x, double y);
float Sleef_fmaxf(float x, float y);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of fmax and fmaxf functions. These functions do not set errno nor raise an exception.

Sleef_fmin, Sleef_fminf - minimum of two numbers

Synopsis

#include <sleef.h>
double Sleef_fmin(double x, double y);
float Sleef_fminf(float x, float y);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of fmin and fminf functions. These functions do not set errno nor raise an exception.

Sleef_fdim, Sleef_fdimf - positive difference

Synopsis

#include <sleef.h>
double Sleef_fdim(double x, double y);
float Sleef_fdimf(float x, float y);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of fdim and fdimf functions. These functions do not set errno nor raise an exception.

Sleef_copysign, Sleef_copysignf - copy sign of a number

Synopsis

#include <sleef.h>
double Sleef_copysign(double x, double y);
float Sleef_copysignf(float x, float y);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of copysign and copysignf functions. These functions do not set errno nor raise an exception.

Sleef_nextafter, Sleef_nextafterf - find the next representable FP value

Synopsis

#include <sleef.h>
double Sleef_nextafter(double x, double y);
float Sleef_nextafterf(float x, float y);
Link with -lsleef.

Description

These functions return the value as specified in the C99 specification of nextafter and nextafterf functions. These functions do not set errno nor raise an exception.