Exponentials and logarithms v0.1.0
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.
| Overload | Summary |
|---|---|
pub func Exp(x: float64) -> float64 | Computes e raised to x. |
pub func Exp(x: float32) -> float32 | Computes e raised to x at float32 precision. |
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 / float32 | exponent |
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.
| Overload | Summary |
|---|---|
pub func Exp2(x: float64) -> float64 | Computes two raised to x. |
pub func Exp2(x: float32) -> float32 | Computes two raised to x at float32 precision. |
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 / float32 | binary 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.
| Overload | Summary |
|---|---|
pub func Expm1(x: float64) -> float64 | Computes Exp(x) - 1 without losing precision near zero. |
pub func Expm1(x: float32) -> float32 | Computes Exp(x) - 1 at float32 precision without losing precision near zero. |
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 / float32 | exponent |
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.
| Overload | Summary |
|---|---|
pub func Log(x: float64) -> float64 | Computes the natural logarithm of x. |
pub func Log(x: float32) -> float32 | Computes the natural logarithm of x at float32 precision. |
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 / float32 | positive 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.
| Overload | Summary |
|---|---|
pub func Log10(x: float64) -> float64 | Computes the base-ten logarithm of x. |
pub func Log10(x: float32) -> float32 | Computes the base-ten logarithm of x at float32 precision. |
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 / float32 | positive 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.
| Overload | Summary |
|---|---|
pub func Log1p(x: float64) -> float64 | Computes Log(1 + x) without losing precision near zero. |
pub func Log1p(x: float32) -> float32 | Computes Log(1 + x) at float32 precision without losing precision near zero. |
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 / float32 | value 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.
| Overload | Summary |
|---|---|
pub func Log2(x: float64) -> float64 | Computes the base-two logarithm of x. |
pub func Log2(x: float32) -> float32 | Computes the base-two logarithm of x at float32 precision. |
Parameters
| Name | Type | Description |
|---|---|---|
x | float64 / float32 | positive value whose logarithm is computed |
Returns: the base-two logarithm of x