Arithmetic

Constants

Symbol Value
ExponentialE \(2.7182818284\ldots\) Euler’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\ldots \] See Euler-Mascheroni Constant on Wikipedia

Relational Operators

Function Notation
Equal \( x = y \)
Mathematical relationship asserting that two quantities have the same value
Greater \( x \gt y \)
GreaterEqual \( x \geq y \)
Less \( x \lt y \)
LessEqual \( x \leq y \)
NotEqual \( x \ne y \)

See below for additonal relational operators: Congruent, etc…

Functions

Function Notation
Add \( a + b\) Addition numeric
Subtract \( a - b\) Subtraction numeric
Negate \(-a\) Additive inversenumeric
Multiply \( a\times b \) Multiplication numeric
Divide \( \frac{a}{b} \) Divide numeric
Power \( a^b \) Exponentiation numeric
Root \(\sqrt[n]{x}=x^{\frac1n}\) n-th root numeric
Sqrt \(\sqrt{x}=x^{\frac12}\) Square rootnumeric
Square \(x^2\) numeric

Transcendental Functions

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

Rounding

Function Notation
Abs \(|x| \) Absolute value, magnitude numeric
Ceil Rounds a number up to the next largest integer numeric
Chop Replace real numbers that are very close to 0 (less than \(10^{-10}\)) with 0 numeric
Floor Round a number to the greatest integer less than the input value numeric
Round numeric

Other Relational Operators

Congruent

["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

["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

["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

["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"]

Min

["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

["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

["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

["Numerator", expr]

Return the numerator of expr.

Note that expr may be a non-canonical form.

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

Denominator

["Denominator", expr]

Return the denominator of expr.

Note that expr may be a non-canonical form.

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

NumeratorDenominator

["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