Search documentation of stdlib

# View Source math (stdlib v6.2.2.3)

Mathematical functions.

This module provides an interface to a number of mathematical functions. For details about what each function does, see the the C library documentation on your system. On Unix systems the easiest way it to run `man sin`. On Windows you should check the Math and floating-point support documentation.

## Limitations

As these are the C library, the same limitations apply.

# Summary

## Functions

acos(X)

Inverse cosine of `X`, return value is in radians.

acosh(X)

Inverse hyperbolic cosine of `X`.

asin(X)

Inverse sine of `X`, return value is in radians.

asinh(X)

Inverse hyperbolic sine of `X`.

atan2(Y, X)

Inverse 2-argument tangent of `X`, return value is in radians.

atan(X)

Inverse tangent of `X`, return value is in radians.

atanh(X)

Inverse hyperbolic tangent of `X`.

ceil(X)

The ceiling of `X`.

cos(X)

The cosine of `X` in radians.

cosh(X)

The hyperbolic cosine of `X`.

erf(X)

Returns the error function (or Gauss error function) of `X`.

erfc(X)

`erfc(X)` returns `1.0` - `erf(X)`, computed by methods that avoid cancellation for large `X`.

exp(X)

Raise e by `X`, that is `eˣ`.

floor(X)

The floor of `X`.

fmod(X, Y)

Returns `X` modulus `Y`.

log2(X)

The base-2 logarithm of `X`.

log10(X)

The base-10 logarithm of `X`.

log(X)

The natural (base-e) logarithm of `X`.

pi()

Ratio of the circumference of a circle to its diameter.

pow(X, N)

Raise `X` by `N`, that is `xⁿ`.

sin(X)

Sine of `X` in radians.

sinh(X)

Hyperbolic sine of `X`.

sqrt(X)

Square root of `X`.

tan(X)

Tangent of `X` in radians.

tanh(X)

Hyperbolic tangent of `X`.

tau()

Ratio of the circumference of a circle to its radius.

# Functions

# acos(X)

    -spec acos(X) -> float() when X :: number().

Inverse cosine of `X`, return value is in radians.

# acosh(X)

    -spec acosh(X) -> float() when X :: number().

Inverse hyperbolic cosine of `X`.

# asin(X)

    -spec asin(X) -> float() when X :: number().

Inverse sine of `X`, return value is in radians.

# asinh(X)

    -spec asinh(X) -> float() when X :: number().

Inverse hyperbolic sine of `X`.

# atan2(Y, X)

    -spec atan2(Y, X) -> float() when Y :: number(), X :: number().

Inverse 2-argument tangent of `X`, return value is in radians.

# atan(X)

    -spec atan(X) -> float() when X :: number().

Inverse tangent of `X`, return value is in radians.

# atanh(X)

    -spec atanh(X) -> float() when X :: number().

Inverse hyperbolic tangent of `X`.

# ceil(X)

(since OTP 20.0)

    -spec ceil(X) -> float() when X :: number().

The ceiling of `X`.

# cos(X)

    -spec cos(X) -> float() when X :: number().

The cosine of `X` in radians.

# cosh(X)

    -spec cosh(X) -> float() when X :: number().

The hyperbolic cosine of `X`.

# erf(X)

    -spec erf(X) -> float() when X :: number().

Returns the error function (or Gauss error function) of `X`.

Where:

    erf(X) = 2/sqrt(pi)*integral from 0 to X of exp(-t*t) dt.

# erfc(X)

    -spec erfc(X) -> float() when X :: number().

`erfc(X)` returns `1.0` - `erf(X)`, computed by methods that avoid cancellation for large `X`.

# exp(X)

    -spec exp(X) -> float() when X :: number().

Raise e by `X`, that is `eˣ`.

Where e is the base of the natural logarithm.

# floor(X)

(since OTP 20.0)

    -spec floor(X) -> float() when X :: number().

The floor of `X`.

# fmod(X, Y)

(since OTP 20.0)

    -spec fmod(X, Y) -> float() when X :: number(), Y :: number().

Returns `X` modulus `Y`.

# log2(X)

(since OTP 18.0)

    -spec log2(X) -> float() when X :: number().

The base-2 logarithm of `X`.

# log10(X)

    -spec log10(X) -> float() when X :: number().

The base-10 logarithm of `X`.

# log(X)

    -spec log(X) -> float() when X :: number().

The natural (base-e) logarithm of `X`.

# pi()

    -spec pi() -> float().

Ratio of the circumference of a circle to its diameter.

Floating point approximation of mathematical constant pi.

# pow(X, N)

    -spec pow(X, N) -> float() when X :: number(), N :: number().

Raise `X` by `N`, that is `xⁿ`.

# sin(X)

    -spec sin(X) -> float() when X :: number().

Sine of `X` in radians.

# sinh(X)

    -spec sinh(X) -> float() when X :: number().

Hyperbolic sine of `X`.

# sqrt(X)

    -spec sqrt(X) -> float() when X :: number().

Square root of `X`.

# tan(X)

    -spec tan(X) -> float() when X :: number().

Tangent of `X` in radians.

# tanh(X)

    -spec tanh(X) -> float() when X :: number().

Hyperbolic tangent of `X`.

# tau()

(since OTP 26.0)

    -spec tau() -> float().

Ratio of the circumference of a circle to its radius.

This constant is equivalent to a full turn when described in radians.

The same as `2 * pi()`.