SoFunction
Updated on 2025-04-09

A list of all functions of Lua Mathematics Library

abs

Take the absolute value

(-15)

15

acos

Inverse cosine function

(0.5)

1.04719755

asin

Anormal sine function

(0.5)

0.52359877

atan2

The arctangent value of x / y

math.atan2(90.0, 45.0)

1.10714871

atan

Arctangent function

(0.5)

0.463647609

ceil

The maximum integer not less than x

(5.8)

6

cosh

Hyperbolic cosine function

(0.5)

1.276259652

cos

Cosine function

(0.5)

0.87758256

deg

Radius angle

()

180

exp

Calculate the value of x power base with e as the value

(2)

2.718281828

floor

The maximum integer not greater than x

(5.6)

5

fmod (mod)

Modal operation

(14, 5)

4

frexp

Decompose the double precision number val into the numeric part (manscrew) and the exponent n with base 2, that is, val=x*2n

(10.0)

0.625    4

ldexp

Calculate value * 2 to the n-power

(10.0, 3)

80 = 10 * (2 ^3)

log10

Calculate logarithm with 10 as the base

math.log10(100)

2

log

Calculate the natural logarithm of a number

(2.71)

0.9969

max

Get the maximum value in the parameters

(2.71, 100, -98, 23)

100

min

Get the minimum value in the parameter

(2.71, 100, -98, 23)

-98

modf

Divide numbers into integers and decimals

(15.98)

15    98

pow

Get the y power of x

(2, 5)

32

rad

Angle radian

(180)

3.14159265358

random

Get random numbers

(1, 100)
(100)

Get random numbers from 1-100

randomseed

Set random number seeds

(())

You must use this function to set random number seeds before using a function

sinh

Hyperbolic sinusoidal function

(0.5)

0.5210953

sin

Sine function

((30))

0.5

sqrt

Open square function

(16)

4

tanh

Hyperbolic tangent function

(0.5)

0.46211715

tan

Tangent function

(0.5)

0.5463024