mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-10-25 22:03:08 +08:00
479 lines
30 KiB
HTML
479 lines
30 KiB
HTML
<div class="container">
|
||
<h1 id="pkg-overview">package math</h1>
|
||
<p><code>import "math"</code>
|
||
</p><p>math包提供了基本的数学常数和数学函数。</p>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h2 id="pkg-constants">Constants </h2>
|
||
<pre>const (
|
||
<span id="E">E</span> = 2.71828182845904523536028747135266249775724709369995957496696763 <span class="com">// A001113</span>
|
||
<span id="Pi">Pi</span> = 3.14159265358979323846264338327950288419716939937510582097494459 <span class="com">// A000796</span>
|
||
<span id="Phi">Phi</span> = 1.61803398874989484820458683436563811772030917980576286213544862 <span class="com">// A001622</span>
|
||
<span id="Sqrt2">Sqrt2</span> = 1.41421356237309504880168872420969807856967187537694807317667974 <span class="com">// A002193</span>
|
||
<span id="SqrtE">SqrtE</span> = 1.64872127070012814684865078781416357165377610071014801157507931 <span class="com">// A019774</span>
|
||
<span id="SqrtPi">SqrtPi</span> = 1.77245385090551602729816748334114518279754945612238712821380779 <span class="com">// A002161</span>
|
||
<span id="SqrtPhi">SqrtPhi</span> = 1.27201964951406896425242246173749149171560804184009624861664038 <span class="com">// A139339</span>
|
||
<span id="Ln2">Ln2</span> = 0.693147180559945309417232121458176568075500134360255254120680009 <span class="com">// A002162</span>
|
||
<span id="Log2E">Log2E</span> = 1 / <a href="#Ln2">Ln2</a>
|
||
<span id="Ln10">Ln10</span> = 2.30258509299404568401799145468436420760110148862877297603332790 <span class="com">// A002392</span>
|
||
<span id="Log10E">Log10E</span> = 1 / <a href="#Ln10">Ln10</a>
|
||
)</pre>
|
||
<p>数学常数,参见:<a href="http://oeis.org/Axxxxxx">http://oeis.org/Axxxxxx</a></p>
|
||
<pre>const (
|
||
<span id="MaxFloat32">MaxFloat32</span> = 3.40282346638528859811704183484516925440e+38 <span class="com">// 2**127 * (2**24 - 1) / 2**23</span>
|
||
<span id="SmallestNonzeroFloat32">SmallestNonzeroFloat32</span> = 1.401298464324817070923729583289916131280e-45 <span class="com">// 1 / 2**(127 - 1 + 23)</span>
|
||
<span id="MaxFloat64">MaxFloat64</span> = 1.797693134862315708145274237317043567981e+308 <span class="com">// 2**1023 * (2**53 - 1) / 2**52</span>
|
||
<span id="SmallestNonzeroFloat64">SmallestNonzeroFloat64</span> = 4.940656458412465441765687928682213723651e-324 <span class="com">// 1 / 2**(1023 - 1 + 52)</span>
|
||
)</pre>
|
||
<p>浮点数的取值极限。Max是该类型所能表示的最大有限值;SmallestNonzero是该类型所能表示的最小非零正数值。</p>
|
||
<pre>const (
|
||
<span id="MaxInt8">MaxInt8</span> = 1<<7 - 1
|
||
<span id="MinInt8">MinInt8</span> = -1 << 7
|
||
<span id="MaxInt16">MaxInt16</span> = 1<<15 - 1
|
||
<span id="MinInt16">MinInt16</span> = -1 << 15
|
||
<span id="MaxInt32">MaxInt32</span> = 1<<31 - 1
|
||
<span id="MinInt32">MinInt32</span> = -1 << 31
|
||
<span id="MaxInt64">MaxInt64</span> = 1<<63 - 1
|
||
<span id="MinInt64">MinInt64</span> = -1 << 63
|
||
<span id="MaxUint8">MaxUint8</span> = 1<<8 - 1
|
||
<span id="MaxUint16">MaxUint16</span> = 1<<16 - 1
|
||
<span id="MaxUint32">MaxUint32</span> = 1<<32 - 1
|
||
<span id="MaxUint64">MaxUint64</span> = 1<<64 - 1
|
||
)</pre>
|
||
<p>整数的取值极限。</p>
|
||
<h2 id="NaN">func <a href="https://github.com/golang/go/blob/master/src/math/bits.go?name=release#28" title="View Source">NaN</a> </h2>
|
||
<pre class="funcdecl">func NaN() <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>函数返回一个IEEE 754“这不是一个数字”值。</p>
|
||
<h2 id="IsNaN">func <a href="https://github.com/golang/go/blob/master/src/math/bits.go?name=release#31" title="View Source">IsNaN</a> </h2>
|
||
<pre class="funcdecl">func IsNaN(f <a href="builtin.htm#float64">float64</a>) (is <a href="builtin.htm#bool">bool</a>)</pre>
|
||
<p>报告f是否表示一个NaN(Not A Number)值。</p>
|
||
<h2 id="Inf">func <a href="https://github.com/golang/go/blob/master/src/math/bits.go?name=release#17" title="View Source">Inf</a> </h2>
|
||
<pre class="funcdecl">func Inf(sign <a href="builtin.htm#int">int</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>如果sign>=0函数返回正无穷大,否则返回负无穷大。</p>
|
||
<h2 id="IsInf">func <a href="https://github.com/golang/go/blob/master/src/math/bits.go?name=release#43" title="View Source">IsInf</a> </h2>
|
||
<pre class="funcdecl">func IsInf(f <a href="builtin.htm#float64">float64</a>, sign <a href="builtin.htm#int">int</a>) <a href="builtin.htm#bool">bool</a></pre>
|
||
<p>如果sign > 0,f是正无穷大时返回真;如果sign<0,f是负无穷大时返回真;sign==0则f是两种无穷大时都返回真。</p>
|
||
<h2 id="Float32bits">func <a href="https://github.com/golang/go/blob/master/src/math/unsafe.go?name=release#10" title="View Source">Float32bits</a> </h2>
|
||
<pre class="funcdecl">func Float32bits(f <a href="builtin.htm#float32">float32</a>) <a href="builtin.htm#uint32">uint32</a></pre>
|
||
<p>函数返回浮点数f的IEEE 754格式二进制表示对应的4字节无符号整数。</p>
|
||
<h2 id="Float32frombits">func <a href="https://github.com/golang/go/blob/master/src/math/unsafe.go?name=release#14" title="View Source">Float32frombits</a> </h2>
|
||
<pre class="funcdecl">func Float32frombits(b <a href="builtin.htm#uint32">uint32</a>) <a href="builtin.htm#float32">float32</a></pre>
|
||
<p>函数返回无符号整数b对应的IEEE 754格式二进制表示的4字节浮点数。</p>
|
||
<h2 id="Float64bits">func <a href="https://github.com/golang/go/blob/master/src/math/unsafe.go?name=release#17" title="View Source">Float64bits</a> </h2>
|
||
<pre class="funcdecl">func Float64bits(f <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#uint64">uint64</a></pre>
|
||
<p>函数返回浮点数f的IEEE 754格式二进制表示对应的8字节无符号整数。</p>
|
||
<h2 id="Float64frombits">func <a href="https://github.com/golang/go/blob/master/src/math/unsafe.go?name=release#21" title="View Source">Float64frombits</a> </h2>
|
||
<pre class="funcdecl">func Float64frombits(b <a href="builtin.htm#uint64">uint64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>函数返回无符号整数b对应的IEEE 754格式二进制表示的8字节浮点数。</p>
|
||
<h2 id="Signbit">func <a href="https://github.com/golang/go/blob/master/src/math/signbit.go?name=release#8" title="View Source">Signbit</a> </h2>
|
||
<pre class="funcdecl">func Signbit(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#bool">bool</a></pre>
|
||
<p>如果x是一个负数或者负零,返回真。</p>
|
||
<h2 id="Copysign">func <a href="https://github.com/golang/go/blob/master/src/math/copysign.go?name=release#9" title="View Source">Copysign</a> </h2>
|
||
<pre class="funcdecl">func Copysign(x, y <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>返回拥有x的量值(绝对值)和y的标志位(正负号)的浮点数。</p>
|
||
<h2 id="Ceil">func <a href="https://github.com/golang/go/blob/master/src/math/floor.go?name=release#36" title="View Source">Ceil</a> </h2>
|
||
<pre class="funcdecl">func Ceil(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>返回不小于x的最小整数(的浮点值),特例如下:</p>
|
||
<pre>Ceil(±0) = ±0
|
||
Ceil(±Inf) = ±Inf
|
||
Ceil(NaN) = NaN</pre>
|
||
<h2 id="Floor">func <a href="https://github.com/golang/go/blob/master/src/math/floor.go?name=release#13" title="View Source">Floor</a> </h2>
|
||
<pre class="funcdecl">func Floor(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>返回不大于x的最大整数(的浮点值),特例如下:</p>
|
||
<pre>Floor(±0) = ±0
|
||
Floor(±Inf) = ±Inf
|
||
Floor(NaN) = NaN</pre>
|
||
<h2 id="Trunc">func <a href="https://github.com/golang/go/blob/master/src/math/floor.go?name=release#48" title="View Source">Trunc</a> </h2>
|
||
<pre class="funcdecl">func Trunc(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>返回x的整数部分(的浮点值)。特例如下:</p>
|
||
<pre>Trunc(±0) = ±0
|
||
Trunc(±Inf) = ±Inf
|
||
Trunc(NaN) = NaN</pre>
|
||
<h2 id="Modf">func <a href="https://github.com/golang/go/blob/master/src/math/modf.go?name=release#13" title="View Source">Modf</a> </h2>
|
||
<pre class="funcdecl">func Modf(f <a href="builtin.htm#float64">float64</a>) (int <a href="builtin.htm#float64">float64</a>, frac <a href="builtin.htm#float64">float64</a>)</pre>
|
||
<p>返回f的整数部分和小数部分,结果的正负号和都x相同;特例如下:</p>
|
||
<pre>Modf(±Inf) = ±Inf, NaN
|
||
Modf(NaN) = NaN, NaN</pre>
|
||
<h2 id="Nextafter">func <a href="https://github.com/golang/go/blob/master/src/math/nextafter.go?name=release#13" title="View Source">Nextafter</a> </h2>
|
||
<pre class="funcdecl">func Nextafter(x, y <a href="builtin.htm#float64">float64</a>) (r <a href="builtin.htm#float64">float64</a>)</pre>
|
||
<p>参数x到参数y的方向上,下一个可表示的数值;如果x==y将返回x。特例如下:</p>
|
||
<pre>Nextafter(NaN, y) = NaN
|
||
Nextafter(x, NaN) = NaN</pre>
|
||
<h2 id="Abs">func <a href="https://github.com/golang/go/blob/master/src/math/abs.go?name=release#12" title="View Source">Abs</a> </h2>
|
||
<pre class="funcdecl">func Abs(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>返回x的绝对值;特例如下:</p>
|
||
<pre>Abs(±Inf) = +Inf
|
||
Abs(NaN) = NaN</pre>
|
||
<h2 id="Max">func <a href="https://github.com/golang/go/blob/master/src/math/dim.go?name=release#26" title="View Source">Max</a> </h2>
|
||
<pre class="funcdecl">func Max(x, y <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>返回x和y中最大值,特例如下:</p>
|
||
<pre>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</pre>
|
||
<h2 id="Min">func <a href="https://github.com/golang/go/blob/master/src/math/dim.go?name=release#53" title="View Source">Min</a> </h2>
|
||
<pre class="funcdecl">func Min(x, y <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>返回x和y中最小值,特例如下:</p>
|
||
<pre>Min(x, -Inf) = Min(-Inf, x) = -Inf
|
||
Min(x, NaN) = Min(NaN, x) = NaN
|
||
Min(-0, ±0) = Min(±0, -0) = -0</pre>
|
||
<h2 id="Dim">func <a href="https://github.com/golang/go/blob/master/src/math/dim.go?name=release#13" title="View Source">Dim</a> </h2>
|
||
<pre class="funcdecl">func Dim(x, y <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>函数返回x-y和0中的最大值,特殊情况:</p>
|
||
<pre>Dim(+Inf, +Inf) = NaN
|
||
Dim(-Inf, -Inf) = NaN
|
||
Dim(x, NaN) = Dim(NaN, x) = NaN</pre>
|
||
<h2 id="Mod">func <a href="https://github.com/golang/go/blob/master/src/math/mod.go?name=release#21" title="View Source">Mod</a> </h2>
|
||
<pre class="funcdecl">func Mod(x, y <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>取余运算,可以理解为 x-Trunc(x/y)*y,结果的正负号和x相同;特例如下:</p>
|
||
<pre>Mod(±Inf, y) = NaN
|
||
Mod(NaN, y) = NaN
|
||
Mod(x, 0) = NaN
|
||
Mod(x, ±Inf) = x
|
||
Mod(x, NaN) = NaN</pre>
|
||
<h2 id="Remainder">func <a href="https://github.com/golang/go/blob/master/src/math/remainder.go?name=release#37" title="View Source">Remainder</a> </h2>
|
||
<pre class="funcdecl">func Remainder(x, y <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>IEEE 754差数求值,即x减去最接近x/y的整数值(如果有两个整数与x/y距离相同,则取其中的偶数)与y的乘积。特例如下:</p>
|
||
<pre>Remainder(±Inf, y) = NaN
|
||
Remainder(NaN, y) = NaN
|
||
Remainder(x, 0) = NaN
|
||
Remainder(x, ±Inf) = x
|
||
Remainder(x, NaN) = NaN</pre>
|
||
<h2 id="Sqrt">func <a href="https://github.com/golang/go/blob/master/src/math/sqrt.go?name=release#92" title="View Source">Sqrt</a> </h2>
|
||
<pre class="funcdecl">func Sqrt(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>返回x的二次方根,特例如下:</p>
|
||
<pre>Sqrt(+Inf) = +Inf
|
||
Sqrt(±0) = ±0
|
||
Sqrt(x < 0) = NaN
|
||
Sqrt(NaN) = NaN</pre>
|
||
<h2 id="Cbrt">func <a href="https://github.com/golang/go/blob/master/src/math/cbrt.go?name=release#21" title="View Source">Cbrt</a> </h2>
|
||
<pre class="funcdecl">func Cbrt(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>返回x的三次方根,特例如下:</p>
|
||
<pre>Cbrt(±0) = ±0
|
||
Cbrt(±Inf) = ±Inf
|
||
Cbrt(NaN) = NaN</pre>
|
||
<h2 id="Hypot">func <a href="https://github.com/golang/go/blob/master/src/math/hypot.go?name=release#19" title="View Source">Hypot</a> </h2>
|
||
<pre class="funcdecl">func Hypot(p, q <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>返回Sqrt(p*p + q*q),注意要避免不必要的溢出或下溢。特例如下:</p>
|
||
<pre>Hypot(±Inf, q) = +Inf
|
||
Hypot(p, ±Inf) = +Inf
|
||
Hypot(NaN, q) = NaN
|
||
Hypot(p, NaN) = NaN</pre>
|
||
<h2 id="Sin">func <a href="https://github.com/golang/go/blob/master/src/math/sin.go?name=release#174" title="View Source">Sin</a> </h2>
|
||
<pre class="funcdecl">func Sin(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>求正弦。特例如下:</p>
|
||
<pre>Sin(±0) = ±0
|
||
Sin(±Inf) = NaN
|
||
Sin(NaN) = NaN</pre>
|
||
<h2 id="Cos">func <a href="https://github.com/golang/go/blob/master/src/math/sin.go?name=release#117" title="View Source">Cos</a> </h2>
|
||
<pre class="funcdecl">func Cos(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>求余弦。特例如下:</p>
|
||
<pre>Cos(±Inf) = NaN
|
||
Cos(NaN) = NaN</pre>
|
||
<h2 id="Tan">func <a href="https://github.com/golang/go/blob/master/src/math/tan.go?name=release#82" title="View Source">Tan</a> </h2>
|
||
<pre class="funcdecl">func Tan(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>求正切。特例如下:</p>
|
||
<pre>Tan(±0) = ±0
|
||
Tan(±Inf) = NaN
|
||
Tan(NaN) = NaN</pre>
|
||
<h2 id="Sincos">func <a href="https://github.com/golang/go/blob/master/src/math/sincos.go?name=release#15" title="View Source">Sincos</a> </h2>
|
||
<pre class="funcdecl">func Sincos(x <a href="builtin.htm#float64">float64</a>) (sin, cos <a href="builtin.htm#float64">float64</a>)</pre>
|
||
<p>函数返回Sin(x), Cos(x)。特例如下:</p>
|
||
<pre>Sincos(±0) = ±0, 1
|
||
Sincos(±Inf) = NaN, NaN
|
||
Sincos(NaN) = NaN, NaN</pre>
|
||
<h2 id="Asin">func <a href="https://github.com/golang/go/blob/master/src/math/asin.go?name=release#19" title="View Source">Asin</a> </h2>
|
||
<pre class="funcdecl">func Asin(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>求反正弦(x是弧度)。特例如下:</p>
|
||
<pre>Asin(±0) = ±0
|
||
Asin(x) = NaN if x < -1 or x > 1
|
||
</pre>
|
||
<h2 id="Acos">func <a href="https://github.com/golang/go/blob/master/src/math/asin.go?name=release#51" title="View Source">Acos</a> </h2>
|
||
<pre class="funcdecl">func Acos(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>求反余弦(x是弧度)。特例如下:</p>
|
||
<pre>Acos(x) = NaN if x < -1 or x > 1
|
||
</pre>
|
||
<h2 id="Atan">func <a href="https://github.com/golang/go/blob/master/src/math/atan.go?name=release#95" title="View Source">Atan</a> </h2>
|
||
<pre class="funcdecl">func Atan(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>求反正切(x是弧度)。特例如下:</p>
|
||
<pre>Atan(±0) = ±0
|
||
Atan(±Inf) = ±Pi/2</pre>
|
||
<h2 id="Atan2">func <a href="https://github.com/golang/go/blob/master/src/math/atan2.go?name=release#29" title="View Source">Atan2</a> </h2>
|
||
<pre class="funcdecl">func Atan2(y, x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>类似Atan(y/x),但会根据x,y的正负号确定象限。特例如下(前面的优先):</p>
|
||
<pre>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</pre>
|
||
<h2 id="Sinh">func <a href="https://github.com/golang/go/blob/master/src/math/sinh.go?name=release#25" title="View Source">Sinh</a> </h2>
|
||
<pre class="funcdecl">func Sinh(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>求双曲正弦,特例如下:</p>
|
||
<pre>Sinh(±0) = ±0
|
||
Sinh(±Inf) = ±Inf
|
||
Sinh(NaN) = NaN</pre>
|
||
<h2 id="Cosh">func <a href="https://github.com/golang/go/blob/master/src/math/sinh.go?name=release#69" title="View Source">Cosh</a> </h2>
|
||
<pre class="funcdecl">func Cosh(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>求双曲余弦,特例如下:</p>
|
||
<pre>Cosh(±0) = 1
|
||
Cosh(±Inf) = +Inf
|
||
Cosh(NaN) = NaN</pre>
|
||
<h2 id="Tanh">func <a href="https://github.com/golang/go/blob/master/src/math/tanh.go?name=release#74" title="View Source">Tanh</a> </h2>
|
||
<pre class="funcdecl">func Tanh(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>求双曲正切,特例如下:</p>
|
||
<pre>Tanh(±0) = ±0
|
||
Tanh(±Inf) = ±1
|
||
Tanh(NaN) = NaN</pre>
|
||
<h2 id="Asinh">func <a href="https://github.com/golang/go/blob/master/src/math/asinh.go?name=release#39" title="View Source">Asinh</a> </h2>
|
||
<pre class="funcdecl">func Asinh(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>求反双曲正弦,特例如下:</p>
|
||
<pre>Asinh(±0) = ±0
|
||
Asinh(±Inf) = ±Inf
|
||
Asinh(NaN) = NaN</pre>
|
||
<h2 id="Acosh">func <a href="https://github.com/golang/go/blob/master/src/math/acosh.go?name=release#42" title="View Source">Acosh</a> </h2>
|
||
<pre class="funcdecl">func Acosh(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>求反双曲余弦,特例如下:</p>
|
||
<pre>Acosh(+Inf) = +Inf
|
||
Acosh(x) = NaN if x < 1
|
||
Acosh(NaN) = NaN</pre>
|
||
<h2 id="Atanh">func <a href="https://github.com/golang/go/blob/master/src/math/atanh.go?name=release#47" title="View Source">Atanh</a> </h2>
|
||
<pre class="funcdecl">func Atanh(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>求反双曲正切,特例如下:</p>
|
||
<pre>Atanh(1) = +Inf
|
||
Atanh(±0) = ±0
|
||
Atanh(-1) = -Inf
|
||
Atanh(x) = NaN if x < -1 or x > 1
|
||
Atanh(NaN) = NaN</pre>
|
||
<h2 id="Log">func <a href="https://github.com/golang/go/blob/master/src/math/log.go?name=release#80" title="View Source">Log</a> </h2>
|
||
<pre class="funcdecl">func Log(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>求自然对数,特例如下:</p>
|
||
<pre>Log(+Inf) = +Inf
|
||
Log(0) = -Inf
|
||
Log(x < 0) = NaN
|
||
Log(NaN) = NaN</pre>
|
||
<h2 id="Log1p">func <a href="https://github.com/golang/go/blob/master/src/math/log1p.go?name=release#95" title="View Source">Log1p</a> </h2>
|
||
<pre class="funcdecl">func Log1p(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>等价于Log(1+x)。但是在x接近0时,本函数更加精确;特例如下:</p>
|
||
<pre>Log1p(+Inf) = +Inf
|
||
Log1p(±0) = ±0
|
||
Log1p(-1) = -Inf
|
||
Log1p(x < -1) = NaN
|
||
Log1p(NaN) = NaN</pre>
|
||
<h2 id="Log2">func <a href="https://github.com/golang/go/blob/master/src/math/log10.go?name=release#17" title="View Source">Log2</a> </h2>
|
||
<pre class="funcdecl">func Log2(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>求2为底的对数;特例和Log相同。</p>
|
||
<h2 id="Log10">func <a href="https://github.com/golang/go/blob/master/src/math/log10.go?name=release#9" title="View Source">Log10</a> </h2>
|
||
<pre class="funcdecl">func Log10(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>求10为底的对数;特例和Log相同。</p>
|
||
<h2 id="Logb">func <a href="https://github.com/golang/go/blob/master/src/math/logb.go?name=release#13" title="View Source">Logb</a> </h2>
|
||
<pre class="funcdecl">func Logb(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>返回x的二进制指数值,可以理解为Trunc(Log2(x));特例如下:</p>
|
||
<pre>Logb(±Inf) = +Inf
|
||
Logb(0) = -Inf
|
||
Logb(NaN) = NaN</pre>
|
||
<h2 id="Ilogb">func <a href="https://github.com/golang/go/blob/master/src/math/logb.go?name=release#32" title="View Source">Ilogb</a> </h2>
|
||
<pre class="funcdecl">func Ilogb(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#int">int</a></pre>
|
||
<p>类似Logb,但返回值是整型;特例如下:</p>
|
||
<pre>Ilogb(±Inf) = MaxInt32
|
||
Ilogb(0) = MinInt32
|
||
Ilogb(NaN) = MaxInt32</pre>
|
||
<h2 id="Frexp">func <a href="https://github.com/golang/go/blob/master/src/math/frexp.go?name=release#16" title="View Source">Frexp</a> </h2>
|
||
<pre class="funcdecl">func Frexp(f <a href="builtin.htm#float64">float64</a>) (frac <a href="builtin.htm#float64">float64</a>, exp <a href="builtin.htm#int">int</a>)</pre>
|
||
<p>返回一个标准化小数frac和2的整型指数exp,满足f == frac * 2**exp,且0.5 <= Abs(frac) < 1;特例如下:</p>
|
||
<pre>Frexp(±0) = ±0, 0
|
||
Frexp(±Inf) = ±Inf, 0
|
||
Frexp(NaN) = NaN, 0</pre>
|
||
<h2 id="Ldexp">func <a href="https://github.com/golang/go/blob/master/src/math/ldexp.go?name=release#14" title="View Source">Ldexp</a> </h2>
|
||
<pre class="funcdecl">func Ldexp(frac <a href="builtin.htm#float64">float64</a>, exp <a href="builtin.htm#int">int</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>Frexp的反函数,返回 frac * 2**exp。特例如下:</p>
|
||
<pre>Ldexp(±0, exp) = ±0
|
||
Ldexp(±Inf, exp) = ±Inf
|
||
Ldexp(NaN, exp) = NaN</pre>
|
||
<h2 id="Exp">func <a href="https://github.com/golang/go/blob/master/src/math/exp.go?name=release#14" title="View Source">Exp</a> </h2>
|
||
<pre class="funcdecl">func Exp(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>返回E**x;x绝对值很大时可能会溢出为0或者+Inf,x绝对值很小时可能会下溢为1。特例如下:</p>
|
||
<pre>Exp(+Inf) = +Inf
|
||
Exp(NaN) = NaN</pre>
|
||
<h2 id="Expm1">func <a href="https://github.com/golang/go/blob/master/src/math/expm1.go?name=release#124" title="View Source">Expm1</a> </h2>
|
||
<pre class="funcdecl">func Expm1(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>等价于Exp(x)-1,但是在x接近零时更精确;x绝对值很大时可能会溢出为-1或+Inf。特例如下:</p>
|
||
<pre>Expm1(+Inf) = +Inf
|
||
Expm1(-Inf) = -1
|
||
Expm1(NaN) = NaN</pre>
|
||
<h2 id="Exp2">func <a href="https://github.com/golang/go/blob/master/src/math/exp.go?name=release#135" title="View Source">Exp2</a> </h2>
|
||
<pre class="funcdecl">func Exp2(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>返回2**x;特例和Exp相同。</p>
|
||
<h2 id="Pow">func <a href="https://github.com/golang/go/blob/master/src/math/pow.go?name=release#38" title="View Source">Pow</a> </h2>
|
||
<pre class="funcdecl">func Pow(x, y <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>返回x**y;特例如下(前面的优先):</p>
|
||
<pre>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
|
||
</pre>
|
||
<h2 id="Pow10">func <a href="https://github.com/golang/go/blob/master/src/math/pow10.go?name=release#16" title="View Source">Pow10</a> </h2>
|
||
<pre class="funcdecl">func Pow10(e <a href="builtin.htm#int">int</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>返回10**e;特例如下:</p>
|
||
<pre>Pow10(e) = +Inf for e > 309
|
||
Pow10(e) = 0 for e < -324
|
||
</pre>
|
||
<h2 id="Gamma">func <a href="https://github.com/golang/go/blob/master/src/math/gamma.go?name=release#122" title="View Source">Gamma</a> </h2>
|
||
<pre class="funcdecl">func Gamma(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>伽玛函数(当x为正整数时,值为(x-1)!)。特例如下:</p>
|
||
<pre>Gamma(+Inf) = +Inf
|
||
Gamma(+0) = +Inf
|
||
Gamma(-0) = -Inf
|
||
Gamma(x) = NaN for integer x < 0
|
||
Gamma(-Inf) = NaN
|
||
Gamma(NaN) = NaN</pre>
|
||
<h2 id="Lgamma">func <a href="https://github.com/golang/go/blob/master/src/math/lgamma.go?name=release#174" title="View Source">Lgamma</a> </h2>
|
||
<pre class="funcdecl">func Lgamma(x <a href="builtin.htm#float64">float64</a>) (lgamma <a href="builtin.htm#float64">float64</a>, sign <a href="builtin.htm#int">int</a>)</pre>
|
||
<p>返回Gamma(x)的自然对数和正负号。特例如下:</p>
|
||
<pre>Lgamma(+Inf) = +Inf
|
||
Lgamma(0) = +Inf
|
||
Lgamma(-integer) = +Inf
|
||
Lgamma(-Inf) = -Inf
|
||
Lgamma(NaN) = NaN</pre>
|
||
<h2 id="Erf">func <a href="https://github.com/golang/go/blob/master/src/math/erf.go?name=release#188" title="View Source">Erf</a> </h2>
|
||
<pre class="funcdecl">func Erf(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>误差函数,特例如下:</p>
|
||
<pre>Erf(+Inf) = 1
|
||
Erf(-Inf) = -1
|
||
Erf(NaN) = NaN</pre>
|
||
<h2 id="Erfc">func <a href="https://github.com/golang/go/blob/master/src/math/erf.go?name=release#265" title="View Source">Erfc</a> </h2>
|
||
<pre class="funcdecl">func Erfc(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>余补误差函数,特例如下:</p>
|
||
<pre>Erfc(+Inf) = 0
|
||
Erfc(-Inf) = 2
|
||
Erfc(NaN) = NaN</pre>
|
||
<h2 id="J0">func <a href="https://github.com/golang/go/blob/master/src/math/j0.go?name=release#76" title="View Source">J0</a> </h2>
|
||
<pre class="funcdecl">func J0(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>第一类贝塞尔函数,0阶。特例如下:</p>
|
||
<pre>J0(±Inf) = 0
|
||
J0(0) = 1
|
||
J0(NaN) = NaN</pre>
|
||
<h2 id="J1">func <a href="https://github.com/golang/go/blob/master/src/math/j1.go?name=release#74" title="View Source">J1</a> </h2>
|
||
<pre class="funcdecl">func J1(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>第一类贝塞尔函数,1阶。特例如下:</p>
|
||
<pre>J1(±Inf) = 0
|
||
J1(NaN) = NaN</pre>
|
||
<h2 id="Jn">func <a href="https://github.com/golang/go/blob/master/src/math/jn.go?name=release#53" title="View Source">Jn</a> </h2>
|
||
<pre class="funcdecl">func Jn(n <a href="builtin.htm#int">int</a>, x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>第一类贝塞尔函数,n阶。特例如下:</p>
|
||
<pre>Jn(n, ±Inf) = 0
|
||
Jn(n, NaN) = NaN</pre>
|
||
<h2 id="Y0">func <a href="https://github.com/golang/go/blob/master/src/math/j0.go?name=release#156" title="View Source">Y0</a> </h2>
|
||
<pre class="funcdecl">func Y0(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>第二类贝塞尔函数,0阶。特例如下:</p>
|
||
<pre>Y0(+Inf) = 0
|
||
Y0(0) = -Inf
|
||
Y0(x < 0) = NaN
|
||
Y0(NaN) = NaN</pre>
|
||
<h2 id="Y1">func <a href="https://github.com/golang/go/blob/master/src/math/j1.go?name=release#154" title="View Source">Y1</a> </h2>
|
||
<pre class="funcdecl">func Y1(x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>第二类贝塞尔函数,1阶。特例如下:</p>
|
||
<pre>Y1(+Inf) = 0
|
||
Y1(0) = -Inf
|
||
Y1(x < 0) = NaN
|
||
Y1(NaN) = NaN</pre>
|
||
<h2 id="Yn">func <a href="https://github.com/golang/go/blob/master/src/math/jn.go?name=release#235" title="View Source">Yn</a> </h2>
|
||
<pre class="funcdecl">func Yn(n <a href="builtin.htm#int">int</a>, x <a href="builtin.htm#float64">float64</a>) <a href="builtin.htm#float64">float64</a></pre>
|
||
<p>第二类贝塞尔函数,n阶。特例如下:</p>
|
||
<pre>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</pre>
|
||
</div> |