## Operators, Functions, and Properties – part 5

In earlier parts of this series, we have talked about devices that change their state when you press some button.  Such devices are both very normal and very common.  A very simple example of this is a counter, where the state is a count, and pressing a button has the effect of increasing the count by one (another button may have the effect of resetting the count to zero).  Not all state changes necessarily require the pushing of a button.  A familiar example is a stopwatch, a simple version of which has a state with two components.  One component is the time shown; the other component says something about how the device was left: running/stopped/paused.  When the device is in the running state, the time shown component of the state will advance on its own, through the passing of time.  In the paused state, the time shown component will not change, even though time passes all the same.  On the stopwatch, pressing the buttons mostly changes this second part of the state, though obviously the time shown component can be set to zero.

So far, I haven’t really connected the various devices and buttons to the thing that mathematicians usually mean when they talk about operators.  A simple way to connect them is to say that a button is an operator, operating on the state of the device.  Perhaps a more precise way of speaking is to say that a button invokes an operator.  The main thing I’ve wanted to convey with my examples here is that operators aren’t limited to operating on numbers.  More generally, operators operate on a state.  That state may or may not be associated with a single number.  The device may or may not show its entire state; and moreover, pressing “clear” (or switching the device off and back on) may or may not reset the device to a known state.

On a calculator, button presses of buttons labeled “+”, “-“, correspond to addition and subtraction operations, respectively.  It is interesting that we can treat the “2” button as an operator also, operating on the number in the window.  This way of looking at things is fairly normal for a computer scientist, and fairly unusual for a normal user of a calculator, or even for a mathematician.  And yet, to characterize what the “2” button does, in mathematical terms, isn’t terribly hard.  Below, we show the effect of the operator “2” for some set of numbers:

You may notice that we’re only showing positive whole numbers – that’s on purpose: you are welcome to look for yourself how the “2” button behaves when the window in the calculator is showing a negative number, or look at what the “2” does once a decimal point button has been pressed.  Restricting ourselves, for simplicity, to positive whole numbers, we can characterize what the effect of pressing “2” is to the number shown in the window.  For example, we can see that pressing “2” makes the number bigger.  We can see that the window changes to show a number with a “2” at the end.  But, clearly, the relationship of the new number to the number shown before is much more specific than just “bigger” or “now showing a 2 at the end”.  The relationship of the new number to the old number is a very precise one.

Can you figure out what that relationship is?

If you graph the old number versus the new number, you get a straight line – and a very steep one, unless you change the vertical scale so that the numbers will fit more comfortably.

The graph above is obtained from the table above, using Excel.  The axes are not marked, but the horizontal axis represents the number already showing in the window, and the vertical axis represents the number showing in the calculator window after the “2” has been pressed.  We can obtain the new number in the window from the previous one through the following formula:

$new = old \times 10 + 2$

In other words, you take the number currently showing in the window, multiply it by 10, and then add two.  That gives you the new number showing in the window.  And, believe it or not, this is exactly what the calculator does, each time you hit the “2” button as part of a whole number!

This entry was posted in Uncategorized and tagged , . Bookmark the permalink.