Dotdown™ · functions

Functions

Write a function name, an open bracket, its values separated by commas, and a close bracket. Inside the brackets you can put any formula.

A function name only counts when a bracket follows it, so a variable can still be called mean or slope. Functions are calculated exactly, like the rest of Dotdown™. They can sit inside bigger formulas: sqrt(a) + 1, pow(1 + r, years) × start.

Numbers

FunctionGivesExample
sqrt(x)Square root. A negative number cannot be calculated.
sqrt(16) → 4
abs(x)Drops the minus sign.
abs(0 − 7) → 7
pow(x, n)x to the power n. A whole n is exact and can be negative. A fraction (0.5, 1 ÷ 3) needs x above zero.
pow(1.05, 10) → 1.62889…
pow(8, 1 ÷ 3) → 2
min(a, b)The smaller of two.
min(3, 8) → 3
max(a, b)The larger of two.
max(3, 8) → 8
mod(a, b)The remainder of a ÷ b, with the sign of b, like Excel.
mod(10, 3) → 1
mod(-3, 2) → 1
floor(x)Down to a whole number.
floor(-2.5) → -3
ceil(x)Up to a whole number.
ceil(2.1) → 3
factorial(n)n × (n−1) × … × 1. n is a whole number from 0 to 1000.
factorial(5) → 120
choose(n, k)Ways to pick k out of n, order ignored.
choose(5, 2) → 10

Growth, logs and angles

FunctionGivesExample
exp(x)e to the power x.
exp(1) → 2.71828…
ln(x)Natural log. x must be above zero.
ln(2) → 0.69314…
log(x)Log base 10. x must be above zero.
log(1000) → 3
pi()π. The brackets stay empty.
pi() → 3.14159…
sin(x)Sine. x is in radians.
sin(pi() ÷ 6) → 0.5
cos(x)Cosine. x is in radians.
cos(pi()) → -1
tan(x)Tangent. x is in radians.
tan(pi() ÷ 4) → 1

These are worked out to about 30 digits, which is far more than a result shows, and sin(pi()) comes out as exactly 0. Angles are in radians: multiply degrees by pi() ÷ 180.

Lists

List functions take a .list variable, which the customer fills with comma-separated numbers. The value must be that one variable, not a formula. See Inputs.

FunctionGivesFor example
sum(list)Add them up.70, 85, 90 → 245
count(list)How many numbers.70, 85, 90 → 3
product(list)Multiply them together.2, 3, 4 → 24
lowest(list)The smallest number.9, 4, 6 → 4
highest(list)The largest number.9, 4, 6 → 9
mean(list)The average.70, 85, 90 → 81.66…
median(list)The middle value, or the average of the middle two.70, 85, 90 → 85
variance(list)Spread, over exactly these numbers (divides by n).2, 4, 6 → 2.66…
stddev(list)Square root of the variance.2, 4, 6 → 1.63…
percentile(list, p)The value at p percent, p from 0 to 100, between neighbours like Excel’s PERCENTILE.INC.p = 50 gives the median
zscore(x, list)How many standard deviations x is from the list’s mean.zscore(95, scores)
sumproduct(list1, list2)Multiply two equal-length lists item by item, then add up. A weighted sum, a dot product.1, 2, 3 and 4, 5, 6 → 32
slope(xs, ys)The slope of the best-fit straight line through paired lists (least squares, like Excel’s SLOPE).1, 2, 3 and 3, 5, 7 → 2
intercept(xs, ys)Where that line sits at x = 0 (like Excel’s INTERCEPT).1, 2, 3 and 3, 5, 7 → 1
correlation(list1, list2)How closely two equal-length lists move together, from -1 to 1.correlation(hours, marks)
.list scores: Test scores
.r1 Average: mean(scores)
.r2 Marks given: count(scores)

A trend line

.list months: Month number
.list sales: Sales (RM)
.input next: Month to predict positive
.r1 Growth per month (RM): slope(months, sales)
.r2 Predicted sales (RM): intercept(months, sales) + r1 × next

Chance (normal distribution)

For bell-curve questions: where a score ranks, or what cutoff leaves 5% above. sd is the standard deviation and must be above zero.

FunctionGivesExample
normdist(x, mean, sd)The chance a normally spread value is at or below x.
normdist(70, 50, 10) → 0.97725
norminv(p, mean, sd)The reverse: the x that a value stays below with chance p (p between 0 and 1).
norminv(0.975, 0, 1) → 1.95996…
.input score: Your score
.input average: Average score
.input sd: Spread (standard deviation) positive
.r1 Share of people at or below you: normdist(score, average, sd) × 100

Answers beyond 10 standard deviations from the mean are rounded to 0 or 1, and norminv refuses a p that close to 0 or 1.

Money

FunctionGives
pmt(rate, periods, loan)The payment each period to pay off a loan.
fv(rate, periods, payment)What regular payments grow to.
pv(rate, periods, payment)What regular payments are worth today.
  • The rate is per period. For a yearly rate paid monthly, divide by 12 (and by 100 for a percent), and make the periods months: years × 12.
  • Signs follow Excel. Money you pay out is negative, so pmt on a positive loan is negative. Wrap it in abs(), or write 0 − pmt(…), for a plain positive payment. For fv and pv put the payment in as a negative (0 − monthly) to get a positive result.
  • Periods must be a whole number of at least 1 for pmt. A rate of 0 works (the loan is split evenly). Payments are at the end of each period.

Loan payment

.input loan: Loan (RM) positive
.input rate: Yearly interest (%) positive
.input years: Years positive
.r1 Monthly payment (RM): abs(pmt(rate ÷ 100 ÷ 12, years × 12, loan))

Savings

.input monthly: Saved each month (RM) positive
.input years: Years positive
.r1 After the years (RM): fv(0.04 ÷ 12, years × 12, 0 − monthly)

Present value

.r1 Worth today (RM): pv(0.05, 10, 0 − 1000)
// 1000 a year for 10 years, at 5%, is worth 7721.73 today

Not in Dotdown yet

Dotdown™ does numbers and true / false only. There are no dates, no text, no lookups like VLOOKUP, no cell ranges like A1:B10, no matrices, no loops, and no multi-variable regression or other distributions. Use a constant for a fixed table of numbers, and a module to pick from it.

Open the builder