/calc
The /calc command allows you to make calculations with units and functions.
The supported units and constants are provided by the dimAns Python library.
Parameters
- t
the expression to calculate
Supports Units, Constants and Functions.
You can provide
?to view general calculator usage and expression syntax,?unitsto get a list of all registered units,?constantsto get a list of all registered constants, and?functionsto get a list of all registered functions.
Language
The command has its own simple mini-language. In the definitions given below,
Expris any expression,Dimensionalis a Quantity or Unit,Identis a Unit or Constant,Numberis a number,Funcis a function.
Expressions
IdentIdentifier (Unit or Constant usage)
NumberInteger or floating point number in decimal format, e.g.
-1,3.14Func(Expr, ...)Function call
(Expr)Grouping
-ExprNegation
+ExprNo operation
Expr ^ ExprExponentiation
Expr * ExprMultiplication
Expr IdentIdentifier multiplication
Expr / ExprDivision
Expr mod ExprModulo
Expr + ExprAddition
Expr - ExprSubtraction
Expr -> DimensionalUnit conversion
Expr -> (Dimensional, ...)Sum unit conversion
Operation precedence
Order | Operations |
|---|---|
1 | Identifier usage, Number specification, Function usage, grouping. |
2 | Negation, no operation, exponentiation. |
3 | Multiplication, identifier multiplication, division, modulo. |
4 | Addition, subtraction. |
5 | Unit conversion, sum unit conversion. |
Functions
Number-theoretic and representation functions
ceil(x)Returns the smallest integer greater than or equal to
x.comb(n, k)Returns the number of ways to choose
kitems fromnitems without repetition and without order.copysign(x, y)Returns
xwith the sign ofy.abs(x)Returns the absolute value of
x.factorial(x)Returns the factorial of
x.floor(x)Returns the largest integer less than or equal to
x.mod(x, y)Returns the remainder from the division of
xbyy,x mod y.isfinite(x)Returns
Trueifxis a finite number,Falseotherwise.isinf(x)Returns
Trueifxis positive or negative infinity,Falseotherwise.isnan(x)Returns
TrueifxisNaN,Falseotherwise.isqrt(x)Returns the integer square root of
x.perm(n, k)Returns the number of ways to choose
kitems fromnitems without repetition and with order.trunc(x)Returns the nearest integer to
xtowards0.
Power and logarithmic functions
cbrt(x)Returns the cube root of
x.exp(x)Returns
eraised to the power ofx.exp2(x)Returns
2raised to the power ofx.expm1(x)Returns
eraised to the power ofx, minus1.log(x)Returns the natural logarithm of
x.log(x, base)Returns the logarithm of
xwith basebase.log1p(x)Returns the natural logarithm of
1plusx.log2(x)Returns the base 2 logarithm of
x.log10(x)Returns the base 10 logarithm of
x.pow(x, y)Returns
xraised to the power ofy,x ^ y.sqrt(x)Returns the square root of
x.
Trigonometric functions
acos(x)Returns the arc cosine (measured in radians) of
x.asin(x)Returns the arc sine (measured in radians) of
x.atan(x)Returns the arc tangent (measured in radians) of
x.atan2(y, x)Returns the arc tangent of
y / x(measured in radians) in the correct quadrant.cos(x)Returns the cosine of
x(measured in radians).dist(x, y)Returns the Euclidean distance between
xandy.sin(x)Returns the sine of
x(measured in radians).tan(x)Returns the tangent of
x(measured in radians).
Angular conversions
degrees(x)Returns
xradians expressed in degrees.radians(x)Returns
xdegrees expressed in radians.
Hyperbolic functions
acosh(x)Returns the inverse hyperbolic cosine of
x.asinh(x)Returns the inverse hyperbolic sine of
x.atanh(x)Returns the inverse hyperbolic tangent of
x.cosh(x)Returns the hyperbolic cosine of
x.sinh(x)Returns the hyperbolic sine of
x.tanh(x)Returns the hyperbolic tangent of
x.
Special functions
erf(x)Returns the error function at
x.erfc(x)Returns the complementary error function at
x.gamma(x)Returns the Gamma function at
x.lgamma(x)Returns the natural logarithm of the absolute value of the Gamma function at
x.
lutfen Calculator functions
dim(x)Returns the dimensions of
x.unit(x)Returns the unit of
x.val(x)Returns the value of
x.uval(x)Returns the underlying value of
x.
Operator functions
add(x, y)Returns
x + y.sub(x, y)Returns
x - y.mul(x, y)Returns
x * y.div(x, y)Returns
x / y.neg(x)Returns
-x.