Reference

Functions

Functions take arguments in parentheses, separated by commas. Each argument can itself be an expression.

avg(99, 34, 65, 213, 45, 123)
max(10m, 30k, 7.7m)
bayes(0.01, 0.9, 0.05)
derivative(2x^2, x)

Math and number theory

FunctionDescriptionExample
abs(x)Absolute valueabs(-234)
sum(...)Add all arguments, unit-awaresum(12, 23, 52)
fraction(x)Reduced fractionfraction(0.625)
mixed fraction(x)Mixed-number fractionmixed fraction(7/3)
isprime(x)Primality testisprime(91)
factors(x)All positive divisorsfactors(28)

Statistics

FunctionDescriptionExample
avg(...) / mean(...)Arithmetic meanavg(70, 80, 90)
median(...)Middle valuemedian(2, 4, 4, 6)
range(...)Largest minus smallestrange(2, 4, 10)
variance(...)Population variancevariance(2, 4, 4, 6)
standard deviation(...)Population standard deviationstandard deviation(2, 4, 4)
harmonic mean(...)Harmonic meanharmonic mean(8, 12, 15)
geometric mean(...)Geometric meangeometric mean(8, 12, 15)

Sets and combinatorics

Function / operatorDescriptionExample
max(...)Maximum value, unit-awaremax(10m, 30k, 7.7m)
min(...)Minimum value, unit-awaremin(12 meters, 12 miles)
lcm(...)Least common multiplelcm(12, 15, 18, 25)
gcd(...)Greatest common divisorgcd(12, 15, 18, 25)
permPermutations, order matters10 perm 3
combCombinations, order ignored10 comb 3

Probability

FunctionDescriptionExample
P(x)Probability literal between 0 and 1P(10%)
conditional(pAandB, pB)Conditional probability P(A|B)conditional(0.12, 0.3)
bayes(prior, likelihood, fp)Bayes posterior P(H|E)bayes(0.01, 0.9, 0.05)
odds(p)Odds for a probabilityodds(0.75)
probability from odds(o)Probability implied by oddsprobability from odds(3)
binomial(n, k, p)Exactly k successes in n trialsbinomial(10, 3, 0.5)
expected value(v1, p1, ...)Weighted sum of value/probability pairsexpected value(10, 0.5, 20, 0.5)

Finance

FunctionDescriptionExample
simple interest(p, r, t)Interest onlysimple interest(10000, 5%, 2 years)
compound interest(p, r, t, n)Compound interest earnedcompound interest(1000, 10%, 2 years)
future value(p, r, t, n)Principal plus compound growthfuture value(1000, 10%, 2 years)
present value(fv, r, t, n)Present value of a future amountpresent value(1210, 10%, 2 years)
cagr(start, end, t)Compound annual growth ratecagr(1000, 2000, 10 years)
emi(p, r, t)Monthly amortizing loan paymentemi(500000, 6.5%, 30 years)
mortgage(p, r, t)Alias for emimortgage(500000, 6.5%, 30 years)
loan payment(p, r, t)Alias for emiloan payment(500000, 6.5%, 30 years)
loan interest(p, r, t)Total interest paidloan interest(100000, 12%, 1 year)
future value annuity(pmt, r, t, n)Future value of equal paymentsfuture value annuity(1000, 10%, 3 years)
present value annuity(pmt, r, t, n)Present value of equal paymentspresent value annuity(500, 8%, 10 years, 12)
roi(initial, final)Return on investmentroi(1000, 1500)
apy(rate, frequency)Effective annual yieldapy(12%, 12)
profit margin(revenue, cost)Profit as a percent of revenueprofit margin(200, 150)
markup(cost, price)Markup over costmarkup(150, 200)
break even(fixed, price, variable)Units needed to break evenbreak even(10000, 50, 30)
runway(cash, burn)Months of cash runwayrunway(100000, 8000)
doubling time(rate)Rule-of-72 estimate in yearsdoubling time(8%)
tip(bill, rate)Tip amounttip(80, 18%)
tip total(bill, rate)Bill including the tiptip total(80, 18%)
discount(price, rate)Sale price after a discount (alias sale price)discount(200, 25%)
sales tax(price, rate)Tax on a pricesales tax(100, 8%)
price with tax(price, rate)Price including taxprice with tax(100, 8%)
npv(rate, cf0, cf1, ...)Net present value of a cashflow seriesnpv(10%, -1000, 500, 500, 500)
irr(cf0, cf1, ...)Internal rate of return, as a percentirr(-1000, 500, 500, 500)
depreciation(cost, salvage, life)Straight-line depreciation per yeardepreciation(10000, 1000, 5)

Health and fitness

Body-composition and fitness metrics. Inputs accept weight/height units. See Health & Fitness for the formula standards.

FunctionDescriptionExample
bmi(weight, height)Body Mass Indexbmi(70, 1.75)
bmr male(w, h, age) / bmr female(...)Basal metabolic rate, kcal/daybmr male(80, 180, 30)
tdee(bmr, factor)Total daily energy expendituretdee(1780, 1.55)
body fat male(w, h, age) / body fat female(...)Body fat % (Deurenberg)body fat male(80, 1.8, 30)
ideal weight male(height) / ideal weight female(...)Ideal weight, kg (Devine)ideal weight male(180 cm)
max heart rate(age)Maximum heart rate, bpmmax heart rate(30)
target heart rate(age, intensity)Target heart-rate zone, bpmtarget heart rate(30, 70%)
calories burned(met, weight, minutes)Calories for an activitycalories burned(8, 70, 30)
water intake(weight)Suggested daily waterwater intake(70 kg)

Symbolic algebra

FunctionDescriptionExample
simplify(expr)Collect like termssimplify(2x^2 - 4x^2)
derivative(expr, variable)Derivativederivative(2x^2, x)
diff(expr, variable)Alias for derivativediff(sin(x), x)
integrate(expr, variable)Indefinite integralintegrate(2x^2 + 3x, x)
integral(expr, variable)Alias for integrateintegral(2x^2 + 3x, x)
integrate(expr, variable, a, b)Definite integralintegrate(2x^2, x, 0, 5)
limit(expr, variable, point)Limitlimit(sin(x)/x, x, 0)

IP addresses

FunctionDescriptionExample
ipv4(n)Build IPv4 address from integeripv4(3232235777)
ipv6(n)Build IPv6 address from integeripv6(1)
network(cidr)Network addressnetwork(192.168.1.130/24)
broadcast(cidr)Broadcast addressbroadcast(192.168.1.0/24)
netmask(cidr)Subnet masknetmask(10.0.0.0/24)
subnetmask(cidr)Alias for netmasksubnetmask(10.0.0.0/24)
wildcard(cidr)Inverse maskwildcard(192.168.1.0/24)
firsthost(cidr)First usable hostfirsthost(192.168.1.0/24)
lasthost(cidr)Last usable hostlasthost(192.168.1.0/24)
hosts(cidr)Usable host counthosts(192.168.1.0/24)
addresses(cidr)Total address countaddresses(192.168.1.0/24)
prefix(maskOrCidr)Prefix lengthprefix(255.255.255.0)
version(address)IP version, 4 or 6version(2001:db8::1)
contains(cidr, address)Subnet membershipcontains(192.168.1.0/24, 192.168.1.5)
isprivate(address)Private address testisprivate(10.1.2.3)
ispublic(address)Public address testispublic(8.8.8.8)
isloopback(address)Loopback testisloopback(127.0.0.1)
ismulticast(address)Multicast testismulticast(224.0.0.1)

Trigonometry and logarithms

These take the value after the name, and parentheses are optional for plain numeric arguments. See Trigonometry and Logarithms for details.

GroupNames
Basic trigsin, cos, tan, sec, csc, cot
Inverseasin, acos, atan, asec, acsc, acot
Hyperbolicsinh, cosh, tanh, sech, csch, coth
Inverse hyperbolicasinh, acosh, atanh, asech, acsch, acoth
Logarithmslog / loge (natural), log10, log2

Geometry

Shape area, perimeter/circumference, surface area, volume, and line slope. Length units on the arguments carry into the result. See Geometry.

FunctionDescriptionExample
circle area(r)π·r²circle area(5)
circle circumference(r)2·π·r (alias circle perimeter)circle circumference(5)
square area(s) / square perimeter(s)Square area / perimetersquare area(4)
rectangle area(w, h) / rectangle perimeter(w, h)Rectangle area / perimeterrectangle area(3, 4)
triangle area(base, height)½·base·height (or Heron from three sides)triangle area(3, 4, 5)
trapezoid area(a, b, h)½·(a + b)·htrapezoid area(4, 6, 3)
parallelogram area(base, height)base × heightparallelogram area(5, 3)
ellipse area(a, b)π·a·bellipse area(3, 2)
sphere volume(r) / sphere surface area(r)Sphere volume / area (alias sphere area)sphere volume(3)
cube volume(s) / cube surface area(s)Cube volume / surface areacube volume(3)
cylinder volume(r, h) / cylinder surface area(r, h)Cylinder volume / surface areacylinder volume(2, 5)
cone volume(r, h) / cone surface area(r, h)Cone volume / surface areacone volume(2, 6)
rectangular prism volume(l, w, h)Box volume (alias box volume)box volume(2, 3, 4)
pyramid volume(l, w, h)1/3·l·w·hpyramid volume(3, 3, 9)
slope(x1, y1, x2, y2)Slope of a lineslope(0, 0, 2, 4)

Coordinate systems

Constructors build points; a single point argument converts it. See Coordinate Systems for to-conversions and arithmetic.

FunctionDescriptionExample
point(...)Cartesian point/vector (also cartesian, vector)point(1, 2, 3)
polar(r, θ)2-D polar point (θ in degrees)polar(5, 90)
cylindrical(r, θ, z)3-D cylindrical pointcylindrical(2, 90, 5)
spherical(ρ, θ, φ)3-D spherical pointspherical(1, 90, 0)
minkowski(t, x, y, z)Spacetime point (−,+,+,+)minkowski(1, 2, 3, 4)
distance(a, b)Distance between two pointsdistance(point(0,0), point(3,4))
magnitude(v) / norm(v)Length from the originmagnitude(point(3,4))
midpoint(a, b)Midpoint of two pointsmidpoint(point(0,0), point(4,6))
dot(a, b)Dot product (scalar)dot(point(1,2,3), point(4,5,6))
cross(a, b)Cross product of two 3-D vectorscross(point(1,0,0), point(0,1,0))
angle(a, b)Angle between two vectors (degrees)angle(point(1,0), point(0,1))
normalize(v)Unit vectornormalize(point(3,4))
interval(p, q)Signed Minkowski interval s²interval(minkowski(5,0,0,0), minkowski(0,3,0,0))
atan2(y, x)Two-argument arctangent (degrees)atan2(1, 1)
hypot(...)Euclidean norm √(x²+y²+…)hypot(3, 4)

Matrices

Take a matrix literal [1 2, 3 4] (space = column, comma/semicolon = row). See Matrices for arithmetic and the full set.

FunctionDescriptionExample
transpose(A)Transposetranspose([1 2 3, 4 5 6])
determinant(A) / det(A)Determinant of a square matrixdeterminant([1 2, 3 4])
inverse(A) / inv(A)Inverse of an invertible matrixinverse([4 7, 2 6])
adjugate(A) / adj(A)Classical adjointadjugate([1 2, 3 4])
trace(A)Sum of the diagonaltrace([1 2, 3 4])
rank(A)Rankrank([1 2, 2 4])
rref(A)Reduced row-echelon formrref([1 2 3, 4 5 6, 7 8 9])
minor(A, i, j)(i, j) minor (1-indexed)minor([1 2 3, 4 5 6, 7 8 10], 1, 1)
cofactor(A, i, j)(i, j) cofactor (1-indexed)cofactor([1 2 3, 4 5 6, 7 8 10], 1, 2)
identity(n) / eye(n)n×n identityidentity(3)
zeros(n) / zeros(r, c)Zero matrixzeros(2, 3)
ones(n) / ones(r, c)All-ones matrixones(2, 2)
diag(...) / diag(A)Build / extract a diagonaldiag(1, 2, 3)
size(A) / shape(A)Dimensions [rows cols]size([1 2 3, 4 5 6])
rows(A) / cols(A)Row / column countrows([1 2 3, 4 5 6])
hadamard(A, B)Element-wise producthadamard([1 2, 3 4], [10 20, 30 40])
linsolve(A, b)Solve A·x = blinsolve([2 1, 1 3], [5, 10])
eigenvalues(A) / eigvals(A)Eigenvalues (approximate)eigenvalues([2 1, 1 2])
eigenvectors(A) / eigvecs(A)Eigenvectors as columnseigenvectors([2 0, 0 3])

Visualization

Produce a graph rendered below the editor. See Graphing.

FunctionDescriptionExample
draw(...)Graph curves y=f(x), complex numbers, or points (alias plot)draw(x^2)
plot(...)Alias for drawplot(sin(x), cos(x))

Random

Draw random values. In the app the result freezes (a hidden managed seed) so it stays stable across edits; hover the function name to reveal the seed and re-roll. See Random & IDs.

FunctionDescriptionExample
random()Real number in [0, 1)random()
random(max)Whole number from 0 to maxrandom(6)
random(min, max)Whole number from min to maxrandom(10, 100)
uuid()UUID — v7 by default; uuid(4) / uuid(7)uuid()
nanoid()URL-safe id; nanoid(n) sets lengthnanoid()
coin()"heads" or "tails"coin()
randombool()true or falserandombool()
pick(...)One argument chosen at randompick(1, 2, 3)
randomcolor()A random colourrandomcolor()

Hashing

Deterministic hashes and checksums of a quoted string (or a number). Returns a lowercase hex digest. See Hashing.

FunctionDescriptionExample
md5(text)MD5 (128-bit)md5("hello")
sha1(text)SHA-1 (160-bit)sha1("hello")
sha256(text)SHA-256 (256-bit)sha256("hello")
sha384(text)SHA-384 (384-bit)sha384("hello")
sha512(text)SHA-512 (512-bit)sha512("hello")
sha3(text)SHA3-256 (alias sha3_256)sha3("hello")
ripemd160(text)RIPEMD-160 (160-bit)ripemd160("hello")
crc32(text)CRC32 checksumcrc32("hello")

Color constructors

rgb(...), rgba(...), and hsl(...) build colors. See Colors.

rgb(12, 124, 201)
rgba(12, 124, 201, 0.5)
hsl(60, 0.03703, 0.1058)

Constants and special values

pi, e, and i can be used anywhere a compatible number is expected. i is the imaginary unit for complex arithmetic.

2 * pi
e ^ 2
i^2

Function names are generally case-insensitive. Labels are case-sensitive.