Exponentials and logarithms v0.1.0

Source
Powers of e and two, and logarithms in base e, two and ten.

Exp

pub func Exp(x: float64) -> float64
pub func Exp(x: float32) -> float32

Computes e raised to x. The error is at most one ulp. Positive infinity returns positive infinity, negative infinity returns +0.0, and a NaN remains a NaN. Finite results overflow to infinity or underflow to zero when required by float64.

OverloadSummary
pub func Exp(x: float64) -> float64Computes e raised to x.
pub func Exp(x: float32) -> float32Computes e raised to x at float32 precision.

Source

Parameters

NameTypeDescription
xfloat64 / float32exponent

Returns: e raised to x

Exp2

pub func Exp2(x: float64) -> float64
pub func Exp2(x: float32) -> float32

Computes two raised to x. The error is at most one ulp, and an in-range integer exponent is exact. Positive infinity returns positive infinity, negative infinity returns zero, and a NaN remains a NaN.

OverloadSummary
pub func Exp2(x: float64) -> float64Computes two raised to x.
pub func Exp2(x: float32) -> float32Computes two raised to x at float32 precision.

Source

Parameters

NameTypeDescription
xfloat64 / float32binary exponent

Returns: two raised to x

Expm1

pub func Expm1(x: float64) -> float64
pub func Expm1(x: float32) -> float32

Computes Exp(x) - 1 without losing precision near zero. The error is at most one ulp and remains small relative to the result as x approaches zero. A signed zero returns itself, positive infinity returns positive infinity, negative infinity returns -1.0, and a NaN remains a NaN.

OverloadSummary
pub func Expm1(x: float64) -> float64Computes Exp(x) - 1 without losing precision near zero.
pub func Expm1(x: float32) -> float32Computes Exp(x) - 1 at float32 precision without losing precision near zero.

Source

Parameters

NameTypeDescription
xfloat64 / float32exponent

Returns: e raised to x, minus one

Log

pub func Log(x: float64) -> float64
pub func Log(x: float32) -> float32

Computes the natural logarithm of x. The error is at most one ulp. Either signed zero returns negative infinity, a negative value returns a NaN, positive infinity returns itself, and a NaN remains a NaN.

OverloadSummary
pub func Log(x: float64) -> float64Computes the natural logarithm of x.
pub func Log(x: float32) -> float32Computes the natural logarithm of x at float32 precision.

Source

Parameters

NameTypeDescription
xfloat64 / float32positive value whose logarithm is computed

Returns: the base-e logarithm of x

Log10

pub func Log10(x: float64) -> float64
pub func Log10(x: float32) -> float32

Computes the base-ten logarithm of x. The error is at most one ulp, and an exact power of ten returns its exact exponent. Either signed zero returns negative infinity, a negative value returns a NaN, positive infinity returns itself, and a NaN remains a NaN.

OverloadSummary
pub func Log10(x: float64) -> float64Computes the base-ten logarithm of x.
pub func Log10(x: float32) -> float32Computes the base-ten logarithm of x at float32 precision.

Source

Parameters

NameTypeDescription
xfloat64 / float32positive value whose logarithm is computed

Returns: the base-ten logarithm of x

Log1p

pub func Log1p(x: float64) -> float64
pub func Log1p(x: float32) -> float32

Computes Log(1 + x) without losing precision near zero. Log1p(0.0) is zero with the argument's sign, Log1p(-1.0) is negative infinity, and an argument below -1 has no real logarithm and gives a NaN.

OverloadSummary
pub func Log1p(x: float64) -> float64Computes Log(1 + x) without losing precision near zero.
pub func Log1p(x: float32) -> float32Computes Log(1 + x) at float32 precision without losing precision near zero.

Source

Parameters

NameTypeDescription
xfloat64 / float32value added to one before taking the logarithm

Returns: the natural logarithm of 1 + x

Log2

pub func Log2(x: float64) -> float64
pub func Log2(x: float32) -> float32

Computes the base-two logarithm of x. The error is at most one ulp, and an exact power of two returns its exact exponent. Either signed zero returns negative infinity, a negative value returns a NaN, positive infinity returns itself, and a NaN remains a NaN.

OverloadSummary
pub func Log2(x: float64) -> float64Computes the base-two logarithm of x.
pub func Log2(x: float32) -> float32Computes the base-two logarithm of x at float32 precision.

Source

Parameters

NameTypeDescription
xfloat64 / float32positive value whose logarithm is computed

Returns: the base-two logarithm of x