Skip to content
Turtle Kitty edited this page Aug 9, 2015 · 1 revision

math

This object contains several useful mathematical constants and functions.

math.pi
    -> 3.14159265358979

math.tau
    -> 6.28318530717959

math.e
    -> 2.71828182845905

math.phi
    -> 1.61803398874989

math.root-2
    -> 1.41421356237309

(math.max 8 6 7 5 3 0 9)
    -> 9

(math.min 8 6 7 5 3 0 9)
    -> 0

(math.sum '(1 2 3 4 5)) 
    -> 15

(math.product '(1 2 3 4 5)) 
    -> 120 

(math.pow 2 3)
    -> 8

(math.sqrt 64) 
    -> 8

(math.log math.e)
    -> 1.0 

(math.sin math.tau)
    -> 6.43249059870655e-16  ; stupid floating point numbers...

(math.cos math.tau)
    -> 1.0
    
(math.tan math.tau)
    -> 6.43249059870655e-16  ; again...
Clone this wiki locally