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
| Function | Gives | Example |
|---|---|---|
sqrt(x) | Square root. A negative number cannot be calculated. |
|
abs(x) | Drops the minus sign. |
|
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. |
|
min(a, b) | The smaller of two. |
|
max(a, b) | The larger of two. |
|
mod(a, b) | The remainder of a ÷ b, with the sign of b, like Excel. |
|
floor(x) | Down to a whole number. |
|
ceil(x) | Up to a whole number. |
|
factorial(n) | n × (n−1) × … × 1. n is a whole number from 0 to 1000. |
|
choose(n, k) | Ways to pick k out of n, order ignored. |
|
Growth, logs and angles
| Function | Gives | Example |
|---|---|---|
exp(x) | e to the power x. |
|
ln(x) | Natural log. x must be above zero. |
|
log(x) | Log base 10. x must be above zero. |
|
pi() | π. The brackets stay empty. |
|
sin(x) | Sine. x is in radians. |
|
cos(x) | Cosine. x is in radians. |
|
tan(x) | Tangent. x is in radians. |
|
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.
| Function | Gives | For 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.
| Function | Gives | Example |
|---|---|---|
normdist(x, mean, sd) | The chance a normally spread value is at or below x. |
|
norminv(p, mean, sd) | The reverse: the x that a value stays below with chance p (p between 0 and 1). |
|
.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
| Function | Gives |
|---|---|
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
pmton a positive loan is negative. Wrap it inabs(), or write0 − pmt(…), for a plain positive payment. Forfvandpvput 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.