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:
add x y
Adds x
and y
together if possible. Accepts integer, float, and complex types.
Equivalent to the (+)
binary operator.
Example:
sub x y
Subtracts x
from y
if possible. Accepts integer, float, and complex types.
Equivalent to the (-)
binary operator.
Example:
mul x y
Multiplies x
and y
if possible. Accepts integer, float, and complex types.
Equivalent to the (*)
binary operator.
Example:
div x y
Divides x
by x
if possible. Accepts integer, float, and complex types.
Equivalent to the (/)
binary operator.
Example:
mod x y
Returns the remainder of x
divided by y
if possible. Accepts integer, float, and complex types.
Equivalent to the (%)
binary operator.
Example:
pow x y
Returns x
to the power of y
if possible. Accepts integer, float, and complex types.
Equivalent to the (**)
binary operator.
Example:
Bitwise Operators
bitnot n
Inverts the bits of n
. Accepts only integers.
Equivalent to the (~)
unary operator.
Example:
bitand x y
Performs a bitwise AND operation on x
and y
. Accepts only integers.
Equivalent to the (&)
binary operator.
Example:
bitor x y
Performs a bitwise OR operation on x
and y
. Accepts only integers.
Equivalent to the (|)
binary operator.
Example:
bitxor x y
Performs a bitwise XOR operation on x
and y
. Accepts only integers.
Equivalent to the (^)
binary operator.
Example:
bitleft x y
Shifts the bits of x
to the left by y
positions. Accepts only integers.
Equivalent to the (<<)
binary operator.
Example:
bitright x y
Shifts the bits of x
to the right by y
positions. Accepts only integers.
Equivalent to the (>>)
binary operator.
Example:
Conversion Functions
int n
Converts a float n
to an integer.
Example:
float n
Converts an integer n
to a float.
Example:
complex re im
Returns a complex number with a real part re
and an imaginary part im
.
Example:
real n
Returns a float representing the real part of a complex number n
.
Example:
imag n
Returns a float representing the imaginary part of a complex number n
.
Example:
deg_to_rad n
Converts n
from degrees to radians. Accepts integer and float types.
Example:
rad_to_deg n
Converts n
from radians to degrees. Accepts integer and float types.
Example:
Trigonometric Functions
sin n
Computes the sine of n
radians. Accepts integer, float, and complex types.
Example:
cos n
Computes the cosine of n
radians. Accepts integer, float, and complex types.
Example:
tan n
Computes the tangent of n
radians. Accepts integer, float, and complex types.
Example:
asin n
Computes the inverse sine of n
. Accepts integer, float, and complex types.
Example:
acos n
Computes the inverse cosine of n
. Accepts integer, float, and complex types.
Example:
atan n
Computes the inverse tangent of n
. Accepts integer, float, and complex types.
Example:
atan2 y x
Computes the inverse tangent of y
and x
. Accepts integer and float types.
Example:
Hyperbolic Functions
sinh n
Computes the hyperbolic sine of n
radians. Accepts integer, float, and complex types.
Example:
cosh n
Computes the hyperbolic cosine of n
radians. Accepts integer, float, and complex types.
Example:
tanh n
Computes the hyperbolic tangent of n
radians. Accepts integer, float, and complex types.
Example:
asinh n
Computes the inverse hyperbolic sine of n
radians. Accepts integer, float, and complex types.
Example:
acosh n
Computes the inverse hyperbolic cosine of n
radians. Accepts integer, float, and complex types.
Example:
atanh n
Computes the inverse hyperbolic tangent of n
radians. Accepts integer, float, and complex types.
Example:
Advanced Functions
ln n
Computes the natural logarithm of n
. Accepts integer, float, and complex types.
Example:
log10 n
Computes the logarithm base 10 of n
. Accepts integer, float, and complex types.
Example:
log 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:
abs n
Computes the absolute value of n
. Accepts integer, float, and complex types.
Example:
floor n
Returns the largest integer less than or equal to n
. Accepts integer and float types.
Example:
ceil n
Returns the smallest integer greater than or equal to n
. Accepts integer and float types.
Example:
sqrt n
Computes the square root of n
. Accepts integer, float, and complex types.
Example:
cbrt n
Computes the cube root of n
. Accepts integer, float, and complex types.
Example:
fact n
Computes the factorial of n
. Accepts integer and float types.
Example:
fact2 n
Computes the double factorial of n
. Accepts integer and float types.
Example:
min x y
Returns the minimum of x
and y
. Accepts integer and float types.
Example:
max x y
Returns the maximum of x
and y
. Accepts integer and float types.
Example:
Last updated