The Kontrast math syntax
Examples
Supported operators and constants
All functions listed below work for real and complex numbers.
Binary operations
-
Addition (
A + B
) -
Subtraction (
A - B
) -
Multiplication (
A * B
) -
Division (
A / B
) -
Exponentiation (
A ^ B
, A to the power of B)
Unary operations
- Square root (
sqrt
) - Exponential function (
exp
) - Natural logarithm (base e) (
log
) - Decadic logarithm (base 10) (
log10
) - Binary logarithm (base 2) (
log2
)
Trigonometric functions
- Sine (
sin
) - Cosine (
cos
) - Tangent (
tan
) - Inverse sine (
arcsin
) - Inverse cosine (
arccos
) - Inverse tangent (
arctan
) - Hyperbolic sine (
sinh
) - Hyperbolic cosine (
cosh
) - Hyperbolic tangent (
tanh
) - Inverse hyperbolic sine (
arsinh
) - Inverse hyperbolic cosine (
arcosh
) - Inverse hyperbolic tangent (
artanh
)
Decomposition
- Absolute value (
abs
) - Argument (
arg
) - Two-valued argument function (
atan2(y, x)
) - Real part (
real
) - Imaginary part (
imag
) - Sign of real number (
sign
) - Complex conjugate (
conj
)
Rounding
- Round to next nearest integer (
round
) - Round to smaller integer (
floor
) - Round to larger integer (
ceil
)
Boolean logic and branching
-
Conditional branch (
condition(boolean expression, true branch, false branch)
) -
Logical and (
A and B
) -
Logical or (
A or B
) -
Logical not (
not A
) -
Equality (
A = B
) -
Smaller than (
A < B
) -
Smaller than or equal (
A <= B
) -
Greater than (
A > B
) -
Greater than or equal (
A >= B
)
Constants
- Pi 3.14159... (
pi
) - Euler's number 2.71828... (
e
) - Imaginary unit (
i
)