Useful MathModule [v3!]
~ How to set up
- Download the module
- Put it anywhere (I recommend putting it in ReplicatedStorage)
- Require it in a script (name it ‘math’)
local math = require(game.ReplicatedStorage.MathModule)
- your done!
~ Values
Tau
-
name:
tau
-
functionality: returns pi * 2
-
output:
Math.tau --> 6.283185307179586
Null
-
name:
null
-
functionality: returns -math.huge
-
output:
Math.null --> -inf
Eulers number
-
name:
e
-
functionality: returns e (Eulers number)
-
output:
Math.euler --> 2.718281828459045
Golden Ratio
-
name:
phi
-
functionality: returns φ
-
output:
Math.phi --> 1.618033988749895
Nan
-
name:
nan
-
functionality: returns 0/0 (Not A Number)
-
output:
Math.nan --> nan
Limit
-
name:
limit
-
functionality: returns the biggest number that is not = inf
-
output:
Math.limit --> 1.7976931348621742e+308
Pixel Ratio
-
name:
px
-
functionality: returns X where 1 pixel = X mm
-
output:
Math.px --> 0.264583333333333
Small g
-
name:
g
-
functionality: returns the Earth’s Gravitational Acceleration
-
output:
Math.g --> 9.807
Pythagoras Constant
-
name:
sqrt2
-
functionality: returns 2^.5
-
output:
Math.sqrt2 --> 1.4142135623730951
Supergolden ratio
-
name:
psi
-
functionality: returns 𝜓
-
output:
Math.psi --> 1.4655712318767682
Plastic Number
-
name:
p
-
functionality: returns the only solution to x^3 = x+1
-
output:
Math.p --> 1.324717957244746
Epsilon
-
name:
eps
-
functionality: returns a really small number
-
output:
Math.eps --> 8.854187817e-12
~ Functions
Circumference
-
name:
circum
-
Arguments:
r (number)
~ r → Radius used to calculate the Circumference -
functionality: returns r * tau
-
Example:
Math.circum(3) --> 18.84955592153876
Cube root
-
name:
cbrt
-
Arguments:
x (number)
~ x → Number that’s cube root will be calculated -
functionality: returns ∛ x
-
Example:
Math.cbrt(64) --> 4
Any Root
-
name:
root
-
Arguments:
x (number), root (number)
~ x → Number that’s root will be calculated
~ root → The Root Number -
functionality: returns ʳᵒᵒᵗ√x
-
Example:
Math.root(16,4) --> 2
Factorial
-
name:
fac
-
Arguments:
x (number)
~ x → Number thats factorial is gonna be calculated -
functionality: returns x!
-
Example:
Math.fac(5) --> 120
Average
-
name:
avg
-
Arguments:
... (numbers)
~ … → Numbers that are gonna be used to calculate the average -
functionality: returns the average of …
-
Example:
Math.avg(1,2,3,4,5) --> 3
Summation
-
name:
sum
-
Arguments:
min (number), max (number), formula (function)
~ min → Starting number of a line of numbers
~ max → Ending number of a line of numbers
~ formula → Formula used on every number (optional) -
functionality: returns numbers from
min
tomax
added to eachother with the use offormula
-
Example:
Math.sum(1,5,function(x: number) return x^2 end) --> 55
Production
-
name:
product
-
Arguments:
min (number), max (number), formula (function)
~ min → Starting number of a line of numbers
~ max → Ending number of a line of numbers
~ formula → Formula used on every number (optional) -
functionality: returns numbers from
min
tomax
multiplied with eachother with the use offormula
-
Example:
Math.product(1,4,function(x: number) return x+1 end) --> 120
Reciprocal
-
name:
rec
-
Arguments:
x (number)
~ x → Number used for the function -
functionality: returns 1/x)
-
Example:
Math.rec(5) --> 0.2
Zero function
-
name:
zer
-
Arguments:
x (number)
~ x → Number to be used for the function -
functionality: returns 10^x
-
Example:
Math.zer(5) --> 100000
Gamma function
-
name:
gamma
-
Arguments:
x (number)
~ x → Number used in the function -
functionality: returns (x-1)!
-
Example:
Math.gamma(5) --> 24
Digits
-
name:
dgt
-
Arguments:
x (number)
~ x → Number to get the digits from -
functionality: returns the digits of X
-
Example:
Math.dgt(12345) --> {1,2,3,4,5}
Chance
-
name:
chance
-
Arguments:
x (number)
~ x → Number to calculate the chance with -
functionality: returns 1 if random(1,x) equal 1, if not then returns 0
-
Example:
Math.chance(100) --> assumed 0
Range
-
name:
range
-
Arguments:
... (numbers)
~ … → Numbers used to get the range -
functionality: returns max(…)-min(…)
-
Example:
Math.range(1,3,5,10) --> 9
Abbreviate
-
name:
note
-
Arguments:
x (number)
~ x → Number thats gonna be abbreviated -
functionality: returns abbreviation of x
-
Example:
Math.note(25069) --> 25k
NOTE: this function has NO LIMITS, and can go up until inf.
Check Prime
-
name:
isprime
-
Arguments:
x (number)
~ x → Number to be checked -
functionality: returns 0 if x isnt prime, else: returns 1
-
Example:
Math.prime(11) --> 1
~ Complex
Tetration
-
name:
tetr
-
Arguments:
x (number), y (number)
~ x → Number to be tetrated
~ y -->The number thatx
is gonna be tetrated to -
functionality: returns x↑↑y (ʸx)
-
Example:
Math.tetr(2,3) --> 16
Pentation
-
name:
pent
-
Arguments:
x (number), y (number)
~ x → Number to be pentated
~ y -->The number thatx
is gonna be pentated to -
functionality: returns x↑↑↑y
-
Example:
Math.pent(2,3) --> 65536
Double Factorial
-
name:
dblfac
-
Arguments:
x (number)
~ x → Number thats double factorial is gonna be calculated -
functionality: returns x!!
-
Example:
Math.dblfac(3) --> 720
Triple Factorial
-
name:
trifac
-
Arguments:
x (number)
~ x → Number thats triple factorial is gonna be calculated -
functionality: returns x!!!
-
Example:
Math.trifac(3) --> inf
NOTE: this function is absolutely useless, but i was happy while i made it so it stays in the module ^^
Lower Chance Random
-
name:
xrandom
-
Arguments:
x (number)
~ x → Number thats Lower random is gonna be calculated -
functionality: returns a number between 1 and x That averages out to 25%
-
Example:
Math.xrandom(100) --> ~25
Upper Chance Random
-
name:
yrandom
-
Arguments:
x (number)
~ x → Number thats Upper random is gonna be calculated -
functionality: returns a number between 1 and x That averages out to 75%
-
Example:
Math.yrandom(100) --> ~75
Zeta function ( ζ )
-
name:
zeta
-
Arguments:
x (number)
~ x → Number thats gonna be used in the function -
functionality: returns ζ(x)
-
Example:
Math.zeta(5) --> 1.036927755143338
~ Download
As File
Download here: MathModuleV3
With Copy and Paste
Copy from here: …
local NewMath = {}
----> built-in
NewMath["random"]=math["random"]
NewMath["huge"]=math["huge"]
NewMath["abs"]=math["abs"]
NewMath["sqrt"]=math["sqrt"]
NewMath["min"]=math["min"]
NewMath["rad"]=math["rad"]
NewMath["sign"]=math["sign"]
NewMath["max"]=math["max"]
NewMath["sin"]=math["sin"]
NewMath["fmod"]=math["fmod"]
NewMath["round"]=math["round"]
NewMath["pi"]=math["pi"]
NewMath["cos"]=math["cos"]
NewMath["deg"]=math["deg"]
NewMath["exp"]=math["exp"]
NewMath["log"]=math["log"]
NewMath["pow"]=math["pow"]
NewMath["tan"]=math["tan"]
NewMath["acos"]=math["acos"]
NewMath["asin"]=math["asin"]
NewMath["atan"]=math["atan"]
NewMath["ceil"]=math["ceil"]
NewMath["cosh"]=math["cosh"]
NewMath["modf"]=math["modf"]
NewMath["sinh"]=math["sinh"]
NewMath["tanh"]=math["tanh"]
NewMath["atan2"]=math["atan2"]
NewMath["clamp"]=math["clamp"]
NewMath["floor"]=math["floor"]
NewMath["frexp"]=math["frexp"]
NewMath["ldexp"]=math["ldexp"]
NewMath["log10"]=math["log10"]
NewMath["noise"]=math["noise"]
NewMath["randomseed"]=math["randomseed"]
----> constants
NewMath["tau"]=NewMath.pi*2
NewMath["null"]=-NewMath.huge
NewMath["e"]=NewMath.exp(1)
NewMath["phi"]=((1+(5^0.5))/2)
NewMath["nan"]=0/0
--> V2 constants
NewMath["limit"]=2^1023.9999999999999
--> V3 constants
NewMath["px"]=0.264583333333333
NewMath["sqrt2"]=2^0.5
NewMath["g"]=9.807
NewMath["psi"]=(1/3*(1+(((29+3*((93)^0.5))/2)^(1/3))+(((29-3*((93)^0.5))/2)^(1/3))))
NewMath["p"]=(((9+(69^0.5))/18)^(1/3)+((9-(69^0.5))/18)^(1/3))
NewMath["eps"]=((8.854187817)*(10^-12))
----> functions
NewMath["circum"]=function(r: number)
return NewMath.tau*r
end
NewMath["cbrt"]=function(x: number)
return x^(1/3)
end
NewMath["root"]=function(x: number,root: number)
return x^(1/root)
end
NewMath["fac"]=function(x: number)
if x == 0 then
return 1
end
local y = x
for i = 1,x-1 do
y=y*i
end
return y
end
NewMath["avg"]=function(...: number)
local n = 0
for _,i in pairs({...}) do
n += i
end
n /= #{...}
return n
end
NewMath["sum"]=function(min: number,max: number,formula: (number)-> number?)
local n = 0
for i = min,max do
if formula then
n += formula(i)
else
n += i
end
end
return n
end
--> V3 functions
NewMath["product"]=function(min: number,max: number,formula: (number)-> number?)
local n = 0
for i = min,max do
if formula then
n *= formula(i)
else
n *= i
end
end
return n
end
NewMath["rec"]=function(x: number)
return 1/x
end
NewMath["zer"]=function(z: number)
return 10^z
end
NewMath["gamma"]=function(x: number)
return NewMath.fac(x-1)
end
NewMath["dgt"]=function(x: number)
local nums = {0,1,2,3,4,5,6,7,8,9}
local digits = {}
for i,v in tostring(x):split("") do
if table.find(nums,tonumber(v)) then
table.insert(digits,tonumber(v))
end
end
return digits
end
NewMath["chance"]=function(x: number)
local rnd = math.random(1,math.clamp(x,1,10^32))
if rnd == 1 then
return rnd
else
return rnd*0
end
end
NewMath["range"]=function(...: number)
return NewMath.max(...)-NewMath.min(...)
end
NewMath["note"]=function(x: number)
local rlen = math.floor(math.log10(math.floor(x)))
local rlen2 = rlen
rlen2 -= rlen2%3
return ("%.f"):format(tostring(math.floor(x))):sub(1,(rlen%3)+1)..require(14327149989)[rlen2]
end
NewMath["isprime"]=function(x: number)
for i = 1,x do
if i ~= 1 and i ~= x then
if x%i==0 then
return 0
end
end
end
return 1
end
----> COMPLEX
NewMath["tetr"]=function(x: number,y: number)
local n = x
for i = 1,y-1 do
n = x^n
end
return n
end
NewMath["pent"]=function(x: number,y: number)
local n = x
for i = 1,y-2 do
n = NewMath.tetr(n,x^n)
end
return n
end
NewMath["dblfac"]=function(x: number)
return NewMath.fac(NewMath.fac(x))
end
--> V2 COMPLEX
NewMath["trifac"]=function(x: number)
return NewMath.fac(NewMath.fac(NewMath.fac(x)))
end
--> V3 COMPLEX
NewMath["yrandom"]=function(x: number)
return NewMath.random(NewMath.random(0,x),x)
end
NewMath["xrandom"]=function(x: number)
return NewMath.random(0,NewMath.random(0,x))
end
NewMath["zeta"]=function(x: number)
local y = 0
for i = 1,math.clamp(x*1000,1,10^10) do
y += (NewMath.rec(i^x))
end
return y
end
return NewMath
As a model
Download here: MathModuleV3
~ Note
I made this Post because I AM NOT updating the old post, the module was Almost fully remade and fixed. Oh and also This module took me SO MUCH time cuz i had to actually understand all of these things. () If you dont like it, tell me BUT dont spam hate. If you have any ideas i could add something etc. just post it here ^^
sorry; poor english ><