Mathematical Functions Reference
Every function and constant available in ToFUL expression fields is listed here. The same namespace applies to both the PMF/PDF field and — where relevant — to the range field.
Constants
Name |
Value |
Notes |
|---|---|---|
|
3.14159265… |
Mathematical constant π. Also accepted as |
|
2.71828182… |
Euler’s number. Do not use |
|
∞ |
Positive infinity. Use in bounds fields only. |
|
Not a Number |
Returned by undefined operations. Avoid in PMF/PDF. |
Exponential and Logarithmic
Function |
Description |
|---|---|
|
Exponential function \(e^x\). Alias: |
|
Natural logarithm \(\ln x\). Alias: |
|
Base-2 logarithm \(\log_2 x\). |
|
Base-10 logarithm \(\log_{10} x\). Alias: |
|
Square root \(\sqrt{x}\). Alias: |
Trigonometric
Function |
Description |
|---|---|
|
Sine (argument in radians). |
|
Cosine (argument in radians). |
|
Tangent (argument in radians). Undefined at \(x = \pi/2 + k\pi\). |
|
Arcsine. Range \([-\pi/2, \pi/2]\). Alias: |
|
Arccosine. Range \([0, \pi]\). Alias: |
|
Arctangent. Range \((-\pi/2, \pi/2)\). Alias: |
|
Four-quadrant arctangent. Returns angle in \((-\pi, \pi]\). |
|
Hyperbolic sine. |
|
Hyperbolic cosine. |
|
Hyperbolic tangent. |
Rounding and Sign
Function |
Description |
|---|---|
|
Absolute value \(|x|\). Alias: |
|
Ceiling — smallest integer ≥ x. |
|
Floor — largest integer ≤ x. |
|
Sign function: −1 for negative, 0 for zero, +1 for positive. |
|
Round to nearest integer (banker’s rounding for .5). |
|
Minimum of two values. |
|
Maximum of two values. |
Special Functions
Function |
Description |
|---|---|
|
Factorial \(n!\). Integer argument only. For real-valued
generalisation, use |
|
Gamma function \(\Gamma(x) = \int_0^\infty t^{x-1}e^{-t}\,dt\). Satisfies \(\Gamma(n) = (n-1)!\) for positive integers. |
|
Error function \(\text{erf}(x) = \frac{2}{\sqrt{\pi}}\int_0^x e^{-t^2}\,dt\). |
|
Complementary error function \(\text{erfc}(x) = 1 - \text{erf}(x)\). |
Operator Reference
Operator |
Unicode alias |
Meaning |
|---|---|---|
|
— |
Addition |
|
|
Subtraction / negation |
|
|
Multiplication |
|
|
Division (true division, always returns float) |
|
|
Exponentiation |
|
|
Less than or equal |
|
|
Greater than or equal |
|
— |
Equal (use in conditionals: |
|
|
Not equal |
|
|
Logical and (for compound conditions) |
|
|
Logical or |
|
|
Logical not |
Examples
# Gamma(alpha=3, beta=2) PDF
(x**2 * exp(-x/2)) / (2**3 * gamma(3)) if x >= 0 else 0
# Standard Normal PDF
exp(-(x**2)/2) / sqrt(2*pi)
# Poisson(lambda=4) PMF
(exp(-4) * 4**x) / factorial(x) if x >= 0 else 0
# Beta(2,3) PDF — check: normalising constant = B(2,3)^-1 = 12
12 * x * (1-x)**2 if 0 <= x <= 1 else 0
# Laplace(mu=0, b=1) PDF
exp(-abs(x)) / 2
See also
Input Syntax Guide — full parser auto-correction table
Debugging Functions — fixing syntax errors