12. Built-in functions and constants

The following general built-in functions are available:

Function name Description
abs(x) Returns the absolute value of x. The type of x (integer or floating-point number) is preserved.
isdefined(x) Returns true if the variable has been set.
max(x, y, ...) Returns the argument with the maximum value. The arguments may have different types. A string is always "greater" than a number.
min(x, y, ...) Returns the argument with the minimum value. The arguments may have different types. A string is always "greater" than a number.

Several built-in mathematical functions are available:

Function name Description
math.acos(x) Returns the arc cosine (measured in radians) of x.
math.asin(x) Returns the arc sine (measured in radians) of x.
math.asin(x) Returns the arc tangent (measured in radians) of x.
math.cos(x) Returns the cosine of x (measured in radians).
math.degrees(x) Converts angle x from radians to degrees.
math.exp(x) Returns math.e**x
math.log(x) Returns the natural logarithm of x.
math.log10(x) Returns the base 10 logarithm of x.
math.radians(x) Converts angle x from degrees to radians.
math.sin(x) Returns the sine of x (measured in radians).
math.sqrt(x) Returns the square root of x.
math.tan(x) Returns the tangent of x (measured in radians).

A number of predefined constants is also available:

Constant name Description
math.e The Euler number (2.718281828459045)
math.pi The number Pi (3.141592653589793)