多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# package math `import "math"` math包提供了基本的数学常数和数学函数。 ## Index * [Constants](#pkg-constants) * [func NaN() float64](#NaN) * [func IsNaN(f float64) (is bool)](#IsNaN) * [func Inf(sign int) float64](#Inf) * [func IsInf(f float64, sign int) bool](#IsInf) * [func Float32bits(f float32) uint32](#Float32bits) * [func Float32frombits(b uint32) float32](#Float32frombits) * [func Float64bits(f float64) uint64](#Float64bits) * [func Float64frombits(b uint64) float64](#Float64frombits) * [func Signbit(x float64) bool](#Signbit) * [func Copysign(x, y float64) float64](#Copysign) * [func Ceil(x float64) float64](#Ceil) * [func Floor(x float64) float64](#Floor) * [func Trunc(x float64) float64](#Trunc) * [func Modf(f float64) (int float64, frac float64)](#Modf) * [func Nextafter(x, y float64) (r float64)](#Nextafter) * [func Abs(x float64) float64](#Abs) * [func Max(x, y float64) float64](#Max) * [func Min(x, y float64) float64](#Min) * [func Dim(x, y float64) float64](#Dim) * [func Mod(x, y float64) float64](#Mod) * [func Remainder(x, y float64) float64](#Remainder) * [func Sqrt(x float64) float64](#Sqrt) * [func Cbrt(x float64) float64](#Cbrt) * [func Hypot(p, q float64) float64](#Hypot) * [func Sin(x float64) float64](#Sin) * [func Cos(x float64) float64](#Cos) * [func Tan(x float64) float64](#Tan) * [func Sincos(x float64) (sin, cos float64)](#Sincos) * [func Asin(x float64) float64](#Asin) * [func Acos(x float64) float64](#Acos) * [func Atan(x float64) float64](#Atan) * [func Atan2(y, x float64) float64](#Atan2) * [func Sinh(x float64) float64](#Sinh) * [func Cosh(x float64) float64](#Cosh) * [func Tanh(x float64) float64](#Tanh) * [func Asinh(x float64) float64](#Asinh) * [func Acosh(x float64) float64](#Acosh) * [func Atanh(x float64) float64](#Atanh) * [func Log(x float64) float64](#Log) * [func Log1p(x float64) float64](#Log1p) * [func Log2(x float64) float64](#Log2) * [func Log10(x float64) float64](#Log10) * [func Logb(x float64) float64](#Logb) * [func Ilogb(x float64) int](#Ilogb) * [func Frexp(f float64) (frac float64, exp int)](#Frexp) * [func Ldexp(frac float64, exp int) float64](#Ldexp) * [func Exp(x float64) float64](#Exp) * [func Expm1(x float64) float64](#Expm1) * [func Exp2(x float64) float64](#Exp2) * [func Pow(x, y float64) float64](#Pow) * [func Pow10(e int) float64](#Pow10) * [func Gamma(x float64) float64](#Gamma) * [func Lgamma(x float64) (lgamma float64, sign int)](#Lgamma) * [func Erf(x float64) float64](#Erf) * [func Erfc(x float64) float64](#Erfc) * [func J0(x float64) float64](#J0) * [func J1(x float64) float64](#J1) * [func Jn(n int, x float64) float64](#Jn) * [func Y0(x float64) float64](#Y0) * [func Y1(x float64) float64](#Y1) * [func Yn(n int, x float64) float64](#Yn) ## Constants ``` const ( E = 2.71828182845904523536028747135266249775724709369995957496696763 // A001113 Pi = 3.14159265358979323846264338327950288419716939937510582097494459 // A000796 Phi = 1.61803398874989484820458683436563811772030917980576286213544862 // A001622 Sqrt2 = 1.41421356237309504880168872420969807856967187537694807317667974 // A002193 SqrtE = 1.64872127070012814684865078781416357165377610071014801157507931 // A019774 SqrtPi = 1.77245385090551602729816748334114518279754945612238712821380779 // A002161 SqrtPhi = 1.27201964951406896425242246173749149171560804184009624861664038 // A139339 Ln2 = 0.693147180559945309417232121458176568075500134360255254120680009 // A002162 Log2E = 1 / Ln2 Ln10 = 2.30258509299404568401799145468436420760110148862877297603332790 // A002392 Log10E = 1 / Ln10 ) ``` 数学常数,参见:[http://oeis.org/Axxxxxx](http://oeis.org/Axxxxxx) ``` const ( MaxFloat32 = 3.40282346638528859811704183484516925440e+38 // 2**127 * (2**24 - 1) / 2**23 SmallestNonzeroFloat32 = 1.401298464324817070923729583289916131280e-45 // 1 / 2**(127 - 1 + 23) MaxFloat64 = 1.797693134862315708145274237317043567981e+308 // 2**1023 * (2**53 - 1) / 2**52 SmallestNonzeroFloat64 = 4.940656458412465441765687928682213723651e-324 // 1 / 2**(1023 - 1 + 52) ) ``` 浮点数的取值极限。Max是该类型所能表示的最大有限值;SmallestNonzero是该类型所能表示的最小非零正数值。 ``` const ( MaxInt8 = 1<<7 - 1 MinInt8 = -1 << 7 MaxInt16 = 1<<15 - 1 MinInt16 = -1 << 15 MaxInt32 = 1<<31 - 1 MinInt32 = -1 << 31 MaxInt64 = 1<<63 - 1 MinInt64 = -1 << 63 MaxUint8 = 1<<8 - 1 MaxUint16 = 1<<16 - 1 MaxUint32 = 1<<32 - 1 MaxUint64 = 1<<64 - 1 ) ``` 整数的取值极限。 ## func [NaN](https://github.com/golang/go/blob/master/src/math/bits.go#L28 "View Source") ``` func NaN() float64 ``` 函数返回一个IEEE 754“这不是一个数字”值。 ## func [IsNaN](https://github.com/golang/go/blob/master/src/math/bits.go#L31 "View Source") ``` func IsNaN(f float64) (is bool) ``` 报告f是否表示一个NaN(Not A Number)值。 ## func [Inf](https://github.com/golang/go/blob/master/src/math/bits.go#L17 "View Source") ``` func Inf(sign int) float64 ``` 如果sign&gt;=0函数返回正无穷大,否则返回负无穷大。 ## func [IsInf](https://github.com/golang/go/blob/master/src/math/bits.go#L43 "View Source") ``` func IsInf(f float64, sign int) bool ``` 如果sign &gt; 0,f是正无穷大时返回真;如果sign&lt;0,f是负无穷大时返回真;sign==0则f是两种无穷大时都返回真。 ## func [Float32bits](https://github.com/golang/go/blob/master/src/math/unsafe.go#L10 "View Source") ``` func Float32bits(f float32) uint32 ``` 函数返回浮点数f的IEEE 754格式二进制表示对应的4字节无符号整数。 ## func [Float32frombits](https://github.com/golang/go/blob/master/src/math/unsafe.go#L14 "View Source") ``` func Float32frombits(b uint32) float32 ``` 函数返回无符号整数b对应的IEEE 754格式二进制表示的4字节浮点数。 ## func [Float64bits](https://github.com/golang/go/blob/master/src/math/unsafe.go#L17 "View Source") ``` func Float64bits(f float64) uint64 ``` 函数返回浮点数f的IEEE 754格式二进制表示对应的8字节无符号整数。 ## func [Float64frombits](https://github.com/golang/go/blob/master/src/math/unsafe.go#L21 "View Source") ``` func Float64frombits(b uint64) float64 ``` 函数返回无符号整数b对应的IEEE 754格式二进制表示的8字节浮点数。 ## func [Signbit](https://github.com/golang/go/blob/master/src/math/signbit.go#L8 "View Source") ``` func Signbit(x float64) bool ``` 如果x是一个负数或者负零,返回真。 ## func [Copysign](https://github.com/golang/go/blob/master/src/math/copysign.go#L9 "View Source") ``` func Copysign(x, y float64) float64 ``` 返回拥有x的量值(绝对值)和y的标志位(正负号)的浮点数。 ## func [Ceil](https://github.com/golang/go/blob/master/src/math/floor.go#L36 "View Source") ``` func Ceil(x float64) float64 ``` 返回不小于x的最小整数(的浮点值),特例如下: ``` Ceil(±0) = ±0 Ceil(±Inf) = ±Inf Ceil(NaN) = NaN ``` ## func [Floor](https://github.com/golang/go/blob/master/src/math/floor.go#L13 "View Source") ``` func Floor(x float64) float64 ``` 返回不大于x的最小整数(的浮点值),特例如下: ``` Floor(±0) = ±0 Floor(±Inf) = ±Inf Floor(NaN) = NaN ``` ## func [Trunc](https://github.com/golang/go/blob/master/src/math/floor.go#L48 "View Source") ``` func Trunc(x float64) float64 ``` 返回x的整数部分(的浮点值)。特例如下: ``` Trunc(±0) = ±0 Trunc(±Inf) = ±Inf Trunc(NaN) = NaN ``` ## func [Modf](https://github.com/golang/go/blob/master/src/math/modf.go#L13 "View Source") ``` func Modf(f float64) (int float64, frac float64) ``` 返回f的整数部分和小数部分,结果的正负号和都x相同;特例如下: ``` Modf(±Inf) = ±Inf, NaN Modf(NaN) = NaN, NaN ``` ## func [Nextafter](https://github.com/golang/go/blob/master/src/math/nextafter.go#L13 "View Source") ``` func Nextafter(x, y float64) (r float64) ``` 参数x到参数y的方向上,下一个可表示的数值;如果x==y将返回x。特例如下: ``` Nextafter(NaN, y) = NaN Nextafter(x, NaN) = NaN ``` ## func [Abs](https://github.com/golang/go/blob/master/src/math/abs.go#L12 "View Source") ``` func Abs(x float64) float64 ``` 返回x的绝对值;特例如下: ``` Abs(±Inf) = +Inf Abs(NaN) = NaN ``` ## func [Max](https://github.com/golang/go/blob/master/src/math/dim.go#L26 "View Source") ``` func Max(x, y float64) float64 ``` 返回x和y中最大值,特例如下: ``` Max(x, +Inf) = Max(+Inf, x) = +Inf Max(x, NaN) = Max(NaN, x) = NaN Max(+0, ±0) = Max(±0, +0) = +0 Max(-0, -0) = -0 ``` ## func [Min](https://github.com/golang/go/blob/master/src/math/dim.go#L53 "View Source") ``` func Min(x, y float64) float64 ``` 返回x和y中最小值,特例如下: ``` Min(x, -Inf) = Min(-Inf, x) = -Inf Min(x, NaN) = Min(NaN, x) = NaN Min(-0, ±0) = Min(±0, -0) = -0 ``` ## func [Dim](https://github.com/golang/go/blob/master/src/math/dim.go#L13 "View Source") ``` func Dim(x, y float64) float64 ``` 函数返回x-y和0中的最大值,特殊情况: ``` Dim(+Inf, +Inf) = NaN Dim(-Inf, -Inf) = NaN Dim(x, NaN) = Dim(NaN, x) = NaN ``` ## func [Mod](https://github.com/golang/go/blob/master/src/math/mod.go#L21 "View Source") ``` func Mod(x, y float64) float64 ``` 取余运算,可以理解为 x-Trunc(x/y)\*y,结果的正负号和x相同;特例如下: ``` Mod(±Inf, y) = NaN Mod(NaN, y) = NaN Mod(x, 0) = NaN Mod(x, ±Inf) = x Mod(x, NaN) = NaN ``` ## func [Remainder](https://github.com/golang/go/blob/master/src/math/remainder.go#L37 "View Source") ``` func Remainder(x, y float64) float64 ``` IEEE 754差数求值,即x减去最接近x/y的整数值(如果有两个整数与x/y距离相同,则取其中的偶数)与y的乘积。特例如下: ``` Remainder(±Inf, y) = NaN Remainder(NaN, y) = NaN Remainder(x, 0) = NaN Remainder(x, ±Inf) = x Remainder(x, NaN) = NaN ``` ## func [Sqrt](https://github.com/golang/go/blob/master/src/math/sqrt.go#L92 "View Source") ``` func Sqrt(x float64) float64 ``` 返回x的二次方根,特例如下: ``` Sqrt(+Inf) = +Inf Sqrt(±0) = ±0 Sqrt(x < 0) = NaN Sqrt(NaN) = NaN ``` ## func [Cbrt](https://github.com/golang/go/blob/master/src/math/cbrt.go#L21 "View Source") ``` func Cbrt(x float64) float64 ``` 返回x的三次方根,特例如下: ``` Cbrt(±0) = ±0 Cbrt(±Inf) = ±Inf Cbrt(NaN) = NaN ``` ## func [Hypot](https://github.com/golang/go/blob/master/src/math/hypot.go#L19 "View Source") ``` func Hypot(p, q float64) float64 ``` 返回Sqrt(p\*p + q\*q),注意要避免不必要的溢出或下溢。特例如下: ``` Hypot(±Inf, q) = +Inf Hypot(p, ±Inf) = +Inf Hypot(NaN, q) = NaN Hypot(p, NaN) = NaN ``` ## func [Sin](https://github.com/golang/go/blob/master/src/math/sin.go#L174 "View Source") ``` func Sin(x float64) float64 ``` 求正弦。特例如下: ``` Sin(±0) = ±0 Sin(±Inf) = NaN Sin(NaN) = NaN ``` ## func [Cos](https://github.com/golang/go/blob/master/src/math/sin.go#L117 "View Source") ``` func Cos(x float64) float64 ``` 求余弦。特例如下: ``` Cos(±Inf) = NaN Cos(NaN) = NaN ``` ## func [Tan](https://github.com/golang/go/blob/master/src/math/tan.go#L82 "View Source") ``` func Tan(x float64) float64 ``` 求正切。特例如下: ``` Tan(±0) = ±0 Tan(±Inf) = NaN Tan(NaN) = NaN ``` ## func [Sincos](https://github.com/golang/go/blob/master/src/math/sincos.go#L15 "View Source") ``` func Sincos(x float64) (sin, cos float64) ``` 函数返回Sin(x), Cos(x)。特例如下: ``` Sincos(±0) = ±0, 1 Sincos(±Inf) = NaN, NaN Sincos(NaN) = NaN, NaN ``` ## func [Asin](https://github.com/golang/go/blob/master/src/math/asin.go#L19 "View Source") ``` func Asin(x float64) float64 ``` 求反正弦(x是弧度)。特例如下: ``` Asin(±0) = ±0 Asin(x) = NaN if x < -1 or x > 1 ``` ## func [Acos](https://github.com/golang/go/blob/master/src/math/asin.go#L51 "View Source") ``` func Acos(x float64) float64 ``` 求反余弦(x是弧度)。特例如下: ``` Acos(x) = NaN if x < -1 or x > 1 ``` ## func [Atan](https://github.com/golang/go/blob/master/src/math/atan.go#L95 "View Source") ``` func Atan(x float64) float64 ``` 求反正切(x是弧度)。特例如下: ``` Atan(±0) = ±0 Atan(±Inf) = ±Pi/2 ``` ## func [Atan2](https://github.com/golang/go/blob/master/src/math/atan2.go#L29 "View Source") ``` func Atan2(y, x float64) float64 ``` 类似Atan(y/x),但会根据x,y的正负号确定象限。特例如下(前面的优先): ``` Atan2(y, NaN) = NaN Atan2(NaN, x) = NaN Atan2(+0, x>=0) = +0 Atan2(-0, x>=0) = -0 Atan2(+0, x<=-0) = +Pi Atan2(-0, x<=-0) = -Pi Atan2(y>0, 0) = +Pi/2 Atan2(y<0, 0) = -Pi/2 Atan2(+Inf, +Inf) = +Pi/4 Atan2(-Inf, +Inf) = -Pi/4 Atan2(+Inf, -Inf) = 3Pi/4 Atan2(-Inf, -Inf) = -3Pi/4 Atan2(y, +Inf) = 0 Atan2(y>0, -Inf) = +Pi Atan2(y<0, -Inf) = -Pi Atan2(+Inf, x) = +Pi/2 Atan2(-Inf, x) = -Pi/2 ``` ## func [Sinh](https://github.com/golang/go/blob/master/src/math/sinh.go#L25 "View Source") ``` func Sinh(x float64) float64 ``` 求双曲正弦,特例如下: ``` Sinh(±0) = ±0 Sinh(±Inf) = ±Inf Sinh(NaN) = NaN ``` ## func [Cosh](https://github.com/golang/go/blob/master/src/math/sinh.go#L69 "View Source") ``` func Cosh(x float64) float64 ``` 求双曲余弦,特例如下: ``` Cosh(±0) = 1 Cosh(±Inf) = +Inf Cosh(NaN) = NaN ``` ## func [Tanh](https://github.com/golang/go/blob/master/src/math/tanh.go#L74 "View Source") ``` func Tanh(x float64) float64 ``` 求双曲正切,特例如下: ``` Tanh(±0) = ±0 Tanh(±Inf) = ±1 Tanh(NaN) = NaN ``` ## func [Asinh](https://github.com/golang/go/blob/master/src/math/asinh.go#L39 "View Source") ``` func Asinh(x float64) float64 ``` 求反双曲正弦,特例如下: ``` Asinh(±0) = ±0 Asinh(±Inf) = ±Inf Asinh(NaN) = NaN ``` ## func [Acosh](https://github.com/golang/go/blob/master/src/math/acosh.go#L42 "View Source") ``` func Acosh(x float64) float64 ``` 求反双曲余弦,特例如下: ``` Acosh(+Inf) = +Inf Acosh(x) = NaN if x < 1 Acosh(NaN) = NaN ``` ## func [Atanh](https://github.com/golang/go/blob/master/src/math/atanh.go#L47 "View Source") ``` func Atanh(x float64) float64 ``` 求反双曲正切,特例如下: ``` Atanh(1) = +Inf Atanh(±0) = ±0 Atanh(-1) = -Inf Atanh(x) = NaN if x < -1 or x > 1 Atanh(NaN) = NaN ``` ## func [Log](https://github.com/golang/go/blob/master/src/math/log.go#L80 "View Source") ``` func Log(x float64) float64 ``` 求自然对数,特例如下: ``` Log(+Inf) = +Inf Log(0) = -Inf Log(x < 0) = NaN Log(NaN) = NaN ``` ## func [Log1p](https://github.com/golang/go/blob/master/src/math/log1p.go#L95 "View Source") ``` func Log1p(x float64) float64 ``` 等价于Log(1+x)。但是在x接近0时,本函数更加精确;特例如下: ``` Log1p(+Inf) = +Inf Log1p(±0) = ±0 Log1p(-1) = -Inf Log1p(x < -1) = NaN Log1p(NaN) = NaN ``` ## func [Log2](https://github.com/golang/go/blob/master/src/math/log10.go#L17 "View Source") ``` func Log2(x float64) float64 ``` 求2为底的对数;特例和Log相同。 ## func [Log10](https://github.com/golang/go/blob/master/src/math/log10.go#L9 "View Source") ``` func Log10(x float64) float64 ``` 求10为底的对数;特例和Log相同。 ## func [Logb](https://github.com/golang/go/blob/master/src/math/logb.go#L13 "View Source") ``` func Logb(x float64) float64 ``` 返回x的二进制指数值,可以理解为Trunc(Log2(x));特例如下: ``` Logb(±Inf) = +Inf Logb(0) = -Inf Logb(NaN) = NaN ``` ## func [Ilogb](https://github.com/golang/go/blob/master/src/math/logb.go#L32 "View Source") ``` func Ilogb(x float64) int ``` 类似Logb,但返回值是整型;特例如下: ``` Ilogb(±Inf) = MaxInt32 Ilogb(0) = MinInt32 Ilogb(NaN) = MaxInt32 ``` ## func [Frexp](https://github.com/golang/go/blob/master/src/math/frexp.go#L16 "View Source") ``` func Frexp(f float64) (frac float64, exp int) ``` 返回一个标准化小数frac和2的整型指数exp,满足f == frac \* 2\*\*exp,且0.5 &lt;= Abs(frac) &lt; 1;特例如下: ``` Frexp(±0) = ±0, 0 Frexp(±Inf) = ±Inf, 0 Frexp(NaN) = NaN, 0 ``` ## func [Ldexp](https://github.com/golang/go/blob/master/src/math/ldexp.go#L14 "View Source") ``` func Ldexp(frac float64, exp int) float64 ``` Frexp的反函数,返回 frac \* 2\*\*exp。特例如下: ``` Ldexp(±0, exp) = ±0 Ldexp(±Inf, exp) = ±Inf Ldexp(NaN, exp) = NaN ``` ## func [Exp](https://github.com/golang/go/blob/master/src/math/exp.go#L14 "View Source") ``` func Exp(x float64) float64 ``` 返回E\*\*x;x绝对值很大时可能会溢出为0或者+Inf,x绝对值很小时可能会下溢为1。特例如下: ``` Exp(+Inf) = +Inf Exp(NaN) = NaN ``` ## func [Expm1](https://github.com/golang/go/blob/master/src/math/expm1.go#L124 "View Source") ``` func Expm1(x float64) float64 ``` 等价于Exp(x)-1,但是在x接近零时更精确;x绝对值很大时可能会溢出为-1或+Inf。特例如下: ``` Expm1(+Inf) = +Inf Expm1(-Inf) = -1 Expm1(NaN) = NaN ``` ## func [Exp2](https://github.com/golang/go/blob/master/src/math/exp.go#L135 "View Source") ``` func Exp2(x float64) float64 ``` 返回2\*\*x;特例和Exp相同。 ## func [Pow](https://github.com/golang/go/blob/master/src/math/pow.go#L38 "View Source") ``` func Pow(x, y float64) float64 ``` 返回x\*\*y;特例如下(前面的优先): ``` 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](https://github.com/golang/go/blob/master/src/math/pow10.go#L16 "View Source") ``` func Pow10(e int) float64 ``` 返回10\*\*e;特例如下: ``` Pow10(e) = +Inf for e > 309 Pow10(e) = 0 for e < -324 ``` ## func [Gamma](https://github.com/golang/go/blob/master/src/math/gamma.go#L122 "View Source") ``` func Gamma(x float64) float64 ``` 伽玛函数(当x为正整数时,值为(x-1)!)。特例如下: ``` Gamma(+Inf) = +Inf Gamma(+0) = +Inf Gamma(-0) = -Inf Gamma(x) = NaN for integer x < 0 Gamma(-Inf) = NaN Gamma(NaN) = NaN ``` ## func [Lgamma](https://github.com/golang/go/blob/master/src/math/lgamma.go#L174 "View Source") ``` func Lgamma(x float64) (lgamma float64, sign int) ``` 返回Gamma(x)的自然对数和正负号。特例如下: ``` Lgamma(+Inf) = +Inf Lgamma(0) = +Inf Lgamma(-integer) = +Inf Lgamma(-Inf) = -Inf Lgamma(NaN) = NaN ``` ## func [Erf](https://github.com/golang/go/blob/master/src/math/erf.go#L188 "View Source") ``` func Erf(x float64) float64 ``` 误差函数,特例如下: ``` Erf(+Inf) = 1 Erf(-Inf) = -1 Erf(NaN) = NaN ``` ## func [Erfc](https://github.com/golang/go/blob/master/src/math/erf.go#L265 "View Source") ``` func Erfc(x float64) float64 ``` 余补误差函数,特例如下: ``` Erfc(+Inf) = 0 Erfc(-Inf) = 2 Erfc(NaN) = NaN ``` ## func [J0](https://github.com/golang/go/blob/master/src/math/j0.go#L76 "View Source") ``` func J0(x float64) float64 ``` 第一类贝塞尔函数,0阶。特例如下: ``` J0(±Inf) = 0 J0(0) = 1 J0(NaN) = NaN ``` ## func [J1](https://github.com/golang/go/blob/master/src/math/j1.go#L74 "View Source") ``` func J1(x float64) float64 ``` 第一类贝塞尔函数,1阶。特例如下: ``` J1(±Inf) = 0 J1(NaN) = NaN ``` ## func [Jn](https://github.com/golang/go/blob/master/src/math/jn.go#L53 "View Source") ``` func Jn(n int, x float64) float64 ``` 第一类贝塞尔函数,n阶。特例如下: ``` Jn(n, ±Inf) = 0 Jn(n, NaN) = NaN ``` ## func [Y0](https://github.com/golang/go/blob/master/src/math/j0.go#L156 "View Source") ``` func Y0(x float64) float64 ``` 第二类贝塞尔函数,0阶。特例如下: ``` Y0(+Inf) = 0 Y0(0) = -Inf Y0(x < 0) = NaN Y0(NaN) = NaN ``` ## func [Y1](https://github.com/golang/go/blob/master/src/math/j1.go#L154 "View Source") ``` func Y1(x float64) float64 ``` 第二类贝塞尔函数,1阶。特例如下: ``` Y1(+Inf) = 0 Y1(0) = -Inf Y1(x < 0) = NaN Y1(NaN) = NaN ``` ## func [Yn](https://github.com/golang/go/blob/master/src/math/jn.go#L235 "View Source") ``` func Yn(n int, x float64) float64 ``` 第二类贝塞尔函数,n阶。特例如下: ``` Yn(n, +Inf) = 0 Yn(n > 0, 0) = -Inf Yn(n < 0, 0) = +Inf if n is odd, -Inf if n is even Y1(n, x < 0) = NaN Y1(n, NaN) = NaN ```