Skip to main content

Arithmetic

Constants

SymbolValue
ExponentialE2.7182818284\ldotsEuler's number
MachineEpsilon 2^{−52}The difference between 1 and the next larger floating point number.
See Machine Epsilon on Wikipedia
CatalanConstant= 0.9159655941\ldots\sum_{n=0}^{\infty} \frac{(-1)^{n}}{(2n+1)^2}
See Catalan's Constant on Wikipedia
GoldenRatio = 1.6180339887\ldots\frac{1+\sqrt{5}}{2} See Golden Ratio on Wikipedia
EulerGamma= 0.5772156649\ldotsSee Euler-Mascheroni Constant on Wikipedia

Relational Operators

FunctionNotation
Equalx = y
Mathematical relationship asserting that two quantities have the same value
Greaterx \gt y
GreaterEqualx \geq y
Lessx \lt y
LessEqualx \leq y
NotEqualx \ne y

See below for additonal relational operators: Congruent, etc...

Functions

FunctionNotation
Add a + bAddition
Subtract a - bSubtraction
Negate-aAdditive inverse
Multiplya\times bMultiplication
Divide\frac{a}{b}Divide
Powera^bExponentiation
Root\sqrt[n]{x}=x^{\frac1n}nth root
Sqrt\sqrt{x}=x^{\frac12}Square root
Squarex^2

Transcendental Functions

FunctionNotation
Exp\exponentialE^{x}Exponential function
Ln\ln(x)Logarithm function, the inverse of Exp
Log\log_b(x)["Log", _v_, _b_] logarithm of base b, default 10
Lb\log_2(x)Binary logarithm function, the base-2 logarithm
Lg\log\_{10}(x)Common logarithm, the base-10 logarithm
LogOnePlus\ln(x+1)

Rounding

FunctionNotation
Abs\|x\| Absolute value, magnitude
CeilRounds a number up to the next largest integer
ChopReplace real numbers that are very close to 0 (less than 10^{-10}) with 0
FloorRound a number to the greatest integer less than the input value
Round

Other Relational Operators

["Congruent", a, b, modulus]

Evaluate to True if a is congruent to b modulo modulus.

26 \equiv 11 \pmod{5}
$$26 \equiv 11 \pmod{5}$$
["Congruent", 26, 11, 5]
// ➔ True

Other Functions

["BaseForm", value:integer]

["BaseForm", value:integer, base]

Format an integer in a specific base, such as hexadecimal or binary.

If no base is specified, use base-10.

The sign of integer is ignored.

  • value should be an integer.
  • base should be an integer from 2 to 36.
["Latex", ["BaseForm", 42, 16]]

// ➔ (\text(2a))_{16}
Latex(BaseForm(42, 16))
// ➔ (\text(2a))_{16}
String(BaseForm(42, 16))
// ➔ "'0x2a'"

["Clamp", value]

["Clamp", value, lower, upper]

  • If value is less than lower, evaluate to lower
  • If value is greater than upper, evaluate to upper
  • Otherwise, evaluate to value

If lowerand upperare not provided, they take the default values of -1 and +1.

["Clamp", 0.42]
// ➔ 1
["Clamp", 4.2]
// ➔ 1
["Clamp", -5, 0, "+Infinity"]
// ➔ 0
["Clamp", 100, 0, 11]
// ➔ 11

["Max", x1, x2, ...]

["Max", list]

If all the arguments are real numbers, excluding NaN, evaluate to the largest of the arguments.

Otherwise, simplify the expression by removing values that are smaller than or equal to the largest real number.

["Max", 5, 2, -1]
// ➔ 5
["Max", 0, 7.1, "NaN", "x", 3]
// ➔ ["Max", 7.1, "NaN", "x"]

["Max", x1, x2, ...]

["Max", list]

If all the arguments are real numbers, excluding NaN, evaluate to the smallest of the arguments.

Otherwise, simplify the expression by removing values that are greater than or equal to the smallest real number.

\min(0, 7.1, 3) = 0
$$\min(0, 7.1, 3) = 0$$
["Min", 5, 2, -1]
// ➔ -1
["Min", 0, 7.1, "x", 3]
// ➔ ["Min", 0, "x"]

["Mod", a, b]

Evaluate to the Euclidian division (modulus) of a by b.

When a and b are positive integers, this is equivalent to the % operator in JavaScript, and returns the remainder of the division of a by b.

However, when a and b are not positive integers, the result is different.

The result is always the same sign as b, or 0.

["Mod", 7, 5]
// ➔ 2

["Mod", -7, 5]
// ➔ 3

["Mod", 7, -5]
// ➔ -3

["Mod", -7, -5]
// ➔ -2

["Rational", n]

Evaluate to a rational approximating the value of the number n.

["Rational", 0.42]
// ➔ ["Rational", 21, 50]

["Rational", numerator, denominator]

Represent a rational number equal to numeratorover denominator.

["Numerator", expr]

Return the numerator of expr.

Note that expr may be a non-canonical form.

["Numerator", ["Rational", 4, 5]]
// ➔ 4

["Denominator", expr]

Return the denominator of expr.

Note that expr may be a non-canonical form.

["Denominator", ["Rational", 4, 5]]
// ➔ 5

["NumeratorDenominator", expr]

Return the numerator and denominator of expr as a sequence.

Note that expr may be a non-canonical form.

["NumeratorDenominator", ["Rational", 4, 5]]
// ➔ ["Sequence", 4, 5]

The sequence can be used with another function, for example GCD to check if the fraction is in its canonical form:

["GCD", ["NumeratorDenominator", ["Rational", 4, 5]]]
// ➔ 1

["GCD", ["NumeratorDenominator", ["Rational", 8, 10]]]
// ➔ 2