﻿ Vector, the Journal of the British APL Association

## Volumes

British APL Association

Archive articles posted online on request: ask the archivist.

Volume 24, No.4

• Proof for author
• 0.3

# by Neville Holmes (neville.holmes@utas.edu.au)

A design for a commodity device called a formulator was outlined in a recently published essay. Just as the calculator extended the abacus beyond basic arithmetic, the formulator is designed to extend commodity computation beyond arithmetic to algebra.

This article examines aspects of the proposed formulator in more detail than given in the essay, and relates its capabilities to those of APL/J interpreters.

## The formulator

Calculators are widely familiar devices that are used to do basic arithmetic. They come in various forms but the simplest, the commodity calculator, is very cheap and apparently simple and reliable. The commodity calculator is also emulated on other handheld devices.

One of the potentially most important uses of calculators is in the teaching of arithmetic in early schooling. They are commonly used for simple quantitative problem solving but could also be adapted easily to teaching basic arithmetic skills.

What is there that goes a bit beyond calculator technology, either in daily life or in later education? Well, there are spreadsheets, but they are more a data management tool than a mathematical tool.

Interpreters like those for APL varieties are of course genuinely and ardently mathematical tools, but they go way beyond what is needed for everyday or school use. This makes them daunting for beginners and dabblers.

What is needed is an intermediary capability, one that combines versatility and simplicity. The formulator has these properties and also has enough in common with APLs that it would make it easier for users to move up.

## The exact calculator

The first step in developing a formulator design is to fix the problems of the commodity calculator. After all, these problems are arguably the reason behind the banning of calculators from primary schooling in countries such as Japan.

There are several significant problems, and these and fixes for them are given in my essay “Truth and Clarity in Arithmetic” in more detail than is appropriate here.

The source of falsehood in the commodity calculator is the adoption of inexact arithmetic pretending to be exact. Exact arithmetic is the cure.

Two measures underpin exactitude: computation with variable length numbers and the use of fractions with a non-decimal denominator.

To make variable length numbers practical, control over the entry and display of such numbers is necessary. For example, scaling is needed on numbers both being keyed in and being displayed. Very long numbers need to be able to abbreviated, but their inexactitude must be clearly shown when this is done.

To make fractions of all kinds practical, numbers with non-decimal denominators must be distinctively represented through use of both a decimal point and a fraction point.

To complete the design of an exact calculator, a variety of very simple functions needs to be added to the miserly ‘normal’ quota. At the very least, quotient and remainder functions are absolutely necessary, both for practical and educational use.

At the same time, inexact values such as multiples of π and inexact functions such as fractional powers need to be excluded, though there are ways that π could be handled symbolically. Simple multiples of π and roots of integers, however, can be approximated by fractions.

One important source of obscurity in the commodity calculator is the disappearance of the numbers being used.

Calculators work on more than one number at a time. Typically there are three numbers immediately relevant to the user of a calculator: two arguments and a result, not to mention the symbol of the function yielding the result. All should be displayed to the user, who should also be able to manipulate them.

## Towards the formulator

The commodity calculator is used to fiddle with numbers one at a time, constructing them by editing and by applying the basic functions provided.

The commodity formulator is designed to be used to fiddle also with functions, constructing them by editing and substitution. Of course the functions are used for numeric calculation, but the focus is on manipulating the functions, that is, on algebraic calculation.

The formulator is necessarily more complex than the calculator. It needs a richer keyboard and character set and more powerful basic functions.

The exact calculator serves as a very appropriate starting point. The published design assumed a conventional numeric keyboard with a sign symbol on either side of the zero key, and a column of four function keys. The signs were used as prefixes to the function keys to modify the four straight functions.

With the larger keyboard needed for the formulator, the function keys could be completely independent of the numeric keys, so that better symbolism could be used.

It is not appropriate here to consider in any detail just what the formulator keyboard should be like, just what basic functions should be provided, and just what symbols should be used. Rather the skeletal structure of the formulator is the focus. However, Ken Iverson’s Turing Award essay is an excellent guide for designers of notation, and the original mathematical symbols should be practical by now.

## Truth and inexact arithmetic

Overtly putting inexact arithmetic onto the exact calculator has two aspects; the use of numbers and the use of functions.

The numbers are entered, edited, and displayed.

The user needs to be able to key numbers in as inexact and, in case of need, to specify just how inexact. Similarly, the user needs to easily see whether the number is exact as shown, or exact but shown inexactly, or inexact with all of the exact part shown, or inexact with the exact part going beyond the end of the number shown.

The functions are selected, modified, and applied.

The basic traditional arithmetic function symbols, such as the saltire × and the obelus ÷, are used, as they are in APL. Variations on those functions are denoted by diacritics (though not shown thus here as it seems such diacritics are not provided by HTML/Unicode), for example the tilde signifies argument commutation: `~÷` for divide into. Numbers – positive, zero, or negative – are used as diacritics or superscripts of a function to have it repeatedly applied, or ignored, or repeatedly inverted.

With inexact arithmetic come various basic functions, such as the trigonometric ones, that normally yield inexact results. Inversion functions, like the square root, even yield more than one result, and, even though it’s popular to ignore all but one, it’s more strict and informative, especially in mathematical education, to produce them all as a set of results. The root function also produces complex numbers, so they need to be handled alongside other kinds of value.

Adding inexact to exact arithmetic broadens the calculator without changing its basic nature as a calculator that applies functions one at a time to one or two arguments. But it does make it rather lopsided with a richness of calculation that involves producing one value from at most two values. The only argument widening described so far is the ability to use a set of numbers as a single value.

The logical next step is therefore to allow lists of values as arguments and results. Again this step has two aspects: handling list arguments and providing structural functions to derive values from such arguments.

A list argument is simply a sequence of numbers separated by spaces. Each item in the list, and each number in a set item, has its exactitude independent of other items or numbers in the list or set.

Because a numeric display of a list could be lengthy, the list calculator offers a variety of ways to view a list as a graph. List arguments can be produced by editing – selecting, joining, truncating, or otherwise fiddling with lists already in the argument stack.

Dyadic functions handle argument lengths as in APL/J, except that a single item list is treated as a scalar. However, a diacritical diple (`<` or `>`) can be used to point to the argument whose items are to be dribbled in so that items of the result are sets of the result from the entire other argument. Used monadically, a function with a diple is reflexive so that the result is the same whichever diple is used.

Much of what is done structurally by functions in APL/J can be done by editing commands in a commodity list calculator. Quite otherwise are those functions that do arithmetic dyadically within the list, collapsing subsequences to single items in various ways. The operators of APL/J are used here as the diacritical modifiers acute ´ and grave `, corresponding to the two solidi / and \.

## Clarity and formulae

The list calculator couples a richness of arithmetic with provision for its application to lists of numbers. The arithmetic functions can be applied by the user to the extent needed and understood, and the lists can be entered, inspected, changed and selected as needed.

The richness has merely been suggested here, with some discussion in the appended notes. Users of APL/J will not be at a loss to fill in the detail in various ways.

However, the design is still of a calculator. The functions are applied one at a time. The next two stages are very simple, but they are the essence of the formulator and the basis for algebraic clarity.

The formulator has a function stack in addition to, and separate from, the argument stack. Just as for the calculator, one or two arguments are set up for the next function to use. The next function is either keyed into the bottom slot in the stack or chosen from the function stack and possibly edited before being used.

A function in the stack can be either a basic function, with or without modifiers, or a composite of such functions, or a train of functions.

A simple composite function is like an integer – notationally juxtaposed functions that build their results up progressively from right to left, from least significant to most significant. Thus only the rightmost function has a choice of being used monadically or dyadically; the others are all monadic since they get their argument from the function to their right. So `÷-` is the reciprocal of either the negation (monadic) or the difference (dyadic) of the argument(s).

However a composite function can also have a dyadic point just like the decimal point of a number. Dyadically, the basic functions to the right of the dyadic point are applied monadically to each argument and the two results become the arguments for the functions to the left. Monadically, the basic functions to the right are applied similarly to produce the second argument at the dyadic point, while the original argument becomes the first argument at the point. So `-∆÷` is the difference of either the reciprocal of two arguments or of the single argument and its reciprocal.

A train of functions is like a list of numbers – a sequence of basic or composite functions separated by spaces. A train serves to repeatedly use its argument(s) while passing results from right to left along the train and combining those results arithmetically with the original argument(s) on the way.

The first, third, and so on functions from the right in a train of odd length are fed the argument(s) of the train as a whole and their results are fed to the intervening dyadic function. A train of even length is in effect made of odd length by prefixing an identity function, `+0` say.

Parentheses may be used within formulae for various effects. For example, modifiers can be applied to an enclosing parenthesis to affect the enclosed function, and a train within parentheses can be used within a composite function.

## Depth and algebra

Composing formulae is the basic level of algebra. The ability to work with patterns of formulae is the next level, and is needed to give depth to the formulator.

A formula pattern or metaformula or template is a functional expression with place holders for substitution of meta-arguments. Templates are keyed in or edited in a template stack alongside the argument and formula stacks.

Once a template is selected for use, functions are selected in the function stack or are keyed in and they replace corresponding place holders in the template wherever they occur and as a single function. When replacement is complete the resulting function is placed in the function stack whence it can be used on selected arguments.

## Rationale

The formulator is not intended to compete with programming systems such the APL/J family. Indeed it is purposefully and drastically simpler, and not only because of the absence of name assignment and the restriction to list arguments.

Rather, the formulator is intended for everyday general use in work and in education – even in the home. In education it opens a wide field beyond simple arithmetic, the arithmetic that the commodity calculator has so badly betrayed, so that it has the potential to support teachers in greatly improving the development of numeracy in their students.

The design of the formulator embodies a contrast between computation and programming, a contrast I pointed out in a published essay on APL of more than thirty years ago. The formulator uses the symbolism of APL in rejecting use of the Roman alphabet, but ideas like trains come from J.

Advanced programming systems like the APL/J family present a forbidding prospect to anyone simply wanting to do some particular ad-hoc calculation. Arguably, this prospect explains why spreadsheets became so much more popular than APL.

Adoption of the formulator would provide an intermediate step between school arithmetic and APL/J systems that would make it easier for people to shift up. Implementation of the formulator should be a relatively easy adaptation of an APL/J interpreter, and it could find prompt use on various handheld digital devices.

The APL/J community would be well placed to produce for teachers and students the material needed for teaching and learning the use of the formulator. Properly done, and with conversion packages that bring formulator stacks into APL/J systems, these could lead to the much wider use of the programming systems favoured by the readers of Vector.

## Notes and references

```script began 18:49:22
caching off
debug mode off
cache time 3600 sec