math — stdlib v6.0

Search documentation of stdlib

# View Source math (stdlib v6.0)

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

Link to this function

# acos(X)

View Source

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

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

Link to this function

# acosh(X)

View Source

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

Inverse hyperbolic cosine of `X`.

Link to this function

# asin(X)

View Source

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

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

Link to this function

# asinh(X)

View Source

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

Inverse hyperbolic sine of `X`.

Link to this function

# atan2(Y, X)

View Source

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

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

Link to this function

# atan(X)

View Source

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

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

Link to this function

# atanh(X)

View Source

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

Inverse hyperbolic tangent of `X`.

Link to this function

# ceil(X)

View Source (since OTP 20.0)

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

The ceiling of `X`.

Link to this function

# cos(X)

View Source

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

The cosine of `X` in radians.

Link to this function

# cosh(X)

View Source

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

The hyperbolic cosine of `X`.

Link to this function

# erf(X)

View Source

    -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.

Link to this function

# erfc(X)

View Source

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

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

Link to this function

# exp(X)

View Source

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

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

Where e is the base of the natural logarithm.

Link to this function

# floor(X)

View Source (since OTP 20.0)

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

The floor of `X`.

Link to this function

# fmod(X, Y)

View Source (since OTP 20.0)

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

Returns `X` modulus `Y`.

Link to this function

# log2(X)

View Source (since OTP 18.0)

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

The base-2 logarithm of `X`.

Link to this function

# log10(X)

View Source

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

The base-10 logarithm of `X`.

Link to this function

# log(X)

View Source

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

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

Link to this function

# pi()

View Source

    -spec pi() -> float().

Ratio of the circumference of a circle to its diameter.

Floating point approximation of mathematical constant pi.

Link to this function

# pow(X, N)

View Source

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

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

Link to this function

# sin(X)

View Source

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

Sine of `X` in radians.

Link to this function

# sinh(X)

View Source

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

Hyperbolic sine of `X`.

Link to this function

# sqrt(X)

View Source

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

Square root of `X`.

Link to this function

# tan(X)

View Source

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

Tangent of `X` in radians.

Link to this function

# tanh(X)

View Source

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

Hyperbolic tangent of `X`.

Link to this function

# tau()

View Source (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()`.