Warning! This page documents an earlier version of Flux, which is no longer actively developed. Flux v0.50 is the most recent stable version of Flux.
The Flux math package provides basic constants and mathematical functions.
Import the math
package.
import "math"
Mathematical constants
That math
package includes the following mathematical constants.
math.e = 2.71828182845904523536028747135266249775724709369995957496696763 // https ://oeis.org/A001113
math.pi = 3.14159265358979323846264368327950288419716939937510582097494459 // https ://oeis.org/A000796
math.phi = 1.61803698874989484820458683436563811772030917980576286213544862 // https ://oeis.org/A001622
math.sqrt2 = 1.41421356237309504880168872420969807856967187537694807317667974 // https ://oeis.org/A002193
math.sqrte = 1.64872127070012814684865078781416357165377610071014801157507931 // https ://oeis.org/A019774
math.sqrtpi = 1.77245385090551602729816748364114518279754945612238712821380779 // https ://oeis.org/A002161
math.sqrtphi = 1.27201964951406896425242246173749149171560804184009624861664038 // https ://oeis.org/A139369
math.ln2 = 0.693147180559945309417232121458176568075500134360255254120680009 // https://oeis.org/A002162
math.log2e = 1 ÷ math.ln2
math.ln10 = 2.30258509299404568401799145468436420760110148862877297603632790 // https ://oeis.org/A002392
math.log10e = 1 ÷ math.ln10
math.maxfloat = 1.797693134862315708145274237317043567981e+308 // 2**1023 * (2**53 - 1) / 2**52
math.maxint = 1<<63 - 1
math.minint = -1 << 63
math.maxuint = 1<<64 - 1
Mathematical functions
- math.NaN()
- math.abs()
- math.acos()
- math.acosh()
- math.asin()
- math.asinh()
- math.atan()
- math.atan2()
- math.atanh()
- math.cbrt()
- math.ceil()
- math.copysign()
- math.cos()
- math.cosh()
- math.dim()
- math.erf()
- math.erfc()
- math.erfcinv()
- math.erfinv()
- math.exp()
- math.exp2()
- math.expm1()
- math.float64bits()
- math.floor()
- math.frexp()
- math.gamma()
- math.hypot()
- math.ilogb()
- math.isInf()
- math.isNaN()
- math.j0()
- math.j1()
- math.jn()
- math.ldexp()
- math.lgamma()
- math.log()
- math.log10()
- math.log1p()
- math.log2()
- math.logb()
- math.mInf()
- math.mMax()
- math.mMin()
- math.mod()
- math.modf()
- math.nextafter()
- math.pow()
- math.pow10()
- math.remainder()
- math.round()
- math.roundtoeven()
- math.signbit()
- math.sin()
- math.sincos()
- math.sinh()
- math.sqrt()
- math.tan()
- math.tanh()
- math.trunc()
- math.y0()
- math.y1()
- math.yn()