Documentation
¶
Overview ¶
mathパッケージは基本的な定数と数学的な関数を提供します。
このパッケージはアーキテクチャ間でビットが完全に同じ結果になることを保証しません。
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 Cbrt(x float64) float64
- func Ceil(x float64) float64
- func Copysign(f, sign float64) float64
- func Cos(x float64) float64
- func Cosh(x float64) float64
- func Dim(x, y float64) float64
- func Erf(x float64) float64
- func Erfc(x float64) float64
- func Erfcinv(x float64) float64
- func Erfinv(x float64) float64
- func Exp(x float64) float64
- func Exp2(x float64) float64
- func Expm1(x float64) float64
- func FMA(x, y, z 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 Gamma(x float64) float64
- func Hypot(p, q float64) float64
- func Ilogb(x float64) int
- func Inf(sign int) float64
- func IsInf(f float64, sign int) bool
- func IsNaN(f float64) (is bool)
- func J0(x float64) float64
- func J1(x float64) float64
- func Jn(n int, x float64) float64
- func Ldexp(frac float64, exp int) float64
- func Lgamma(x float64) (lgamma float64, sign int)
- func Log(x float64) float64
- func Log10(x float64) float64
- func Log1p(x float64) float64
- func Log2(x float64) float64
- func Logb(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 float64, frac float64)
- func NaN() float64
- func Nextafter(x, y float64) (r float64)
- func Nextafter32(x, y float32) (r float32)
- func Pow(x, y float64) float64
- func Pow10(n int) float64
- func Remainder(x, y float64) float64
- func Round(x float64) float64
- func RoundToEven(x float64) float64
- func Signbit(x float64) bool
- func Sin(x float64) float64
- func Sincos(x float64) (sin, cos 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
- func Y0(x float64) float64
- func Y1(x float64) float64
- func Yn(n int, x float64) float64
Examples ¶
Constants ¶
const ( E = 2.71828182845904523536028747135266249775724709369995957496696763 Pi = 3.14159265358979323846264338327950288419716939937510582097494459 Phi = 1.61803398874989484820458683436563811772030917980576286213544862 Sqrt2 = 1.41421356237309504880168872420969807856967187537694807317667974 SqrtE = 1.64872127070012814684865078781416357165377610071014801157507931 SqrtPi = 1.77245385090551602729816748334114518279754945612238712821380779 SqrtPhi = 1.27201964951406896425242246173749149171560804184009624861664038 Ln2 = 0.693147180559945309417232121458176568075500134360255254120680009 Log2E = 1 / Ln2 Ln10 = 2.30258509299404568401799145468436420760110148862877297603332790 Log10E = 1 / Ln10 )
数学定数。
const ( MaxFloat32 = 0x1p127 * (1 + (1 - 0x1p-23)) SmallestNonzeroFloat32 = 0x1p-126 * 0x1p-23 MaxFloat64 = 0x1p1023 * (1 + (1 - 0x1p-52)) SmallestNonzeroFloat64 = 0x1p-1022 * 0x1p-52 )
浮動小数点の制限値。 Max はその型で表現可能な最大の有限値です。 SmallestNonzero はその型で表現可能な最小の正の0以外の値です。
const ( MaxInt = 1<<(intSize-1) - 1 MinInt = -1 << (intSize - 1) 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 MaxUint = 1<<intSize - 1 MaxUint8 = 1<<8 - 1 MaxUint16 = 1<<16 - 1 MaxUint32 = 1<<32 - 1 MaxUint64 = 1<<64 - 1 )
整数の上限値。
Variables ¶
This section is empty.
Functions ¶
func Abs ¶
Absはxの絶対値を返します。
特殊な場合は以下のようになります:
Abs(±Inf) = +Inf Abs(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { x := math.Abs(-2) fmt.Printf("%.1f\n", x) y := math.Abs(2) fmt.Printf("%.1f\n", y) }
Output: 2.0 2.0
func Acos ¶
Acosは、xのarccosine(ラジアン単位)を返します。
特殊な場合は以下です:
Acos(x) = NaN if x < -1 or x > 1
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f", math.Acos(1)) }
Output: 0.00
func Acosh ¶
Acoshはxの逆双曲線余弦を返します。
特殊な場合は以下の通りです:
Acosh(+Inf) = +Inf Acosh(x) = NaN if x < 1 Acosh(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f", math.Acosh(1)) }
Output: 0.00
func Asin ¶
Asinは、xの弧度法におけるアークサインを返します。
特別なケースは次のとおりです:
Asin(±0) = ±0 Asin(x) = NaN if x < -1 or x > 1
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f", math.Asin(0)) }
Output: 0.00
func Asinh ¶
Asinhはxの逆双曲線正弦を返します。
特殊なケースは:
Asinh(±0) = ±0 Asinh(±Inf) = ±Inf Asinh(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f", math.Asinh(0)) }
Output: 0.00
func Atan ¶
Atanはxのアークタンジェント(ラジアン)を返します。
特殊なケースは以下の通りです:
Atan(±0) = ±0 Atan(±Inf) = ±Pi/2
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f", math.Atan(0)) }
Output: 0.00
func Atan2 ¶
Atan2は、y/xの逆正接を返します。戻り値の象限を決定するために、二つの符号を使用します。
特殊なケースは以下の通りです:
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
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f", math.Atan2(0, 0)) }
Output: 0.00
func Atanh ¶
Atanhはxの逆双曲線正接を返します。
特別な場合は次のとおりです:
Atanh(1) = +Inf Atanh(±0) = ±0 Atanh(-1) = -Inf Atanh(x) = NaN if x < -1 or x > 1 Atanh(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f", math.Atanh(0)) }
Output: 0.00
func Cbrt ¶
Cbrtはxの立方根を返します。
特殊なケースは次の通りです:
Cbrt(±0) = ±0 Cbrt(±Inf) = ±Inf Cbrt(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f\n", math.Cbrt(8)) fmt.Printf("%.2f\n", math.Cbrt(27)) }
Output: 2.00 3.00
func Ceil ¶
Ceil(天井)は、x以上の最小の整数値を返します。
特別なケースは:
Ceil(±0) = ±0 Ceil(±Inf) = ±Inf Ceil(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { c := math.Ceil(1.49) fmt.Printf("%.1f", c) }
Output: 2.0
func Copysign ¶
Copysign は f の絶対値と sign の符号を持つ値を返す。
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f", math.Copysign(3.2, -1)) }
Output: -3.20
func Cos ¶
Cosは、ラジアンの引数xの余弦を返します。
特殊な場合は:
Cos(±Inf) = NaN Cos(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f", math.Cos(math.Pi/2)) }
Output: 0.00
func Cosh ¶
Coshはxの双曲線余弦を返します。
特殊なケースは以下の通りです:
Cosh(±0) = 1 Cosh(±Inf) = +Inf Cosh(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f", math.Cosh(0)) }
Output: 1.00
func Dim ¶
Dim関数は、x-yまたは0のうちの大きい方を返します。
特別なケースは以下の通りです:
Dim(+Inf, +Inf) = NaN Dim(-Inf, -Inf) = NaN Dim(x, NaN) = Dim(NaN, x) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f\n", math.Dim(4, -2)) fmt.Printf("%.2f\n", math.Dim(-4, 2)) }
Output: 6.00 0.00
func Erfcinv ¶ added in v1.10.0
Erfcinvは Erfc(x)の逆関数を返します。
特殊な場合は以下の通りです:
Erfcinv(0) = +Inf Erfcinv(2) = -Inf Erfcinv(x) = NaN if x < 0 or x > 2 Erfcinv(NaN) = NaN
func Erfinv ¶ added in v1.10.0
Erfinvはxの逆誤差関数を返します。
特殊なケースは以下の通りです:
Erfinv(1) = +Inf Erfinv(-1) = -Inf Erfinv(x) = NaN if x < -1 or x > 1 Erfinv(NaN) = NaN
func Exp ¶
Expはe**x、つまりxの自然対数の底eによる指数関数です。
特殊な場合は次の通りです:
Exp(+Inf) = +Inf Exp(NaN) = NaN
非常に大きな値は0または+Infにオーバーフローします。 非常に小さい値は1にアンダーフローします。
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f\n", math.Exp(1)) fmt.Printf("%.2f\n", math.Exp(2)) fmt.Printf("%.2f\n", math.Exp(-1)) }
Output: 2.72 7.39 0.37
func Exp2 ¶
Exp2はxの2の累乗(2**x)を返します。
特殊なケースは Exp と同じです。
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f\n", math.Exp2(1)) fmt.Printf("%.2f\n", math.Exp2(-3)) }
Output: 2.00 0.12
func Expm1 ¶
Expm1はxの自然対数e**x - 1を返します。 xがほぼゼロの場合、 Exp(x) - 1よりも精度が高くなります。
特殊なケースは以下の通りです:
Expm1(+Inf) = +Inf Expm1(-Inf) = -1 Expm1(NaN) = NaN
非常に大きな値は-1または+Infにオーバーフローします。
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.6f\n", math.Expm1(0.01)) fmt.Printf("%.6f\n", math.Expm1(-1)) }
Output: 0.010050 -0.632121
func FMA ¶ added in v1.14.0
FMAは、一度の丸めのみを使用して計算されたx * y + zを返します。 (つまり、FMAはx、y、およびzの融合乗算-加算結果を返します。)
func Float32bits ¶
Float32bitsは、fのIEEE 754バイナリ表現を返します。 fの符号ビットと結果は同じビット位置にあります。 Float32bits(Float32frombits(x)) == x.
func Float32frombits ¶
Float32frombitsは、符号ビットの位置が同じであるように IEEE 754バイナリ表現bに対応する浮動小数点数を返します。 Float32frombits(Float32bits(x))== x。
func Float64bits ¶
Float64bitsは、fのIEEE 754バイナリ表現を返します。 fの符号ビットと結果が同じビット位置になります。 また、Float64bits(Float64frombits(x)) == x となります。
func Float64frombits ¶
Float64frombitsは、IEEE 754のバイナリ表現bに対応する浮動小数点数を返します。bの符号ビットと結果は同じビット位置にあります。 Float64frombits(Float64bits(x)) == x.
func Floor ¶
Floorはx以下の最大の整数値を返します。
特殊なケースは次の通りです:
Floor(±0) = ±0 Floor(±Inf) = ±Inf Floor(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { c := math.Floor(1.51) fmt.Printf("%.1f", c) }
Output: 1.0
func Frexp ¶
Frexpは、fを正規化された分数と2の整数冪に分解します。 それは、f == frac × 2**expを満たすfracとexpを返します。 fracの絶対値は[½, 1)の範囲にあります。
特殊な場合は以下の通りです:
Frexp(±0) = ±0, 0 Frexp(±Inf) = ±Inf, 0 Frexp(NaN) = NaN, 0
func Gamma ¶
Gammaはxのガンマ関数を返します。
特殊な場合は以下の通りです:
Gamma(+Inf) = +Inf Gamma(+0) = +Inf Gamma(-0) = -Inf Gamma(x) = NaN for integer x < 0 Gamma(-Inf) = NaN Gamma(NaN) = NaN
func Hypot ¶
Hypotは Sqrt(p*p + q*q) を返します。不必要なオーバーフローやアンダーフローを避けるように注意します。
特殊な場合は以下の通りです:
Hypot(±Inf, q) = +Inf Hypot(p, ±Inf) = +Inf Hypot(NaN, q) = NaN Hypot(p, NaN) = NaN
func Ilogb ¶
Ilogbはxのバイナリ指数を整数として返します。
特殊なケースは以下の通りです:
Ilogb(±Inf) = MaxInt32 Ilogb(0) = MinInt32 Ilogb(NaN) = MaxInt32
func IsInf ¶
IsInfは、fが無限大であるかどうかをsignに基づいて報告します。 sign > 0の場合、fが正の無限大であるかどうかを報告します。 sign < 0の場合、fが負の無限大であるかどうかを報告します。 sign == 0の場合、fがどちらかの無限大であるかどうかを報告します。
func Ldexp ¶
Ldexpは Frexp の逆です。 それはfrac × 2 ** expを返します。
特別なケースは以下の通りです:
Ldexp(±0, exp) = ±0 Ldexp(±Inf, exp) = ±Inf Ldexp(NaN, exp) = NaN
func Lgamma ¶
Lgammaは Gamma(x)の自然対数と符号(-1または+1)を返します。
特殊なケースは以下の通りです:
Lgamma(+Inf) = +Inf Lgamma(0) = +Inf Lgamma(-integer) = +Inf Lgamma(-Inf) = -Inf Lgamma(NaN) = NaN
func Log ¶
Logはxの自然対数を返します。
特別なケースは以下の通りです:
Log(+Inf) = +Inf Log(0) = -Inf Log(x < 0) = NaN Log(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { x := math.Log(1) fmt.Printf("%.1f\n", x) y := math.Log(2.7183) fmt.Printf("%.1f\n", y) }
Output: 0.0 1.0
func Log10 ¶
Log10 は x の 10 を底とする対数(常用対数)を返します。 特殊な場合は Log と同じです。
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.1f", math.Log10(100)) }
Output: 2.0
func Log1p ¶
Log1pは引数xの1を加えたものの自然対数を返します。 xがゼロに近い場合、 Log(1 + x)よりも正確です。
特殊な場合は次のとおりです:
Log1p(+Inf) = +Inf Log1p(±0) = ±0 Log1p(-1) = -Inf Log1p(x < -1) = NaN Log1p(NaN) = NaN
func Log2 ¶
Log2 は x の二進対数を返します。 特殊な場合は Log と同じです。
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.1f", math.Log2(256)) }
Output: 8.0
func Max ¶
Maxは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
なお、これはNaNと+Infの場合に組み込み関数maxとは異なります。
func Min ¶
Min関数は、xとyのうち小さい方を返します。
特殊な場合は以下の通りです:
Min(x, -Inf) = Min(-Inf, x) = -Inf Min(x, NaN) = Min(NaN, x) = NaN Min(-0, ±0) = Min(±0, -0) = -0
注意:これは、NaNと-Infを引数にして呼び出すと、組み込みのmin関数とは異なる結果になります。
func Mod ¶
Modはx/yの浮動小数点の余りを返します。 結果の絶対値はyより小さく、符号はxと一致します。
特殊なケースは次のとおりです:
Mod(±Inf, y) = NaN Mod(NaN, y) = NaN Mod(x, 0) = NaN Mod(x, ±Inf) = x Mod(x, NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { c := math.Mod(7, 4) fmt.Printf("%.1f", c) }
Output: 3.0
func Modf ¶
Modfは整数部分と小数部分の浮動小数点数を返します。両方の値はfと同じ符号を持ちます。
特殊なケースは以下の通りです:
Modf(±Inf) = ±Inf, NaN Modf(NaN) = NaN, NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { int, frac := math.Modf(3.14) fmt.Printf("%.2f, %.2f\n", int, frac) int, frac = math.Modf(-2.71) fmt.Printf("%.2f, %.2f\n", int, frac) }
Output: 3.00, 0.14 -2.00, -0.71
func Nextafter ¶
Nextafterはxからyに向かって次の表現可能なfloat64値を返します。
特別な場合は以下の通りです:
Nextafter(x, x) = x Nextafter(NaN, y) = NaN Nextafter(x, NaN) = NaN
func Nextafter32 ¶ added in v1.4.0
Nextafter32はxからyの方向に次に表現可能なfloat32値を返します。
特殊なケースは以下の通りです:
Nextafter32(x, x) = x Nextafter32(NaN, y) = NaN Nextafter32(x, NaN) = NaN
func Pow ¶
Powはx**y、yのxを底とした指数を返します。
特殊な場合は以下の通りです:
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
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { c := math.Pow(2, 3) fmt.Printf("%.1f", c) }
Output: 8.0
func Pow10 ¶
Pow10はnの10のn乗、つまり10の指数nを返します。
特別な場合は以下の通りです:
Pow10(n) = 0 for n < -323 Pow10(n) = +Inf for n > 308
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { c := math.Pow10(2) fmt.Printf("%.1f", c) }
Output: 100.0
func Remainder ¶
Remainderはx/yのIEEE 754浮動小数点余りを返します。
特殊なケースは以下の通りです:
Remainder(±Inf, y) = NaN Remainder(NaN, y) = NaN Remainder(x, 0) = NaN Remainder(x, ±Inf) = x Remainder(x, NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.1f", math.Remainder(100, 30)) }
Output: 10.0
func Round ¶ added in v1.10.0
Roundは、最も近い整数を返します。半の場合はゼロから離れます。
特殊なケースは次の通りです:
Round(±0) = ±0 Round(±Inf) = ±Inf Round(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { p := math.Round(10.5) fmt.Printf("%.1f\n", p) n := math.Round(-10.5) fmt.Printf("%.1f\n", n) }
Output: 11.0 -11.0
func RoundToEven ¶ added in v1.10.0
RoundToEvenは、最も近い整数を返し、丸めの際に引き分けを偶数に丸めます。
特別なケースは以下の通りです:
RoundToEven(±0) = ±0 RoundToEven(±Inf) = ±Inf RoundToEven(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { u := math.RoundToEven(11.5) fmt.Printf("%.1f\n", u) d := math.RoundToEven(12.5) fmt.Printf("%.1f\n", d) }
Output: 12.0 12.0
func Sin ¶
Sinは、ラジアンの引数xの正弦を返します。
特殊なケースは次の通りです:
Sin(±0) = ±0 Sin(±Inf) = NaN Sin(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f", math.Sin(math.Pi)) }
Output: 0.00
func Sincos ¶
SincosはSin(x), Cos(x)を返します。
特殊なケースは以下の通りです:
Sincos(±0) = ±0, 1 Sincos(±Inf) = NaN, NaN Sincos(NaN) = NaN, NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { sin, cos := math.Sincos(0) fmt.Printf("%.2f, %.2f", sin, cos) }
Output: 0.00, 1.00
func Sinh ¶
Sinhはxの双曲線正弦を返します。
特殊なケースは以下の通りです:
Sinh(±0) = ±0 Sinh(±Inf) = ±Inf Sinh(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f", math.Sinh(0)) }
Output: 0.00
func Sqrt ¶
Sqrtはxの平方根を返します。
特殊な場合は次の通りです:
Sqrt(+Inf) = +Inf Sqrt(±0) = ±0 Sqrt(x < 0) = NaN Sqrt(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { const ( a = 3 b = 4 ) c := math.Sqrt(a*a + b*b) fmt.Printf("%.1f", c) }
Output: 5.0
func Tan ¶
Tanはラジアンの引数xの正接(タンジェント)を返します。
特殊なケースは以下の通りです:
Tan(±0) = ±0 Tan(±Inf) = NaN Tan(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f", math.Tan(0)) }
Output: 0.00
func Tanh ¶
Tanhはxの双曲線正接を返します。
特殊な場合は次のとおりです:
Tanh(±0) = ±0 Tanh(±Inf) = ±1 Tanh(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f", math.Tanh(0)) }
Output: 0.00
func Trunc ¶
Truncはxの整数値を返します。
特殊なケースは以下の通りです:
Trunc(±0) = ±0 Trunc(±Inf) = ±Inf Trunc(NaN) = NaN
Example ¶
package main import ( "github.com/shogo82148/std/fmt" "github.com/shogo82148/std/math" ) func main() { fmt.Printf("%.2f\n", math.Trunc(math.Pi)) fmt.Printf("%.2f\n", math.Trunc(-1.2345)) }
Output: 3.00 -1.00
func Y0 ¶
Y0は第二種ベッセル関数のゼロ次の値を返します。
特殊なケースは以下の通りです:
Y0(+Inf) = 0 Y0(0) = -Inf Y0(x < 0) = NaN Y0(NaN) = NaN
Types ¶
This section is empty.
Source Files
¶
- abs.go
- acosh.go
- asin.go
- asinh.go
- atan.go
- atan2.go
- atanh.go
- bits.go
- cbrt.go
- const.go
- copysign.go
- dim.go
- dim_asm.go
- erf.go
- erfinv.go
- exp.go
- exp2_noasm.go
- exp_amd64.go
- exp_asm.go
- expm1.go
- floor.go
- floor_asm.go
- fma.go
- frexp.go
- gamma.go
- hypot.go
- hypot_asm.go
- j0.go
- j1.go
- jn.go
- ldexp.go
- lgamma.go
- log.go
- log10.go
- log1p.go
- log_asm.go
- logb.go
- mod.go
- modf.go
- modf_noasm.go
- nextafter.go
- pow.go
- pow10.go
- remainder.go
- signbit.go
- sin.go
- sincos.go
- sinh.go
- sqrt.go
- stubs.go
- tan.go
- tanh.go
- trig_reduce.go
- unsafe.go
Directories
¶
Path | Synopsis |
---|---|
bigパッケージは任意精度算術(大きな数)を実装します。
|
bigパッケージは任意精度算術(大きな数)を実装します。 |
bitsパッケージは、事前に宣言された符号なし整数型のためのビットカウントと操作 関数を実装します。
|
bitsパッケージは、事前に宣言された符号なし整数型のためのビットカウントと操作 関数を実装します。 |
cmplxパッケージは、複素数の基本的な定数と数学関数を提供します。
|
cmplxパッケージは、複素数の基本的な定数と数学関数を提供します。 |
randパッケージは、シミュレーションなどのタスクに適した擬似乱数生成器を実装しますが、 セキュリティに敏感な作業には使用しないでください。
|
randパッケージは、シミュレーションなどのタスクに適した擬似乱数生成器を実装しますが、 セキュリティに敏感な作業には使用しないでください。 |
v2
randパッケージは、シミュレーションなどのタスクに適した擬似乱数生成器を実装しますが、セキュリティに敏感な作業には使用しないでください。
|
randパッケージは、シミュレーションなどのタスクに適した擬似乱数生成器を実装しますが、セキュリティに敏感な作業には使用しないでください。 |