Functions
| Function | Description | Example | Result |
|---|---|---|---|
math.sqrt(x) | Square root | math.sqrt(144) | 12 |
math.abs(x) | Absolute value | math.abs(-5) | 5 |
math.ceil(x) | Round up | math.ceil(3.2) | 4 |
math.floor(x) | Round down | math.floor(3.8) | 3 |
math.round(x) | Round to nearest | math.round(3.5) | 4 |
math.pow(x, y) | Power | math.pow(2, 10) | 1024 |
math.min(a, b) | Minimum | math.min(3, 7) | 3 |
math.max(a, b) | Maximum | math.max(3, 7) | 7 |
math.random() | Random 0.0–1.0 | math.random() | 0.73... |
math.random_int(min, max) | Random integer | math.random_int(1, 10) | 7 |
math.pi() | Pi constant | math.pi() | 3.14159... |
math.sin(x) | Sine (radians) | math.sin(1.57) | ~1.0 |
math.cos(x) | Cosine (radians) | math.cos(0) | 1.0 |
math.tan(x) | Tangent (radians) | math.tan(0.785) | ~1.0 |
math.log(x) | Natural log | math.log(2.718) | ~1.0 |
math.log10(x) | Base-10 log | math.log10(100) | 2.0 |