Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------
- --MATH FUNCTIONS--
- ------------------
- function math.root(a,b)
- return math.pow(a,(1/b))
- end
- function math.logx(a,b)
- return math.log10(a)/math.log10(b)
- end
- function math.digits(a,b)
- b = b or 10
- return math.floor(math.logx(a,b))
- end
- function math.summation(a,b)
- if a == 1 then return b*(b+1)/2 end
- local r = 0
- for i = a, b do
- r = r+i
- end
- return r
- end
- function math.factorial(x)
- if x == 1 or x == 0 then return 1 end
- local r = 1
- for i=2, x do
- r = r * i
- end
- return r
- end
- function math.powerset(s,n)
- n = n or 1
- if n>#s then
- return {{}}
- end
- local r = math.powerset(s,n+1)
- for i=1,#r do
- r[#r+1] = {s[n], table.unpack(r[i])}
- end
- return r
- end
- function math.normalizerad(r)
- if r>math.pi then
- r = -math.pi+r%math.pi
- elseif r<-math.pi then
- r = math.pi-(math.pi-r%math.pi)
- end
- return r
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement