## Operators, Functions, and Properties – part 30

In many of the posts in this series we’ve shown operators that work on a single number coming in and that produce a single number coming out.  This is a hugely important subcategory of operators, but single-in single-out operators aren’t by any means the only type.  So let’s take a look at the operators typically encountered in K-12 mathematics in the United States.

The arithmetic operations from elementary school: add, subtract, multiply, divide – these are usually conceived as two-input, one-output operations.  There are some more you learn in secondary school: exponentiation, and perhaps the min and max operators we looked at in the previous post.  Interestingly, most of the new operations you learn in secondary school are single-input types: absolute value, square, square root; and later on sin, cos, tan and other trigonometric functions, and log.  Occasionally, secondary school students run into situations where there are more than two inputs (e.g. to find a slope of a line going through two given points) but these rarely rise to the level of standardized notation.

Even things like the quadratic formula, which looks for the value of $x$ for which $ax^2 +bx + c = 0$, and where the numbers $a, b$, and $c$ could be regarded as the inputs, is rarely seen or treated as an operator.  Instead, it is treated as a series of one-offs: here’s an equation, solve it.  Here’s another equation, solve it too.

There is a vocabulary to distinguish these kinds of operators and functions, though the vocabulary is more firmly established in computer science than it is in mathematics.  The one-in, one-out kind are called unary operators and unary functions; the two-in, one-out kind are called binary operators and binary functions.  Functions with three values coming in and one coming out would be called ternary functions, and so on.  Sometimes you see the notation “n-ary function” for a function that has n values coming in (for some unspecified n) and one value coming out.

Some mathematicians might scoff at all this, and bring up that in some sense, all operators and all functions are of the one-in, one-out type.  What comes in, no matter what it is, is called the domain, and what comes out, whatever it is, is called the range.  Neither domain and range have to be numbers.  They can be whatever they need to be.

For example, subtraction can be seen as a single-in, single-out function where the domain (what comes in) consists of pairs of numbers.  The range (what comes out) consists of single numbers.  The image below compares the way we normally think of subtraction, on the left, and subtraction as an operator on a pair of numbers, on the right.

Though the view on the right may seem artificial, it seems less so if you see what we have to do to the diagram on the left to keep straight what input is what.

As another example, sort-by-due-date can be seen as a single-in, single-out operator where the domain consists of a bag of bills and the range consists of a linear arrangement  of these same bills – a special arrangement where the bills that need to be paid soon are up front and the bills that need to be paid later are in the back.

In prior posts in this series, we’ve looked at state machines, where the operators operate on the state of the machine.   We’ve played with stopwatches and calculators as examples of such machines.  Sometimes the state of these machines consisted of a single number, but more commonly, the state consists of multiple numbers and other things.  For example, the state of the tab in your browser window includes a history of sites, so that the “back” operator has a way to get you back to the site you were before you clicked on a link.

In the next post, we’ll play with some operators that have interesting domains and interesting ranges.