math

package module
v0.0.0-...-27f1cf3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2025 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package math mostly provides genericized wrappers around the standard math library. Some functions have different behaviors from the math library to be more compliant with the IEEE-754 standard.

This package does not guarantee bit-identical results across architectures.

Index

Constants

View Source
const (
	E   = math.E                                                           // 2.71828182845904523536028747135266249775724709369995957496696763 https://oeis.org/A001113
	Pi  = math.Pi                                                          // 3.14159265358979323846264338327950288419716939937510582097494459 https://oeis.org/A000796
	Phi = math.Phi                                                         // 1.61803398874989484820458683436563811772030917980576286213544862 https://oeis.org/A001622
	Tau = 6.28318530717958647692528676655900576839433879875021164194988918 // https://oeis.org/A019692

	Sqrt2   = math.Sqrt2                                                       // 1.41421356237309504880168872420969807856967187537694807317667974 https://oeis.org/A002193
	SqrtE   = math.SqrtE                                                       // 1.64872127070012814684865078781416357165377610071014801157507931 https://oeis.org/A019774
	SqrtPi  = math.SqrtPi                                                      // 1.77245385090551602729816748334114518279754945612238712821380779 https://oeis.org/A002161
	SqrtPhi = math.SqrtPhi                                                     // 1.27201964951406896425242246173749149171560804184009624861664038 https://oeis.org/A139339
	SqrtTau = 2.50662827463100050241576528481104525300698674060993831662992358 // https://oeis.org/A019727

	Ln2    = math.Ln2    // 0.693147180559945309417232121458176568075500134360255254120680009 https://oeis.org/A002162
	Log2E  = math.Log2E  // 1 / Ln2
	Ln10   = math.Ln10   // 2.30258509299404568401799145468436420760110148862877297603332790 https://oeis.org/A002392
	Log10E = math.Log10E // 1 / Ln10
)

Mathematical constants.

View Source
const (
	MaxFloat32             = math.MaxFloat32             // 3.40282346638528859811704183484516925440e+38
	SmallestNormalFloat32  = 0x1p-126                    // 1.175494350822287507968736537222245677819e-38
	SmallestNonzeroFloat32 = math.SmallestNonzeroFloat32 // 1.401298464324817070923729583289916131280e-45

	MaxFloat64             = math.MaxFloat64             // 1.79769313486231570814527423731704356798070e+308
	SmallestNormalFloat64  = 0x1p-1022                   // 2.2250738585072013830902327173324040642192160e-308
	SmallestNonzeroFloat64 = math.SmallestNonzeroFloat64 // 4.9406564584124654417656879286822137236505980e-324
)

Floating-point limit values. Max is the largest finite value representable by the type. SmallestNormal is the smallest positive, non-subnormal value representable by the type. SmallestNonzero is the smallest positive, non-zero value representable by the type.

View Source
const (
	MaxInt   = math.MaxInt   // MaxInt32 or MaxInt64 depending on intSize.
	MinInt   = math.MinInt   // MinInt32 or MinInt64 depending on intSize.
	MaxInt8  = math.MaxInt8  // 127
	MinInt8  = math.MinInt8  // 128
	MaxInt16 = math.MaxInt16 // 32767
	MinInt16 = math.MinInt16 // -32768
	MaxInt32 = math.MaxInt32 // 2147483647
	MinInt32 = math.MinInt32 // -2147483648
	MaxInt64 = math.MaxInt64 // 9223372036854775807
	MinInt64 = math.MinInt64 // -9223372036854775808

	MaxUint   = math.MaxUint   // MaxUint32 or MaxUint64 depending on intSize.
	MaxUint8  = math.MaxUint8  // 255
	MaxUint16 = math.MaxUint16 // 65535
	MaxUint32 = math.MaxUint32 // 4294967295
	MaxUint64 = math.MaxUint64 // 18446744073709551615
)

Integer limit values.

Variables

This section is empty.

Functions

func Abs

func Abs[FLOAT Float](x FLOAT) FLOAT

Abs returns the absolute value of x.

Special cases are:

Abs(±Inf) = +Inf
Abs(NaN)  = NaN

func Acos

func Acos[FLOAT Float](x FLOAT) (θ FLOAT)

Acos returns the arccosine, in radians, of x.

Special case is:

Acos(x) = NaN if x < -1 or x > 1

func Acosh

func Acosh[FLOAT Float](x FLOAT) (θ FLOAT)

Acosh returns the inverse hyperbolic cosine of x.

Special cases are:

Acosh(+Inf) = +Inf
Acosh(x)    = NaN if x < 1
Acosh(NaN)  = NaN

func Asin

func Asin[FLOAT Float](x FLOAT) (θ FLOAT)

Asin returns the arcsine, in radians, of x.

Special cases are:

Asin(±0) = ±0
Asin(x) = NaN if x < -1 or x > 1

func Asinh

func Asinh[FLOAT Float](x FLOAT) (θ FLOAT)

Asinh returns the inverse hyperbolic sine of x.

Special cases are:

Asinh(±0)   = ±0
Asinh(±Inf) = ±Inf
Asinh(NaN)  = NaN

func Atan

func Atan[FLOAT Float](x FLOAT) (θ FLOAT)

Atan returns the arctangent, in radians, of x.

Special cases are:

Atan(±0) = ±0
Atan(±Inf) = ±Pi/2

func Atan2

func Atan2[FLOAT Float](y, x FLOAT) (θ FLOAT)

Atan2 returns the arc tangent of y/x, using the signs of the two to determine the quadrant of the return value.

Special cases are (in order):

Atan2(y, NaN)     = NaN
Atan2(NaN, x)     = NaN
Atan2(+0, x>=0)   = +0
Atan2(-0, x>=0)   = -0
Atan2(+0, x<=-0)  = +τ/2
Atan2(-0, x<=-0)  = -τ/2
Atan2(y>0, 0)     = +τ/4
Atan2(y<0, 0)     = -τ/4
Atan2(+Inf, +Inf) = +τ/8
Atan2(-Inf, +Inf) = -τ/8
Atan2(+Inf, -Inf) = 3τ/8
Atan2(-Inf, -Inf) = -3τ/8
Atan2(y, +Inf)    = 0
Atan2(y>0, -Inf)  = +τ/2
Atan2(y<0, -Inf)  = -τ/2
Atan2(+Inf, x)    = +τ/4
Atan2(-Inf, x)    = -τ/4

func Atanh

func Atanh[FLOAT Float](x FLOAT) (θ FLOAT)

Atanh returns the inverse hyperbolic tangent of x.

Special cases are:

Atanh(1)  = +Inf
Atanh(±0) = ±0
Atanh(-1) = -Inf
Atanh(x)  = NaN if x < -1 or x > 1

func Bits

func Bits[UINT uint32 | uint64, FLOAT Float](f FLOAT) UINT

Bits returns the IEEE 754 binary representation of f, with the sign bit of f and the result in the same bit position, and Bits[UINT](FromBits[FLOAT](x)) == x.

func Bits32

func Bits32(x float32) uint32

Bits32 returns the IEEE 754 binary representation of f, with the sign bit of f and the result in the same bit position, and Bits32(FromBits32(x)) == x.

func Bits64

func Bits64(x float64) uint64

Bits64 returns the IEEE 754 binary representation of f, with the sign bit of f and the result in the same bit position, and Bits64(FromBits64(x)) == x.

func Cbrt

func Cbrt[FLOAT Float](x FLOAT) FLOAT

Cbrt returns the cube root of x.

Special cases are:

Cbrt(±0)   = ±0
Cbrt(±Inf) = ±Inf
Cbrt(NaN)  = NaN

func Ceil

func Ceil[FLOAT Float](x FLOAT) FLOAT

Ceil returns the least integer value greater than or equal to x.

Special cases are:

Ceil(±0)   = ±0
Ceil(±Inf) = ±Inf
Ceil(NaN)  = NaN

func CopySign

func CopySign[FLOAT Float](f, sign FLOAT) FLOAT

CopySign returns a value with the magnitude of f and the sign of sign.

func Cos

func Cos[FLOAT Float](θ FLOAT) (x FLOAT)

Cos returns the cosine of the radian argument θ.

Special cases are:

Cos(±Inf) = NaN
Cos(NaN)  = NaN

func CosSin

func CosSin[FLOAT Float](θ FLOAT) (cos, sin FLOAT)

CosSin returns Cos(x), Sin(x).

Special cases are:

CosSin(±0)   = 1, ±0
CosSin(±Inf) = NaN, NaN
CosSin(NaN)  = NaN, NaN

func Cosh

func Cosh[FLOAT Float](x FLOAT) FLOAT

Cosh returns the hyperbolic cosine of x.

Special cases are:

Cosh(±0)   = 1
Cosh(±Inf) = +Inf
Cosh(NaN)  = NaN

func Dim

func Dim[FLOAT Float](x, y FLOAT) FLOAT

Dim returns the maximum of x-y or 0.

Special cases are:

Dim(+Inf, +Inf) = NaN
Dim(-Inf, -Inf) = NaN
Dim(x, NaN)     = Dim(NaN, x) = NaN

func Erf

func Erf[FLOAT Float](x FLOAT) FLOAT

Erf returns the error function of x.

Special cases are:

Erf(+Inf) = 1
Erf(-Inf) = -1
Erf(NaN)  = NaN

func ErfInv

func ErfInv[FLOAT Float](x FLOAT) FLOAT

ErfInv returns the inverse error function of x.

Special cases are:

ErfInv(1)   = +Inf
ErfInv(-1)  = -Inf
ErfInv(x)   = NaN if x < -1 or x > 1
ErfInv(NaN) = NaN

func Erfc

func Erfc[FLOAT Float](x FLOAT) FLOAT

Erfc returns the complementary error function of x.

Special cases are:

Erfc(+Inf) = 0
Erfc(-Inf) = 2
Erfc(NaN)  = NaN

func ErfcInv

func ErfcInv[FLOAT Float](x FLOAT) FLOAT

ErfcInv returns the inverse of Erfc(x).

Special cases are:

ErfcInv(0)   = +Inf
ErfcInv(2)   = -Inf
ErfcInv(x)   = NaN if x < 0 or x > 2
ErfcInv(NaN) = NaN

func Exp

func Exp[FLOAT Float](x FLOAT) FLOAT

Exp returns e**2, the base-e exponential of x.

Special cases are:

Exp(+Inf) = +Inf
Exp(NaN)  = NaN

Very large values overflow to 0 or +Inf. Very small values underflow to 1.

func Exp2

func Exp2[FLOAT Float](x FLOAT) FLOAT

Exp2 returns 2**x, the base-2 exponential of x.

Special cases are the same as Exp.

func ExpM1

func ExpM1[FLOAT Float](x FLOAT) FLOAT

ExpM1 returns e**x - 1, the base-e exponential of x minus 1. It is more accurate than Exp(x) - 1 when x is near zero.

Special cases are:

ExpM1(+Inf) = +Inf
ExpM1(-Inf) = -1
ExpM1(NaN)  = NaN

Very large values overflow to -1 or +Inf.

func FMA

func FMA[FLOAT Float](x, y, z FLOAT) FLOAT

FMA returns x * y + z, computed with only one rounding. (That is, FMA returns the fused multiply-add of x, y, and z.)

func Floor

func Floor[FLOAT Float](x FLOAT) FLOAT

Floor returns the greatest integer value less than or equal to x.

Special cases are:

Floor(±0)   = ±0
Floor(±Inf) = ±Inf
Floor(NaN)  = NaN

func FrExp

func FrExp[FLOAT Float](f FLOAT) (frac FLOAT, exp int)

FrExp breaks f into a normalized fraction and an integral power of two. It returns frac and exp satisfying f == frac × 2**exp, with the absolute value of frac in the interval [½, 1).

Special cases are:

FrExp(±0)   = ±0, 0
FrExp(±Inf) = ±Inf, 0
FrExp(NaN)  = NaN, 0

func FromBits

func FromBits[FLOAT Float, UINT uint32 | uint64](bits UINT) FLOAT

FromBits returns the floating-point number corresponding to the IEEE 754 binary representation b, with the sign bit of b and the result in the same bit position. FromBits[FLOAT](Bits[UINT](x)) == x.

func FromBits32

func FromBits32(x uint32) float32

FromBits32 returns the floating-point number corresponding to the IEEE 754 binary representation b, with the sign bit of b and the result in the same bit position. FromBits32(Bits32(x)) == x.

func FromBits64

func FromBits64(x uint64) float64

FromBits64 returns the floating-point number corresponding to the IEEE 754 binary representation b, with the sign bit of b and the result in the same bit position. FromBits64(Bits64(x)) == x.

func Gamma

func Gamma[FLOAT Float](x FLOAT) FLOAT

Gamma is an alias of Γ.

func Hypot

func Hypot[FLOAT Float](p, q FLOAT) FLOAT

Hypot returns Sqrt(p*p + q*q), taking care to avoid unnecessary overflow and underflow.

Special cases are:

Hypot(±Inf, q) = +Inf
Hypot(p, ±Inf) = +Inf
Hypot(NaN, q)  = NaN
Hypot(p, NaN)  = NaN

func ILogB

func ILogB[FLOAT Float](x FLOAT) int

ILogB returns the binary exponent of x as an integer.

Special cases are:

ILogB(±Inf) = MaxInt32
ILogB(0)    = MinInt32
ILogB(NaN)  = MaxInt32

func Inf

func Inf[FLOAT Float](sign int) FLOAT

Inf returns positive infinity if sign >= 0, negative infinity if sign < 0.

func Inf32

func Inf32(sign int) float32

Inf32 returns Inf as a float32.

func Inf64

func Inf64(sign int) float64

Inf64 returns Inf as a float64.

func IsInf

func IsInf[FLOAT Float](f FLOAT, sign int) (is bool)

IsInf reports whether f is an infinity, according to sign. If sign > 0, IsInf reports whether f is positive infinity. If sign < 0, IsInf reports whether f is negative infinity. If sign == 0, IsInf reports whether f is either infinity.

func IsNaN

func IsNaN[FLOAT Float](f FLOAT) (is bool)

IsNaN reports whether f is an IEEE 754 “not-a-number” value.

func J0

func J0[FLOAT Float](x FLOAT) FLOAT

J0 returns the order-zero Bessel function of the first kind.

Special cases are:

J0(±Inf) = 0
J0(0)    = 1
J0(NaN)  = NaN

func J1

func J1[FLOAT Float](x FLOAT) FLOAT

J1 returns the order-one Bessel function of the first kind.

Special cases are:

J1(±Inf) = 0
J1(NaN)  = NaN

func Jn

func Jn[FLOAT Float](n int, x FLOAT) FLOAT

Jn returns the order-n Bessel function of the first kind.

Special cases are:

Jn(n, ±Inf) = 0
Jn(n, NaN)  = NaN

func Lb

func Lb[FLOAT Float](x FLOAT) FLOAT

Lb is an alias of Log2.

func LdExp

func LdExp[FLOAT Float](frac FLOAT, exp int) FLOAT

LdExp is the inverse of FrExp. It returns frac × 2**exp.

Special cases are:

LdExp(±0, exp)   = ±0
LdExp(±Inf, exp) = ±Inf
LdExp(NaN, exp)  = NaN

func Ln

func Ln[FLOAT Float](x FLOAT) FLOAT

Ln is an alias of Log.

func Ln1p

func Ln1p[FLOAT Float](x FLOAT) FLOAT

Ln1p is an alias of Log1p.

func LnGamma

func LnGamma[FLOAT Float](x FLOAT) (lngamma FLOAT, sign int)

LnGamma is an alias of LnΓ.

func LnΓ

func LnΓ[FLOAT Float](x FLOAT) (lnΓ FLOAT, sign int)

LnΓ returns the natural logarithm and sign (-1 or +1) of Γ(x).

Special cases are:

LnΓ(+Inf)     = +Inf
LnΓ(0)        = +Inf
LnΓ(-integer) = +Inf
LnΓ(-Inf)     = -Inf
LnΓ(NaN)      = NaN

func Log

func Log[FLOAT Float](x FLOAT) FLOAT

Log returns the natural logarithm of x.

Special cases are:

Log(+Inf)  = +Inf
Log(0)     = -Inf
Log(x < 0) = NaN
Log(NaN)   = NaN

func Log1p

func Log1p[FLOAT Float](x FLOAT) FLOAT

Log1p returns the natural logarithm of 1 plus its argument x. It is more accurate than Log(1 + x) when x is near zero.

Special cases are:

Log1p(+Inf)   = +Inf
Log1p(±0)     = ±0
Log1p(-1)     = -Inf
Log1p(x < -1) = NaN
Log1p(NaN)    = NaN

func Log2

func Log2[FLOAT Float](x FLOAT) FLOAT

Log2 returns the binary logarithm of x. The special cases are the same as for Log.

func Log10

func Log10[FLOAT Float](x FLOAT) FLOAT

Log10 returns the decimal logarithm of x. The special cases are the same as for Log.

func LogB

func LogB[FLOAT Float](x FLOAT) FLOAT

LogB returns the binary exponent of x.

Special cases are:

Logb(±Inf) = +Inf
Logb(0)    = -Inf
Logb(NaN)  = NaN

func Max

func Max[FLOAT Float](x, y FLOAT) FLOAT

Max returns the larger of x or y.

Special cases are:

Max(x, NaN)  = Max(NaN, x)  = x
Max(x, +Inf) = Max(+Inf, x) = +Inf
Max(+0, ±0)  = Max(±0, +0)  = +0
Max(-0, -0)  = -0

Note that this differs from the built-in function max and the standard library math.Max when called with NaN. This change is to make Max compliant with the floating-point standard.

func Min

func Min[FLOAT Float](x, y FLOAT) FLOAT

Min returns the smaller of x or y.

Special cases are:

Min(x, -Inf) = Min(-Inf, x) = -Inf
Min(x, NaN)  = Min(NaN, x)  = NaN
Min(-0, ±0)  = Min(±0, -0)  = -0

Note that this differs from the built-in function min and the standard library math.Min when called with NaN. This change is to make Min compliant with the floating-point standard.

func Mod

func Mod[FLOAT Float](x, y FLOAT) FLOAT

Mod returns the floating-point remainder of x/y. The magnitude of the result is less than y and its sign agrees with that of x.

Special cases are:

Mod(±Inf, y) = NaN
Mod(NaN, y)  = NaN
Mod(x, 0)    = NaN
Mod(x, ±Inf) = x
Mod(x, NaN)  = NaN

func Modf

func Modf[FLOAT Float](x FLOAT) (int, frac FLOAT)

Modf returns integer and fractional floating-point numbers that sum to f. Both values have the same sign as f.

Special cases are:

Modf(±Inf) = ±Inf, NaN
Modf(NaN)  = NaN, NaN

func NaN

func NaN[FLOAT Float]() FLOAT

NaN returns an IEEE 754 “not-a-number” value.

func NaN32

func NaN32() float32

NaN32 returns an IEEE 754 “not-a-number” value as a float32.

func NaN64

func NaN64() float64

NaN64 returns an IEEE 754 “not-a-number” value as a float64.

func NextAfter

func NextAfter[FLOAT Float](x, y FLOAT) FLOAT

NextAfter returns the next representable float32 or float64 value after x towards y.

Special cases are:

NextAfter(x, x)   = x
NextAfter(NaN, y) = NaN
NextAfter(x, NaN) = NaN

func NextDown

func NextDown[FLOAT Float](x FLOAT) FLOAT

NextDown returns the next representable float32 or float64 value after x towards negative infinity.

Special cases are:

NextUp(NaN)  = NaN
NextUp(-Inf) = -Inf

func NextUp

func NextUp[FLOAT Float](x FLOAT) FLOAT

NextUp returns the next representable float32 or float64 value after x towards positive infinity.

Special cases are:

NextUp(NaN)  = NaN
NextUp(+Inf) = +Inf

func Pow

func Pow[FLOAT Float](x, y FLOAT) FLOAT

Pow returns x**y, the base-x exponential of y.

Special cases are (in order):

Pow(x, ±0)    = 1 for any x
Pow(1, y)     = 1 for any y
Pow(x, 1)     = x for any x
Pow(NaN, y)   = NaN
Pow(x, NaN)   = NaN
Pow(±0, y)    = ±Inf for y an odd integer < 0
Pow(±0, -Inf) = +Inf
Pow(±0, +Inf) = +0
Pow(±0, y)    = +Inf for finite y < 0 and not an odd integer
Pow(±0, y)    = ±0 for y an odd integer > 0
Pow(±0, y)    = +0 for finite y > 0 and not an odd integer
Pow(-1, ±Inf) = 1
Pow(x, +Inf)  = +Inf for |x| > 1
Pow(x, -Inf)  = +0 for |x| > 1
Pow(x, +Inf)  = +0 for |x| < 1
Pow(x, -Inf)  = +Inf for |x| < 1
Pow(+Inf, y)  = +Inf for y > 0
Pow(+Inf, y)  = +0 for y < 0
Pow(-Inf, y)  = Pow(-0, -y)
Pow(x, y)     = NaN for finite x < 0 and finite non-integer y

func Pow10

func Pow10[FLOAT Float](x int) FLOAT

Pow10 returns 10**n, the base-10 exponential of n.

Special cases are:

Pow10(n) =    0 for n < -323
Pow10(n) = +Inf for n > 308

func Remainder

func Remainder[FLOAT Float](x, y FLOAT) FLOAT

Remainder returns the IEEE 754 floating-point remainder of x/y.

Special cases are:

Remainder(±Inf, y) = NaN
Remainder(NaN, y)  = NaN
Remainder(x, 0)    = NaN
Remainder(x, ±Inf) = x
Remainder(x, NaN)  = NaN

func Round

func Round[FLOAT Float](x FLOAT) FLOAT

Round returns the nearest integer, rounding half away from zero.

Special cases are:

Round(±0)   = ±0
Round(±Inf) = ±Inf
Round(NaN)  = NaN

func RoundToEven

func RoundToEven[FLOAT Float](x FLOAT) FLOAT

RoundToEven returns the nearest integer, rounding ties to even.

Special cases are:

RoundToEven(±0)   = ±0
RoundToEven(±Inf) = ±Inf
RoundToEven(NaN)  = NaN

func Sgn

func Sgn[FLOAT Float](x FLOAT) FLOAT

Sgn returns the sign function of x.

Special cases are:

Sgn(NaN) = NaN
Sgn(±0)  = +0

func SignBit

func SignBit[FLOAT Float](x FLOAT) bool

SignBit reports whether x is negative or negative zero.

func Sin

func Sin[FLOAT Float](θ FLOAT) (x FLOAT)

Sin returns the sine of the radian argument θ.

Special cases are:

Sin(±0)   = ±0
Sin(±Inf) = NaN
Sin(NaN)  = NaN

func SinCos

func SinCos[FLOAT Float](θ FLOAT) (sin, cos FLOAT)

SinCos returns Sin(x), Cos(x).

Special cases are:

SinCos(±0)   = ±0, 1
SinCos(±Inf) = NaN, NaN
SinCos(NaN)  = NaN, NaN

func Sinh

func Sinh[FLOAT Float](x FLOAT) FLOAT

Sinh returns the hyperbolic sine of x.

Special cases are:

Sinh(±0)   = ±0
Sinh(±Inf) = ±Inf
Sinh(NaN)  = NaN

func Sqrt

func Sqrt[FLOAT Float](x FLOAT) FLOAT

Sqrt returns the square root of x.

Special cases are:

Sqrt(+Inf)  = +Inf
Sqrt(±0)    = ±0
Sqrt(x < 0) = NaN
Sqrt(NaN)   = NaN

func Tan

func Tan[FLOAT Float](θ FLOAT) (x FLOAT)

Tan returns the tangent of the radian argument θ.

Special cases are:

Tan(±0)   = ±0
Tan(±Inf) = NaN
Tan(NaN)  = NaN

func Tanh

func Tanh[FLOAT Float](x FLOAT) FLOAT

Tanh returns the hyperbolic tangent of x.

Special cases are:

Tanh(±0) = ±0
Tanh(±Inf) = ±1
Tanh(NaN) = NaN

func Trunc

func Trunc[FLOAT Float](x FLOAT) FLOAT

Trunc returns the integer value of x.

Special cases are:

Trunc(±0)   = ±0
Trunc(±Inf) = ±Inf
Trunc(NaN)  = NaN

func Y0

func Y0[FLOAT Float](x FLOAT) FLOAT

Y0 returns the order-zero Bessel function of the second kind.

Special cases are:

Y0(+Inf)  = 0
Y0(0)     = -Inf
Y0(x < 0) = NaN
Y0(NaN)   = NaN

func Y1

func Y1[FLOAT Float](x FLOAT) FLOAT

Y1 returns the order-one Bessel function of the second kind.

Special cases are:

Y1(+Inf)  = 0
Y1(0)     = -Inf
Y1(x < 0) = NaN
Y1(NaN)   = NaN

func Yn

func Yn[FLOAT Float](n int, x FLOAT) FLOAT

Yn returns the order-n Bessel function of the second kind.

Special cases are:

Yn(n, +Inf)  = 0
Yn(n ≥ 0, 0) = -Inf
Yn(n < 0, 0) = +Inf if n is odd, -Inf if n is even
Yn(n, x < 0) = NaN
Yn(n, NaN)   = NaN

func Γ

func Γ[FLOAT Float](x FLOAT) FLOAT

Γ returns the Gamma function of x.

Special cases are:

Γ(+Inf) = +Inf
Γ(+0)   = +Inf
Γ(-0)   = -Inf
Γ(x)    = NaN for integer x < 0
Γ(-Inf) = NaN
Γ(NaN)  = NaN

Types

type Float

type Float interface{ float32 | float64 }

Float is a constraint that permits any builtin floating point type. If future releases of Go add new floating point types, this constraint will be modified to include them.

Directories

Path Synopsis
kirkpatrick-reisch
muldivsort command
recursion
primative
Package primative provides functions to be able to build primative recursive functions.
Package primative provides functions to be able to build primative recursive functions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL