Math
Constants
pi
The ratio of a circle's circumference to its diameter, approximately 3.14.
Can also be represented by the Unicode symbol π.
tau
Equal to 2π (approximately 6.28), representing the ratio of a circle's circumference to its radius.
Can also be represented by the Unicode symbol τ.
e
The base of natural logarithms, approximately 2.72.
Can also be represented by the Unicode symbol ℯ.
phi
The golden ratio, approximately 1.618.
Can also be represented by the Unicode symbol φ.
Arithmetic Operators
neg n
Changes the sign of n if possible. Accepts integer, float, and complex types.
Equivalent to the (-) unary operator.
Example:
three = neg -3
three = -(-3)add x y
Adds x and y together if possible. Accepts integer, float, and complex types.
Equivalent to the (+) binary operator.
Example:
three = add 1 2
three = (+) 1 2
three = 1 + 2sub x y
Subtracts x from y if possible. Accepts integer, float, and complex types.
Equivalent to the (-) binary operator.
Example:
three = sub 5 2
three = (-) 5 2
three = 5 - 2mul x y
Multiplies x and y if possible. Accepts integer, float, and complex types.
Equivalent to the (*) binary operator.
Example:
six = mul 2 3
six = (*) 2 3
six = 2 * 3div x y
Divides x by x if possible. Accepts integer, float, and complex types.
Equivalent to the (/) binary operator.
Example:
three = div 6 2
three = (/) 6 2
three = 6 / 2mod x y
Returns the remainder of x divided by y if possible. Accepts integer, float, and complex types.
Equivalent to the (%) binary operator.
Example:
one = mod 5 2
one = (%) 5 2
one = 5 % 2pow x y
Returns x to the power of y if possible. Accepts integer, float, and complex types.
Equivalent to the (**) binary operator.
Example:
nine = pow 3 2
nine = (**) 3 2
nine = 3 ** 2Bitwise Operators
bitnot n
Inverts the bits of n. Accepts only integers.
Equivalent to the (~) unary operator.
Example:
one = bitnot -2
one = (~) -2
one = ~-2bitand x y
Performs a bitwise AND operation on x and y. Accepts only integers.
Equivalent to the (&) binary operator.
Example:
one = bitand 5 3
one = (&) 5 3
one = 5 & 3bitor x y
Performs a bitwise OR operation on x and y. Accepts only integers.
Equivalent to the (|) binary operator.
Example:
seven = bitor 5 3
seven = (|) 5 3
seven = 5 | 3bitxor x y
Performs a bitwise XOR operation on x and y. Accepts only integers.
Equivalent to the (^) binary operator.
Example:
six = bitxor 5 3
six = (^) 5 3
six = 5 ^ 3bitleft x y
Shifts the bits of x to the left by y positions. Accepts only integers.
Equivalent to the (<<) binary operator.
Example:
ten = bitleft 5 1
ten = (<<) 5 1
ten = 5 << 1bitright x y
Shifts the bits of x to the right by y positions. Accepts only integers.
Equivalent to the (>>) binary operator.
Example:
two = bitright 5 1
two = (>>) 5 1
two = 5 >> 1Conversion Functions
int n
Converts a float n to an integer.
Example:
three = int 3.5float n
Converts an integer n to a float.
Example:
three_point_zero = float 3complex re im
Returns a complex number with a real part re and an imaginary part im.
Example:
three_plus_five_i = complex 3 5real n
Returns a float representing the real part of a complex number n.
Example:
three = real 3+5iimag n
Returns a float representing the imaginary part of a complex number n.
Example:
five = imag 3+5ideg_to_rad n
Converts n from degrees to radians. Accepts integer and float types.
Example:
half_of_pi = deg_to_rad 90rad_to_deg n
Converts n from radians to degrees. Accepts integer and float types.
Example:
ninety = rad_to_deg (pi / 2)Trigonometric Functions
sin n
Computes the sine of n radians. Accepts integer, float, and complex types.
Example:
zero = sin 0cos n
Computes the cosine of n radians. Accepts integer, float, and complex types.
Example:
one = cos 0tan n
Computes the tangent of n radians. Accepts integer, float, and complex types.
Example:
zero = tan 0asin n
Computes the inverse sine of n . Accepts integer, float, and complex types.
Example:
zero = asin 0acos n
Computes the inverse cosine of n. Accepts integer, float, and complex types.
Example:
zero = acos 1atan n
Computes the inverse tangent of n . Accepts integer, float, and complex types.
Example:
zero = atan 0atan2 y x
Computes the inverse tangent of y and x. Accepts integer and float types.
Example:
zero = atan2 0 1Hyperbolic Functions
sinh n
Computes the hyperbolic sine of n radians. Accepts integer, float, and complex types.
Example:
zero = sinh 0cosh n
Computes the hyperbolic cosine of n radians. Accepts integer, float, and complex types.
Example:
one = cosh 0tanh n
Computes the hyperbolic tangent of n radians. Accepts integer, float, and complex types.
Example:
zero = tanh 0asinh n
Computes the inverse hyperbolic sine of n radians. Accepts integer, float, and complex types.
Example:
zero = asinh 0acosh n
Computes the inverse hyperbolic cosine of n radians. Accepts integer, float, and complex types.
Example:
zero = acosh 1atanh n
Computes the inverse hyperbolic tangent of n radians. Accepts integer, float, and complex types.
Example:
zero = atanh 0Advanced Functions
ln n
Computes the natural logarithm of n . Accepts integer, float, and complex types.
Example:
one = ln elog10 n
Computes the logarithm base 10 of n . Accepts integer, float, and complex types.
Example:
two = log10 100log base n
Computes the logarithm with base base of n . Accepts integer, float, and complex types for n and integer or float types for base.
Example:
four = log 3 81abs n
Computes the absolute value of n . Accepts integer, float, and complex types.
Example:
one = abs -1floor n
Returns the largest integer less than or equal to n. Accepts integer and float types.
Example:
three = floor 3.7ceil n
Returns the smallest integer greater than or equal to n. Accepts integer and float types.
Example:
three = ceil 3.3sqrt n
Computes the square root of n . Accepts integer, float, and complex types.
Example:
two = sqrt 4cbrt n
Computes the cube root of n . Accepts integer, float, and complex types.
Example:
two = cbrt 8fact n
Computes the factorial of n. Accepts integer and float types.
Example:
twenty_four = fact 4fact2 n
Computes the double factorial of n. Accepts integer and float types.
Example:
eight = fact2 4min x y
Returns the minimum of x and y. Accepts integer and float types.
Example:
three = min 3 5max x y
Returns the maximum of x and y. Accepts integer and float types.
Example:
five = max 3 5Last updated