Arithmetic
Constants
| Symbol | Value | |
|---|---|---|
ExponentialE | \approx 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 | \approx 0.9159655941\ldots | \sum_{n=0}^{\infty} \frac{(-1)^{n}}{(2n+1)^2} See Catalan's Constant on Wikipedia |
GoldenRatio | \approx 1.6180339887\ldots | \frac{1+\sqrt{5}}{2} See Golden Ratio on Wikipedia |
EulerGamma | \approx 0.5772156649\ldots | See Euler-Mascheroni Constant on Wikipedia |
Functions
Arithmetic Functions
| Function | Notation | |
|---|---|---|
Add | a + b | Addition |
Subtract | a - b | Subtraction |
Negate | -a | Additive inverse |
Multiply | a\times b | Multiplication |
Divide | \frac{a}{b} | Divide |
Power | a^b | Exponentiation |
Root | \sqrt[n]{x}=x^{\frac1n} | nth root |
Sqrt | \sqrt{x}=x^{\frac12} | Square root |
Square | x^2 |
Sums and Products
Sum(xs: collection)
Evaluate to a sum of all the elements in collection. If all the elements are
numbers, the result is a number. Otherwise it is an ["Add"] expression.
["Sum", ["List", 5, 7, 11]]
// ➔ 23
["Sum", ["List", 5, 7, "x" , "y"]]
// ➔ ["Add", 12, "x", "y"]
Note this is equivalent to:
["Reduce", ["List", 5, 7, 11], "Add"]
Sum(body: function, ...bounds: tuple) -> number
Evaluate to the sum of body for each value in bounds.
["Sum", ["Add", "i", 1], ["Tuple", "i", 1, 10]]
// ➔ 65
Product(xs: collection)
Evaluate to a product of all the elements in collection.
If all the elements are numbers, the result is a number. Otherwise it is a ["Multiply"] expression.
["Product", ["List", 5, 7, 11]]
// ➔ 385
["Product", ["List", 5, "x", 11]]
// ➔ ["Multiply", 55, "x"]
Note this is equivalent to:
["Reduce", ["List", 5, 7, 11], "Multiply"]
Product(f: function, bounds:tuple)
Return the product of bodyfor each value in bounds.
["Product", ["Add", "x", 1], ["Tuple", "x", 1, 10]]
// ➔ 39916800
Transcendental Functions
| Function | Notation | |
|---|---|---|
Exp | \exponentialE^{x} | Exponential function |
Ln | \ln(x) | Logarithm function, the natural logarithm, 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
| Function | Notation | |
|---|---|---|
Abs | \|x\| | Absolute value, magnitude |
Ceil | \lceil x \rceil | Rounds a number up to the next largest integer |
Floor | \lfloor x \rfloor | Round a number to the greatest integer less than the input value |
Chop | Replace real numbers that are very close to 0 (less than 10^{-10}) with 0 | |
Round |
Other Relational Operators
Congruent(a, b, modulus)
Evaluate to True if a is congruent to b modulo modulus.
["Congruent", 26, 11, 5]
// ➔ True
Other Functions
Clamp(value)
Clamp(value, lower, upper)
- If
valueis less thanlower, evaluate tolower - If
valueis greater thanupper, evaluate toupper - 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", 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
Relational Operators
| Function | Notation | |
|---|---|---|
Equal | x = y | Mathematical relationship asserting that two quantities have the same value |
NotEqual | x \ne y | |
Greater | x \gt y | |
GreaterEqual | x \geq y | |
Less | x \lt y | |
LessEqual | x \leq y |
See below for additonal relational operators: Congruent, etc...