Skip to content
Varlig Guide
Varlig home

Word-based mathematics

Many built-in functions can also be written as an English phrase, such as half of £37, greater of £20 and per player or average of 22 min, 25 min and 24 min. This page lists those phrases, grouped by what they do, with the function each one matches. Reach for it when you want a calculation to read like the sentence you would say out loud. The phrase and the function do the same job, so use whichever reads better in your note.

Halves, smaller and larger values

calc
half of £37 gives £18.50
double £80 gives £160.00
twice 45 min gives 90 min
the difference between £120 and £85 gives £35.00
lesser of £250 and 10% of £3,000 gives £250.00
greater of £15 and 3% of £1,200 gives £36.00
smaller of 5 km and 3 miles gives 4.828032 km

double and twice multiply by two, and triple by three. the difference between gives how far apart two values are, whichever you write first, so it’s never negative. Between two places, difference between London and Tokyo still gives their time difference.

lesser of and smaller of pick the smaller of two values; greater of and larger of pick the larger. They are handy for caps and minimums: the lesser of line caps a 10% fee at £250, and the greater of line charges 3% with a minimum of £15. When the two values use different units, the answer is given in the first value’s unit.

clamp keeps a value within a range. It works with plain numbers, money, quantities and durations, and keeps the unit, as long as the value and both limits measure the same thing:

calc
clamp 32 between 10 and 25 gives 25
clamp 8 from 10 to 25 gives 10
clamp 23 °C between 18 °C and 21 °C gives 21 °C
clamp £120 between £0 and £100 gives £100.00
clamp 2.5 kg between 500 g and 2 kg gives 2 kg

The thermostat line holds a setting at 21 °C, and the next caps a refund at £100.

Remainders, factors and primes

calc
remainder of 50 divided by 6 gives 2
gcd of 24 and 36 gives 12
lcm of 12 and 15 gives 60
is 97 prime gives true
is 91 a prime number gives false

remainder of is the same as mod: 50 eggs in boxes of six leave 2 over. gcd is the greatest common divisor: the largest square tile that fits a 24 cm by 36 cm panel exactly is 12 cm. lcm is the lowest common multiple, so buses every 12 minutes and every 15 minutes leave together every 60 minutes.

Primality is exact for whole numbers up to 2^63. Numbers with a decimal part and negative numbers give false.

Powers, roots and logarithms

calc
10 squared gives 100
2 cubed gives 8
3 raised to 4 gives 81
2 to the power of 10 gives 1,024
square root of 144 gives 12
cube root of 1,000 gives 10
root 4 of 81 gives 3
log base 2 of 1,024 gives 10
1,024 is 2 to what power gives 10

squared and cubed apply to what’s straight before them, as ² and ³ do, so 5 m squared is the area 5 m² and (5 m) squared is 25 m². root n of x and n root of x take any root. log base b of x and log x base b give the logarithm to any base, and x is b to what power asks the same question the other way round.

Counting arrangements

calc
10 combination 2 gives 45
10 choose 3 gives 120
8 permutation 3 gives 336

n combination k counts the ways to choose k things from n when order doesn’t matter: ten people shaking hands with each other make 45 handshakes. n choose k is another way to say it, so 10 choose 3 is the number of ways to pick three people from ten. n permutation k counts them when order does matter: eight runners can fill the gold, silver and bronze places in 336 ways. To count every possible finishing order, use a factorial: 8! is 40,320.

Totals and averages

List the values after the phrase, separated by commas, with and before the last one if you like:

calc
sum of £12.50, £8.20 and £4.30 gives £25.00
average of 22 min, 25 min, 24 min, 41 min and 23 min gives 27 min
median of 22 min, 25 min, 24 min, 41 min and 23 min gives 24 min
min of £4.20, £3.80, £5.10 gives £3.80
max of £4.20, £3.80, £5.10 gives £5.10
count of £4.20, £3.80, £5.10 gives 3
standard deviation of 20 min, 25 min and 30 min gives 5 min

total of is the same as sum of, and mean of is the same as average of. The average and median of the same commute times differ because one slow day (41 minutes) pulls the average up but barely moves the median. standard deviation of gives the sample standard deviation.

For more on working with lists, including sorting and filtering, see Lists and statistics.

Random values

random number between a and b picks a whole number from a to b, including both ends. The answer changes each time it is worked out, so these examples show one possible draw:

calcAnswers depend on today’s date or live data
random number between 1 and 6 gives 4
winning ticket = random number between 1 and 250 gives 200
random() gives 0.7220223468
Form Gives
random number between 1 and 10 A whole number from 1 to 10, including both
random(1, 6), rand(1, 6) The same, as a function
random(), rand() A fraction from 0 up to, but not including, 1
random(0, 1) A fraction between 0 and 1, not a choice of 0 or 1

The bounds must be whole numbers without units, and the first must not be larger than the second. A draw stored in a name, like winning ticket above, stays fixed while you work on the rest of the note, and is drawn again when the note is loaded or recalculated.

All phrases at a glance

Phrase Example Result Function form
half of x half of £37 £18.50 x / 2
double x, twice x, triple x double £80 £160.00 x * 2
the difference between a and b the difference between £120 and £85 £35.00 abs(a - b)
a in b, for two numbers 1 in 5 as % 20% a / b
lesser of a and b, smaller of lesser of 3 and 5 3 min(a, b)
greater of a and b, larger of greater of 3 and 5 5 max(a, b)
clamp x between a and b, clamp x from a to b clamp 32 between 10 and 25 25 clamp(x, a, b)
remainder of a divided by b remainder of 50 divided by 6 2 a mod b
gcd of a and b gcd of 24 and 36 12 gcd(a, b)
lcm of a and b lcm of 12 and 15 60 lcm(a, b)
is n prime, is n a prime number is 97 prime true
a divided by b 17 divided by 5 3.4 a / b
a multiplied by b £3.50 multiplied by 4 £14.00 a * b
x squared, x cubed 10 squared 100 x^2, x^3
a to the power of b, a raised to b, a exponent b 2 to the power of 10 1,024 a^b
square root of x square root of 144 12 sqrt(x)
cube root of x cube root of 1,000 10 cbrt(x)
root n of x, n root of x root 4 of 81 3 (no general function)
log base b of x, log x base b log base 2 of 1,024 10 logbase(x, b)
x is b to what power 1,024 is 2 to what power 10 logbase(x, b)
n combination k, n choose k 10 choose 3 120 combination(n, k)
n permutation k 8 permutation 3 336 permutation(n, k)
sum of a, b and c, total of sum of 1, 2 and 3 6 sum([a, b, c]), total([a, b, c])
mean of, average of mean of 24, 31, 28 and 29 28 average([…]), avg([…])
median of, min of, max of, count of median of 3, 7, 9, 12, 40 9
standard deviation of standard deviation of 20, 25 and 30 5 stddev([…]), stdev([…])
random number between a and b random number between 1 and 10 a whole number random(a, b)

The function reference covers every function form in detail.

Putting it together

Working out fixtures and fees for a small five-a-side league:

calc
# Five-a-side league
teams = 6
matches = teams choose 2 gives 15
pitch hire = £54
season cost = matches * pitch hire gives £810.00
players = 45
players / teams rounded down gives 7
remainder of players divided by teams gives 3
per player = season cost / players gives £18.00
fee = greater of £20 and per player gives £20.00

If every team plays every other team once, six teams need 15 matches. Forty-five players make squads of seven with three reserves left over, and greater of sets the fee to the club’s £20 minimum because the pitch hire alone only works out at £18 each.