Documentation
¶
Overview ¶
Package libm provides transcendental math functions whose results match Neo4j's correctly rounded Java Math functions more closely than Go's standard library math package.
The exponential, logarithmic and power functions (Exp, Exp2, Log, Log2, Pow) are ported from musl's math library, which in turn carries the Arm optimized-routines implementations (Copyright (c) 2018, Arm Limited, SPDX-License-Identifier: MIT). These are correctly rounded except in rare documented cases, whereas Go's math package (derived from fdlibm) can be up to 1 ulp away for inputs such as 3 ^ 2.5.
The hyperbolic functions (Sinh, Cosh, Tanh, Asinh, Acosh, Atanh) are ported from musl's wrappers over its correctly rounded Exp and Log.
Sin, Cos, Tan, Asin, Acos, Atan, Atan2 and Log10 are fdlibm-derived in both musl and Go's math package, so they are thin aliases to the corresponding math functions: musl's implementations are the Sun Microsystems fdlibm sources, which is the same origin as Go's math package.
See NOTICES.md for the full third-party licence texts.
Sinh is a Go port of musl's double-precision sinh function, Copyright (c) 2018, Arm Limited. SPDX-License-Identifier: MIT. See NOTICES.md for the licence text.
The hyperbolic functions below are thin wrappers over musl's correctly rounded Exp and Log, following the musl source line by line.
Index ¶
- Constants
- func Abs(x float64) float64
- func Acos(x float64) float64
- func Acosh(x float64) float64
- func Asin(x float64) float64
- func Asinh(x float64) float64
- func Atan(x float64) float64
- func Atan2(y, x float64) float64
- func Atanh(x float64) float64
- func Ceil(x float64) float64
- func Copysign(x, y float64) float64
- func Cos(x float64) float64
- func Cosh(x float64) float64
- func Exp(x float64) float64
- func Exp2(x float64) float64
- func Expm1(x float64) float64
- func Float32bits(f float32) uint32
- func Float32frombits(b uint32) float32
- func Float64bits(f float64) uint64
- func Float64frombits(b uint64) float64
- func Floor(x float64) float64
- func Frexp(f float64) (frac float64, exp int)
- func Inf(sign int) float64
- func IsInf(x float64, sign int) bool
- func IsNaN(x float64) bool
- func Ldexp(frac float64, exp int) float64
- func Log(x float64) float64
- func Log1p(x float64) float64
- func Log2(x float64) float64
- func Log10(x float64) float64
- func Max(x, y float64) float64
- func Min(x, y float64) float64
- func Mod(x, y float64) float64
- func Modf(f float64) (int, frac float64)
- func NaN() float64
- func Pow(x, y float64) float64
- func Pow10(n int) float64
- func Round(x float64) float64
- func RoundToEven(x float64) float64
- func Signbit(x float64) bool
- func Sin(x float64) float64
- func Sinh(x float64) float64
- func Sqrt(x float64) float64
- func Tan(x float64) float64
- func Tanh(x float64) float64
- func Trunc(x float64) float64
Constants ¶
const ( E = math.E Pi = math.Pi Phi = math.Phi Sqrt2 = math.Sqrt2 SqrtE = math.SqrtE SqrtPi = math.SqrtPi SqrtPhi = math.SqrtPhi Ln2 = math.Ln2 Log2E = math.Log2E Ln10 = math.Ln10 Log10E = math.Log10E MaxFloat64 = math.MaxFloat64 SmallestNonzeroFloat64 = math.SmallestNonzeroFloat64 MaxInt8 = math.MaxInt8 MinInt8 = math.MinInt8 MaxInt16 = math.MaxInt16 MinInt16 = math.MinInt16 MaxInt32 = math.MaxInt32 MinInt32 = math.MinInt32 MaxInt64 = math.MaxInt64 MinInt64 = math.MinInt64 MaxUint8 = math.MaxUint8 MaxUint16 = math.MaxUint16 MaxUint32 = math.MaxUint32 MaxUint64 = math.MaxUint64 MaxUint = math.MaxUint )
Variables ¶
This section is empty.
Functions ¶
func Abs ¶
Exact and trivial functions: re-exported from the standard library. These are correctly rounded (or exact) by construction, so they never differ from Neo4j's results.
func Float32bits ¶
func Float32frombits ¶
func Float64bits ¶
func Float64frombits ¶
func Log1p ¶
Log1p and Expm1 are re-exported from the standard library. Sin, Cos, Tan, Asin, Acos, Atan, Atan2 and Log10 are ported from musl (trig.go, invtrig.go): Go's sin, cos, tan and atan come from Cephes, not fdlibm, and differed from Neo4j's results for a quarter to a third of inputs (#907).
func RoundToEven ¶
Types ¶
This section is empty.