math#
relationalai.std
RAI number values are represented by Expression
objects. The relationalai.std.math
module is an analog of the Python math
module for working with RAI numbers.
NOTE
The actual values of properties and other data in a RAI Model are only determined during query evaluation in the RAI Native App.
As a result, the Python interpreter can’t access the types or values of data in the model, which means numeric values can’t be represented as Python number objects.
To import the math
module, add the following to the top of your Python file or notebook:
Table Of Contents#
Basic Operations#
Function | Description |
---|
abs() | Calculates the absolute value of a number. |
sign() | Returns the sign of a number. |
trunc_divide() | Divides two numbers and returns the integer part of the result. |
ceil() | Rounds a number up to the nearest whole number. |
floor() | Rounds a number down to the nearest whole number. |
clip() | Clips a number to a specified range. Sometimes referred to as clamp. |
factorial() | Calculates the factorial of a number. |
isclose() | Determines if two numbers are close to each other. |
Power and Logarithmic Functions#
Function | Description |
---|
pow() | Raises a number to a power. |
sqrt() | Calculates the square root of a number. |
cbrt() | Calculates the cube root of a number. |
exp() | Calculates the exponential of a number. |
log() | Calculates the logarithm of a number to a specified base. (Default: natural log) |
log2() | Calculates the base-2 logarithm of a number. |
log10() | Calculates the base-10 logarithm of a number. |
Trigonometric Functions#
Function | Description |
---|
sin() | Calculates the sine of an angle. |
cos() | Calculates the cosine of an angle. |
tan() | Calculates the tangent of an angle. |
cot() | Calculates the cotangent of an angle. |
asin() | Calculates the inverse sine of a number. |
acos() | Calculates the inverse cosine of a number. |
atan() | Calculates the inverse tangent of a number. |
acot() | Calculates the inverse cotangent of a number. |
Hyperbolic Functions#
Function | Description |
---|
sinh() | Calculates the hyperbolic sine of a number. |
cosh() | Calculates the hyperbolic cosine of a number. |
tanh() | Calculates the hyperbolic tangent of a number. |
acosh() | Calculates the inverse hyperbolic cosine of a number. |
asinh() | Calculates the inverse hyperbolic sine of a number. |
atanh() | Calculates the inverse hyperbolic tangent of a number. |
Spherical Trigonometry#
Function | Description |
---|
haversine() | Calculates the haversine of an angle. |
Angular Conversion#
Function | Description |
---|
degrees() | Converts an angle from radians to degrees. |
radians() | Converts an angle from degrees to radians. |
Special Functions#
Function | Description |
---|
erf() | Calculates the error function of a number. |
erfinv() | Calculates the inverse error function of a number. |