# `<math.h>`

```HUGE_VAL ```

```abs · acos · asin · atan · atan2 · ceil · cos · cosh · exp · fabs · floor · fmod · frexp · ldexp · log · log10 · modf · pow · sin · sinh · sqrt · tan · tanh ```

```acosf · asinf · atanf · atan2f · ceilf · cosf · coshf · expf · fabsf · floorf · fmodf · frexpf · ldexpf · logf · log10f · modff · pow · sinf · sinhf · sqrtf · tanf · tanhf ```

```acosl · asinl · atanl · atan2l · ceill · cosl · coshl · expl · fabsl · floorl · fmodl · frexpl · ldexpl · logl · log10l · modfl · pow · sinl · sinhl · sqrtl · tanl · tanhl ```

Include the standard header `<math.h>` to declare a number of functions that perform common mathematical operations on real floating-point values (of type float, double, or long double).

A domain error occurs when the function is not defined for its input argument value or values. A function can report a domain error by storing the value of `EDOM` in `errno` and returning a particular value defined for each implementation.

A range error occurs when the return value of the function is defined but cannot be represented. A function can report a range error by storing the value of `ERANGE` in `errno` and returning one of several values:

• `HUGE_VAL` -- if the value of a function returning double is positive and too large in magnitude to represent
• `-HUGE_VAL` -- if the value of a function returning double is negative and too large in magnitude to represent
• zero -- if the value of the function is too small to represent with a finite value
```    /* MACROS */
#define HUGE_VAL <double rvalue>

/* FUNCTIONS */
double abs(double x); [C++ only]
float abs(float x); [C++ only]
long double abs(long double x); [C++ only]

double acos(double x);
float acos(float x); [C++ only]
long double acos(long double x); [C++ only]
float acosf(float x); [required with C99]
long double acosl(long double x); [required with C99]

double asin(double x);
float asin(float x); [C++ only]
long double asin(long double x); [C++ only]
float asinf(float x); [required with C99]
long double asinl(long double x); [required with C99]

double atan(double x);
float atan(float x); [C++ only]
long double atan(long double x); [C++ only]
float atanf(float x); [required with C99]
long double atanl(long double x); [required with C99]

double atan2(double y, double x);
float atan2(float y, float x); [C++ only]
long double atan2(long double y, long double x); [C++ only]
float atan2f(float y, float x); [required with C99]
long double atan2l(long double y,
long double x); [required with C99]

double ceil(double x);
float ceil(float x); [C++ only]
long double ceil(long double x); [C++ only]
float ceilf(float x); [required with C99]
long double ceill(long double x); [required with C99]

double cos(double x);
float cos(float x); [C++ only]
long double cos(long double x); [C++ only]
float cosf(float x); [required with C99]
long double cosl(long double x); [required with C99]

double cosh(double x);
float cosh(float x); [C++ only]
long double cosh(long double x); [C++ only]
float coshf(float x); [required with C99]
long double coshl(long double x); [required with C99]

double exp(double x);
float exp(float x); [C++ only]
long double exp(long double x); [C++ only]
float expf(float x); [required with C99]
long double expl(long double x); [required with C99]

double fabs(double x);
float fabs(float x); [C++ only]
long double fabs(long double x); [C++ only]
float fabsf(float x); [required with C99]
long double fabsl(long double x); [required with C99]

double floor(double x);
float floor(float x); [C++ only]
long double floor(long double x); [C++ only]
float floorf(float x); [required with C99]
long double floorl(long double x); [required with C99]

double fmod(double x, double y);
float fmod(float x, float y); [C++ only]
long double fmod(long double x, long double y); [C++ only]
float fmodf(float x, float y); [required with C99]
long double fmodl(long double x,
long double y); [required with C99]

double frexp(double x, int *pexp);
float frexp(float x, int *pexp); [C++ only]
long double frexp(long double x, int *pexp); [C++ only]
float frexpf(float x, int *pexp); [required with C99]
long double frexpl(long double x, int *pexp); [required with C99]

double ldexp(double x, int ex);
float ldexp(float x, int ex); [C++ only]
long double ldexp(long double x, int ex); [C++ only]
float ldexpf(float x, int ex); [required with C99]
long double ldexpl(long double x, int ex); [required with C99]

double log(double x);
float log(float x); [C++ only]
long double log(long double x); [C++ only]
float logf(float x); [required with C99]
long double logl(long double x); [required with C99]

double log10(double x);
float log10(float x); [C++ only]
long double log10(long double x); [C++ only]
float log10f(float x); [required with C99]
long double log10l(long double x); [required with C99]

double modf(double x, double *pint);
float modf(float x, float *pint); [C++ only]
long double modf(long double x,
long double *pint); [C++ only]
float modff(float x, float *pint); [required with C99]
long double modfl(long double x,
long double *pint); [required with C99]

double pow(double x, double y);
float pow(float x, float y); [C++ only]
long double pow(long double x, long double y); [C++ only]
double pow(double x, int y); [C++ only]
float pow(float x, int y); [C++ only]
long double pow(long double x, int y); [C++ only]
float powf(float x, float y); [required with C99]
long double powl(long double x,
long double y); [required with C99]

double sin(double x);
float sin(float x); [C++ only]
long double sin(long double x); [C++ only]
float sinf(float x); [required with C99]
long double sinl(long double x); [required with C99]

double sinh(double x);
float sinh(float x); [C++ only]
long double sinh(long double x); [C++ only]
float sinhf(float x); [required with C99]
long double sinhl(long double x); [required with C99]

double sqrt(double x);
float sqrt(float x); [C++ only]
long double sqrt(long double x); [C++ only]
float sqrtf(float x); [required with C99]
long double sqrtl(long double x); [required with C99]

double tan(double x);
float tan(float x); [C++ only]
long double tan(long double x); [C++ only]
float tanf(float x); [required with C99]
long double tanl(long double x); [required with C99]

double tanh(double x);
float tanh(float x); [C++ only]
long double tanh(long double x); [C++ only]
float tanhf(float x); [required with C99]
long double tanhl(long double x); [required with C99]
```

## `abs`, `fabs`, `fabsf`, `fabsl`

```double abs(double x); [C++ only]
float abs(float x); [C++ only]
long double abs(long double x); [C++ only]
double fabs(double x);
float fabs(float x); [C++ only]
long double fabs(long double x); [C++ only]
float fabsf(float x); [required with C99]
long double fabsl(long double x); [required with C99]```

The function returns the magnitude of `x`, `|x|`.

## `acos`, `acosf`, `acosl`

```double acos(double x);
float acos(float x); [C++ only]
long double acos(long double x); [C++ only]
float acosf(float x); [required with C99]
long double acosl(long double x); [required with C99]```

The function returns the angle whose cosine is `x`, in the range [0, pi] radians. A domain error occurs if `1 < |x|`.

## `asin`, `asinf`, `asinl`

```double asin(double x);
float asin(float x); [C++ only]
long double asin(long double x); [C++ only]
float asinf(float x); [required with C99]
long double asinl(long double x); [required with C99]```

The function returns the angle whose sine is `x`, in the range [-pi/2, +pi/2] radians. A domain error occurs if `1 < |x|`.

## `atan`, `atanf`, `atanl`

```double atan(double x);
float atan(float x); [C++ only]
long double atan(long double x); [C++ only]
float atanf(float x); [required with C99]
long double atanl(long double x); [required with C99]```

The function returns the angle whose tangent is `x`, in the range [-pi/2, +pi/2] radians.

## `atan2`, `atan2f`, `atan2l`

```double atan2(double y, double x);
float atan2(float y, float x); [C++ only]
long double atan2(long double y, long double x); [C++ only]
float atan2f(float y, float x); [required with C99]
long double atan2l(long double y,
long double x); [required with C99]```

The function returns the angle whose tangent is `y/x`, in the full angular range [-pi, +pi] radians. A domain error may occur if both `x` and `y` are zero.

## `ceil`, `ceilf`, `ceill`

```double ceil(double x);
float ceil(float x); [C++ only]
long double ceil(long double x); [C++ only]
float ceilf(float x); [required with C99]
long double ceill(long double x); [required with C99]```

The function returns the smallest integer value not less than `x`.

## `cos`, `cosf`, `cosl`

```double cos(double x);
float cos(float x); [C++ only]
long double cos(long double x); [C++ only]
float cosf(float x); [required with C99]
long double cosl(long double x); [required with C99]```

The function returns the cosine of `x`. If `x` is large the value returned might not be meaningful, but the function reports no error.

## `cosh`, `coshf`, `coshl`

```double cosh(double x);
float cosh(float x); [C++ only]
long double cosh(long double x); [C++ only]
float coshf(float x); [required with C99]
long double coshl(long double x); [required with C99]```

The function returns the hyperbolic cosine of `x`.

## `exp`, `expf`, `expl`

```double exp(double x);
float exp(float x); [C++ only]
long double exp(long double x); [C++ only]
float expf(float x); [required with C99]
long double expl(long double x); [required with C99]```

The function returns the exponential of `x`, e^`x`.

## `floor`, `floorf`, `floorl`

```double floor(double x);
float floor(float x); [C++ only]
long double floor(long double x); [C++ only]
float floorf(float x); [required with C99]
long double floorl(long double x); [required with C99]```

The function returns the largest integer value not greater than `x`.

## `fmod`, `fmodf`, `fmodl`

```double fmod(double x, double y);
float fmod(float x, float y); [C++ only]
long double fmod(long double x, long double y); [C++ only]
float fmodf(float x, float y); [required with C99]
long double fmodl(long double x,
long double y); [required with C99]```

The function returns the remainder of `x/y`, which is defined as follows:

• If `y` is zero, the function either reports a domain error or simply returns zero.
• Otherwise, the function determines the unique signed integer value `i` such that the returned value `x - i * y` has the same sign as `x` and magnitude less than `|y|`.

## `frexp`, `frexpf`, `frexpl`

```double frexp(double x, int *pexp);
float frexp(float x, int *pexp); [C++ only]
long double frexp(long double x, int *pexp); [C++ only]
float frexpf(float x, int *pexp); [required with C99]
long double frexpl(long double x, int *pexp); [required with C99]```

The function determines a fraction `frac` and an exponent integer `ex` that represent the value of `x`. It returns the value `frac` and stores the integer `ex` in `*pexp`, such that:

• `|frac|` is in the interval [1/2, 1) or is zero
• `x == frac * 2^ex`

If `x` is zero, `*pexp` is also zero.

## `HUGE_VAL`

`#define HUGE_VAL <double rvalue>`

The macro yields the double value returned by some functions on a range error. The value can be a representation of infinity.

## `ldexp`, `ldexpf`, `ldexpl`

```double ldexp(double x, int ex);
float ldexp(float x, int ex); [C++ only]
long double ldexp(long double x, int ex); [C++ only]
float ldexpf(float x, int ex); [required with C99]
long double ldexpl(long double x, int ex); [required with C99]```

The function returns `x * 2^ex`.

## `log`, `logf`, `logl`

```double log(double x);
float log(float x); [C++ only]
long double log(long double x); [C++ only]
float logf(float x); [required with C99]
long double logl(long double x); [required with C99]```

The function returns the natural logarithm of `x`. A domain error occurs if `x < 0`.

## `log10`, `log10f`, `log10l`

```double log10(double x);
float log10(float x); [C++ only]
long double log10(long double x); [C++ only]
float log10f(float x); [required with C99]
long double log10l(long double x); [required with C99]```

The function returns the base-10 logarithm of `x`. A domain error occurs if `x < 0`.

## `modf`, `modff`, `modfl`

```double modf(double x, double *pint);
float modf(float x, float *pint); [C++ only]
long double modf(long double x,
long double *pint); [C++ only]
float modff(float x, float *pint); [required with C99]
long double modfl(long double x,
long double *pint); [required with C99]```

The function determines an integer `i` plus a fraction `frac` that represent the value of `x`. It returns the value `frac` and stores the integer `i` in `*pint`, such that:

• `x == frac + i`
• `|frac|` is in the interval [0, 1)
• both `frac` and `i` have the same sign as `x`

## `pow`, `powf`, `powl`

```double pow(double x, double y);
float pow(float x, float y); [C++ only]
long double pow(long double x, long double y); [C++ only]
double pow(double x, int y); [C++ only]
float pow(float x, int y); [C++ only]
long double pow(long double x, int y); [C++ only]
float powf(float x, float y); [required with C99]
long double powl(long double x,
long double y); [required with C99]```

The function returns `x` raised to the power `y`, `x^y`.

## `sin`, `sinf`, `sinl`

```double sin(double x);
float sin(float x); [C++ only]
long double sin(long double x); [C++ only]
float sinf(float x); [required with C99]
long double sinl(long double x); [required with C99]```

The function returns the sine of `x`. If `x` is large the value returned might not be meaningful, but the function reports no error.

## `sinh`, `sinhf`, `sinhl`

```double sinh(double x);
float sinh(float x); [C++ only]
long double sinh(long double x); [C++ only]
float sinhf(float x); [required with C99]
long double sinhl(long double x); [required with C99]```

The function returns the hyperbolic sine of `x`.

## `sqrt`, `sqrtf`, `sqrtl`

```double sqrt(double x);
float sqrt(float x); [C++ only]
long double sqrt(long double x); [C++ only]
float sqrtf(float x); [required with C99]
long double sqrtl(long double x); [required with C99]```

The function returns the real square root of `x`, `x^(1/2)`. A domain error occurs if `x < 0`.

## `tan`, `tanf`, `tanl`

```double tan(double x);
float tan(float x); [C++ only]
long double tan(long double x); [C++ only]
float tanf(float x); [required with C99]
long double tanl(long double x); [required with C99]```

The function returns the tangent of `x`. If `x` is large the value returned might not be meaningful, but the function reports no error.

## `tanh`, `tanhf`, `tanhl`

```double tanh(double x);
float tanh(float x); [C++ only]
long double tanh(long double x); [C++ only]
float tanhf(float x); [required with C99]
long double tanhl(long double x); [required with C99]```

The function returns the hyperbolic tangent of `x`.