MATH for the LAYMAN

Table of Contents

Preface

1: Numbers

2: Computer Use and Experimentation

3: Graphs and Visualization

4: Polynomials

5: Power Series

6: Slope and Derivative

7: Growth and Decay

8: Vibrations

9: Inverses and Equations

10: Language and Grammar

11: Proofs

12: Anagrams and Permutations

13: Logic and Sets

14: Properties of Functions

15: Linear Vector Functions

16: Polynomials and Number Systems

17: Algorithms

18: Anti-Derivative and Integral

19: Complex Numbers and the Exponential Family

20: Further Topics

Supplement

Appendix 1: Utilities

References

___________________________________________________________

MATH for the LAYMAN

Kenneth E. Iverson

Preface

In 1936, Lancelot Hogben published his still-popular Mathematics for the Million [1], stating his objective as follows:

The view which we shall explore is that mathematics is the language of size, shape and order and that it is an essential part of the equipment of an intelligent citizen to understand this language. If the rules of mathematics are the rules of grammar, there is no stupidity involved when we fail to see that a mathematical truth is obvious. The rules of ordinary grammar are not obvious. They have to be learned. They are not eternal truths. They are conveniences without whose aid truths about the sorts of things in the world cannot be communicated from one person to another.

Our objective is similar, but we now have new tools: the development of computer programming has provided languages with grammars that are simpler and more tractable than that of conventional mathematical notation. Moreover, the general availability of the computer makes possible convenient and accurate experimentation with mathematical ideas.

For example, the exclusive use of decimal notation in beginning mathematics entails the perplexing use of approximations such as 0.333333 and 0.857143 for the fractions one-third and six-sevenths, intermixed with exact values such as 0.046875 for the drill-bit-size three sixty-fourths. The present treatment also uses rational arithmetic, with exact representations such as 1r3 and 6r7 and 3r64, leading to the following computer production of an addition table for fractions:

   + table 1r1 1r2 1r3 1r4 1r5 1r6 1r7 1r8
+---+--------------------------------------------+
|   |  1  1r2   1r3   1r4   1r5   1r6   1r7   1r8|
+---+--------------------------------------------+
|  1|  2  3r2   4r3   5r4   6r5   7r6   8r7   9r8|
|1r2|3r2    1   5r6   3r4  7r10   2r3  9r14   5r8|
|1r3|4r3  5r6   2r3  7r12  8r15   1r2 10r21 11r24|
|1r4|5r4  3r4  7r12   1r2  9r20  5r12 11r28   3r8|
|1r5|6r5 7r10  8r15  9r20   2r5 11r30 12r35 13r40|
|1r6|7r6  2r3   1r2  5r12 11r30   1r3 13r42  7r24|
|1r7|8r7 9r14 10r21 11r28 12r35 13r42   2r7 15r56|
|1r8|9r8  5r8 11r24   3r8 13r40  7r24 15r56   1r4|
+---+--------------------------------------------+
Hogben continues with:

The fact is that modern mathematics does not borrow much from antiquity. To be sure, every useful development in mathematics rests on the historical foundation of some earlier branch. At the same time, every new branch liquidates the usefulness of clumsier tools which preceded it.

Although algebra, trigonometry, the use of graphs, the calculus all depend on the rules of Greek geometry, less than a dozen from the two hundred propositions of Euclid’s elements are essential to help us in understanding how to use them. The remainder are complicated ways of doing things we can do more simply when we know later branches of mathematics.

These facts make it possible to present to the layman a simple view of calculus as the study of the rate of change of a function, and to use it to provide insight into matters such as the sine and cosine functions (so useful in trigonometry and the study of mechanical and electrical vibrations), and into the exponential and its inverse the logarithm (so useful in growth and decay processes, and in matters such as the familiar musical scale).

The presentation consists largely of examples, organized in function tables and illustrated by graphs. The more analytical aspects of proofs and the grammar of mathematical notation are deferred to Chapters 11 and 10. These chapters can, however, be profitably consulted at almost any point.

An overview is provided by the Table of Contents which (when the text is used interactively on the computer) can be "clicked on with a mouse" to jump to any desired Section. Chapters 1-3 introduce Numbers, Computer use, and Graphs and visualization. Chapters 4-8 introduce many of the important tools of applied mathematics. The topics of these chapters are commonly considered to be too difficult for the layman, but are examples of Hogben's comment about "...doing things we can do more simply when we know later branches of mathematics." In particular, the treatment is greatly simplified by the use of a programming language that makes simple the use of lists (vectors) and tables (matrices).

A supplement at the end of the book contains sections that expand on the treatments in the main text. They are not essential to the main thread of development, but should be consulted on occasion (by clicking on S1A, S1B, etc.).

Although familiarity with Hogben’s book is not essential to a study of the present text, it is highly recommended to the layman, especially the brief prologue. We conclude with the continuation of the preceding quote:

For the mathematical technician these complications may provide a useful discipline. The person who wants to understand the place of mathematics in modern civilization is merely distracted and disheartened by them. What follows is for those who have been already disheartened and distracted, and have consequently forgotten what they may have learned already, or fail to see the meaning or usefulness of what they remember. So we shall begin at the very beginning.

1: Numbers

1A. The Counting (Natural) Numbers

1B. Lists and Names

1C. Iteration (Repetition)

1D. Inverse

1E. Addition and Subtraction (+ and -)

1F. Bonding

1G. Multiplication or Times (*)

1H. Power and Exponent (^)

1I. Monomials and Polynomials (p.)

1J. Division (%)

1K. Review and Supplement

1L. Notes

1A. The Counting (Natural) Numbers S1A.

The Counting numbers begin with 1 2 3 4 and go on forever, because every counting number has a successor that comes next after it. Thus:
   >: 1
2
   >: 2
3
   >: 3  
4
   >: 4
5
   >: >: 1
3
   >: >: >: >: 2
6

   >: 1 2 3 4 5 6
2 3 4 5 6 7

>: "performs an action" upon the number to which it is applied, and is therefore analogous to an "action word" or verb in English. In math, such a verb is also called a function (from Latin fungi, to perform or execute).

The number to which a verb applies may be called a noun. In math it is also called an argument, in the sense of a topic or subject ("You and love are still my argument" -- Shakespeare).

1B. Lists and Names S1B.

A collection of numbers may be written as a list, in the form 2 3 5 7 11, and verbs may be applied to such lists. For example:
   >: 2 3 5 7 11
3 4 6 8 12
   >: >: >: 2 3 5 7 11
5 6 8 10 14
A name may be assigned to a number or list by using the copula =:, and the name may then be used to refer to its referent. For example:
   primes=: 2 3 5 7 11
   >: primes
3 4 6 8 12
   b=: >: primes
   >: >: b
5 6 8 10 14
The main copulas used in English are "is" and "are". They may be used in reading mathematical expressions aloud, as in "primes are 2 3 5 7 11" for primes=:2 3 5 7 11, and "first is one" for first=:1.

Names may also be assigned to verbs. There appears to be no English word that corresponds to >: except, perhaps, the command "next" used to summon a successor from a queue. Thus:

   next=: >:
   next 5
6
   next next 5
7

1C. Iteration (Repetition) S1C.

The expression next ^: 3 produces a verb that is equivalent to applying the verb next for three times. Thus:
   primes
2 3 5 7 11
   next ^: 3 primes
5 6 8 10 14
   next next next primes
5 6 8 10 14
   for=: ^:
   
   next for 3 primes
5 6 8 10 14
   list=: 1 2 3 4
   next for list primes
3 4 6  8 12
4 5 7  9 13
5 6 8 10 14
6 7 9 11 15

1D. Inverse S1D.

The verb previous=: <: "undoes" the work of the verb next=: >:, and is said to be its inverse. Thus:
   previous=: <:

   primes
2 3 5 7 11
   previous primes
1 2 4 6 10
   next previous primes
2 3 5 7 11
   previous next primes
2 3 5 7 11
   previous 3
2
   previous 2
1
   previous 1
0
   previous 0
_1
   previous _1
_2

Because 1 is the first counting number, the zero (0) and the negative numbers (_1 and _2) shown above are not counting numbers. But they are integers, so called because they are unbroken or intact (in=not, tag=touch), as distinguished from the fractions (broken or fractured) referred to in the preface.

Adopting the seemingly-innocent notion of a verb that undoes the effect of next has, rather surprisingly, led us out of the original domain of counting numbers, and forced the adoption of a broader class, the integers, that includes the zero and negative numbers.

In adopting further inverses we will again experience the same need to broaden our domain, to include rational numbers, and imaginary numbers. Moreover, the surprising effect of inverse processes is not confined to mathematics.

Consider the effect of reversing a movie projector to run a film backward. If the film shows a locomotive moving forward along a track, the result of reversal is unremarkable. But if it concerns the dropping of an egg on the pavement, or a dive from a diving-board, the result is a startling illustration of the important distinction between reversible and irreversible processes.

Finally, the inverse of a function can be obtained by using iteration (for) with the right argument _1. Thus:

   next for _1 primes
1 2 4 6 10
   >: ^: _1 primes
1 2 4 6 10
   >: ^: _1
<:
   next for _3 _2 _1 0 1 2 3 primes
_1 0 2  4  8
 0 1 3  5  9
 1 2 4  6 10
 2 3 5  7 11
 3 4 6  8 12
 4 5 7  9 13
 5 6 8 10 14

1E. Addition and Subtraction (+ and -) S1E.

The effect of the verb next for 3 is to add 3 to its argument, and next for 3 primes is equivalent to the addition primes + 3 (using the familiar Saint George's cross to denote the verb). Thus:
   next for 3 primes
5 6 8 10 14
   primes + 3
5 6 8 10 14
   0 1 2 3 4 5 + 0 1 2 3 4 5
0 2 4 6 8 10
   + table 0 1 2 3 4 5
+-+------------+
| |0 1 2 3 4  5|
+-+------------+
|0|0 1 2 3 4  5|
|1|1 2 3 4 5  6|
|2|2 3 4 5 6  7|
|3|3 4 5 6 7  8|
|4|4 5 6 7 8  9|
|5|5 6 7 8 9 10|
+-+------------+
The last result is an addition table, which may be "read" as follows:
To find the result of 3 + 4, choose the result (7) found in the row headed by 3 and the column headed by 4.
The verb + table is only one example of a function table, and other functions may be used. For example:
   previous for 3 primes
_1 0 2 4 8
   primes - 3
_1 0 2 4 8

   - table 0 1 2 3 4 5
+-+----------------+
| |0  1  2  3  4  5|
+-+----------------+
|0|0 _1 _2 _3 _4 _5|
|1|1  0 _1 _2 _3 _4|
|2|2  1  0 _1 _2 _3|
|3|3  2  1  0 _1 _2|
|4|4  3  2  1  0 _1|
|5|5  4  3  2  1  0|
+-+----------------+
Exercises
  1. Read from the addition table the sums 2 + 5 and 5 + 2 and verify that they agree. Make similar comparisons of additions of numbers that are similarly interchanged or commuted.

  2. Because of the agreements noted in Exercise 1, addition is said to be commutative. Use the subtraction table to find whether subtraction is commutative.

1F. Bonding (&) S1F.

The verb + & 3 is equivalent to "add 3", that is, to next for 3. Thus:
   + & 3 primes
5 6 8 10 14
   primes + 3
5 6 8 10 14

   with=: &
   + with 3 primes
5 6 8 10 14
   next for 3 primes
5 6 8 10 14

   - with 3 primes
_1 0 2 4 8
   primes - 3
_1 0 2 4 8

   - with 3 + with 3 primes
2 3 5 7 11
   + with 2 primes
4 5 7 9 13
   + with 2 for 0 1 2 3 4 primes
 2  3  5  7 11
 4  5  7  9 13
 6  7  9 11 15
 8  9 11 13 17
10 11 13 15 19
Although the referent of primes is the list 2 3 5 7 11, it would not be correct to substitute the referent for the name in the foregoing expression, because the resulting 0 1 2 3 4 2 3 5 7 11 would be treated as a single list argument to for. Thus:
   + with 2 for 0 1 2 3 4 2 3 5 7 11
+&2^:0 1 2 3 4 2 3 5 7 11
The lists may, however, be separated by parentheses:
   + with 2 for 0 1 2 3 4 (2 3 5 7 11)
 2  3  5  7 11
 4  5  7  9 13
 6  7  9 11 15
 8  9 11 13 17
10 11 13 15 19

1G. Multiplication or Times (*) S1G.

Three times four (3 * 4) is said to be the addition of four copies (“plies”) of three. Thus:
   3 + 3 + 3 + 3
12
   3 * 4
12
   * table 0 1 2 3 4 5 6 7 8 9 10
+--+--------------------------------+
|  |0  1  2  3  4  5  6  7  8  9  10|
+--+--------------------------------+
| 0|0  0  0  0  0  0  0  0  0  0   0|
| 1|0  1  2  3  4  5  6  7  8  9  10|
| 2|0  2  4  6  8 10 12 14 16 18  20|
| 3|0  3  6  9 12 15 18 21 24 27  30|
| 4|0  4  8 12 16 20 24 28 32 36  40|
| 5|0  5 10 15 20 25 30 35 40 45  50|
| 6|0  6 12 18 24 30 36 42 48 54  60|
| 7|0  7 14 21 28 35 42 49 56 63  70|
| 8|0  8 16 24 32 40 48 56 64 72  80|
| 9|0  9 18 27 36 45 54 63 72 81  90|
|10|0 10 20 30 40 50 60 70 80 90 100|
+--+--------------------------------+
Exercises
  1. Study the multiplication table, and comment on its properties (such as commutativity).

  2. The numbers in column 5 are multiples of 5, that is, they result from multiplying by 5. Verify that they progress by "counting by fives", and check for similar properties in other columns and rows.

  3. Comment on any patterns you find in the rows, columns, or diagonals of other function tables.

  4. Make the table * table 2 3 4 5 6 6 7 8 9 10 and make a list of the counting numbers beginning with 2 (and up to perhaps 19) that do not occur in it. These numbers are called primes.

1H. Power and Exponent (^) S1H.

Just as repeated application of addition is equivalent to another important function (multplication, or *), so repeated multiplication is equivalent to power, or ^ . Thus, 3 ^ 4 is equivalent to 3 * 3 * 3 * 3. The right argument (in this case 4) is often called the exponent, and the expression 3 ^ 4 is read as “three power four” or “three to the power four”. For example:
   3 ^ 4
81
   3*3*3*3
81
   0 1 2 3 4 5 ^2
0 1 4 9 16 25

   ^ table 0 1 2 3 4 5
+-+-------------------+
| |0 1  2   3   4    5|
+-+-------------------+
|0|1 0  0   0   0    0|
|1|1 1  1   1   1    1|
|2|1 2  4   8  16   32|
|3|1 3  9  27  81  243|
|4|1 4 16  64 256 1024|
|5|1 5 25 125 625 3125|
+-+-------------------+

1I. Monomials and Polynomials (p.) S1I.

An expression such as 5*4^3 is called a monomial (one name) with the coefficient 5, the argument 4, and the exponent 3; a sum of monomials is called a polynomial (many names). For example:
   5 * 4 ^ 3
320

   (5*4^3) + (_2*4^4) + (1*4^1)
_288

A polynomial in which the exponents in the successive monomials are successive integers beginning with zero, is said to be in standard form, and may be expressed using the polynomial function p., with the list of coefficients as the left argument. For example:

   x=:  4
   (2*x^0) + (3*x^1) + (4*x^2)
78
   2 3 4 p. x
78
Exercises

  1. Evaluate the following expressions, and comment on the results:
       a=: 0 1 2 3 4 5
       1 2 1 p. a
       (a+1) ^ 2
       1 3 3 1 p. a
       (a+1) ^ 3
       c4=: 0 1 3 3 1 + 1 3 3 1 0
       c4 p. a
       (a+1) ^ 4

1J. Division (%) S1J.

Division (to be denoted by %) "undoes" the work of multiplication. For example:
   a=: 0 1 2 3 4 5 6
   b=: a * 2
   b
0 2 4 6 8 10 12
   b % 2
0 1 2 3 4 5 6
   b % 3
0 0.666667 1.33333 2 2.66667 3.33333 4
Just as the inverse of addition introduced new numbers outside the domain of the counting numbers, so some of the results of this inverse function lie outside of the domain of integers. These non-integral results (such as 0.666667) are "decimal approximations to" a new class of numbers, called fractions or rationals.

Just as we introduced a way to represent negative numbers, so we introduce a representation for rationals: 2r3 for the fraction two-thirds, 4r3 for the fraction four-thirds, etc. Thus:

   1r3+1r3
2r3
   a=: 0 1r2 1r3 1r4 1r5 1r6
   
   a+a
0 1 2r3 1r2 2r5 1r3
   a-a
0 0 0 0 0 0
   a * a
0 1r4 1r9 1r16 1r25 1r36

   + table a
+---+------------------------------+
|   |  0  1r2  1r3  1r4   1r5   1r6|
+---+------------------------------+
|  0|  0  1r2  1r3  1r4   1r5   1r6|
|1r2|1r2    1  5r6  3r4  7r10   2r3|
|1r3|1r3  5r6  2r3 7r12  8r15   1r2|
|1r4|1r4  3r4 7r12  1r2  9r20  5r12|
|1r5|1r5 7r10 8r15 9r20   2r5 11r30|
|1r6|1r6  2r3  1r2 5r12 11r30   1r3|
+---+------------------------------+

   - table a
+---+--------------------------------+
|   |  0   1r2   1r3   1r4   1r5  1r6|
+---+--------------------------------+
|  0|  0  _1r2  _1r3  _1r4  _1r5 _1r6|
|1r2|1r2     0   1r6   1r4  3r10  1r3|
|1r3|1r3  _1r6     0  1r12  2r15  1r6|
|1r4|1r4  _1r4 _1r12     0  1r20 1r12|
|1r5|1r5 _3r10 _2r15 _1r20     0 1r30|
|1r6|1r6  _1r3  _1r6 _1r12 _1r30    0|
+---+--------------------------------+

   * table a
+---+--------------------------+
|   |0  1r2  1r3  1r4  1r5  1r6|
+---+--------------------------+
|  0|0    0    0    0    0    0|
|1r2|0  1r4  1r6  1r8 1r10 1r12|
|1r3|0  1r6  1r9 1r12 1r15 1r18|
|1r4|0  1r8 1r12 1r16 1r20 1r24|
|1r5|0 1r10 1r15 1r20 1r25 1r30|
|1r6|0 1r12 1r18 1r24 1r30 1r36|
+---+--------------------------+

   % table a
+---+---------------------+
|   |0 1r2 1r3 1r4 1r5 1r6|
+---+---------------------+
|  0|0   0   0   0   0   0|
|1r2|_   1 3r2   2 5r2   3|
|1r3|_ 2r3   1 4r3 5r3   2|
|1r4|_ 1r2 3r4   1 5r4 3r2|
|1r5|_ 2r5 3r5 4r5   1 6r5|
|1r6|_ 1r3 1r2 2r3 5r6   1|
+---+---------------------+
Exercises
  1. Study the foregoing tables, and comment on their properties. (See the Exercises in Section 1G.)

  2. Comment on the _ that occurs in the first column of the division table (it denotes infinity).

  3. Study the multiplication table, and try to formulate rules for the multiplication of rationals.

1K. Review and Supplement S1K.

Using notation provided by a programming language (that will allow us to experiment with our math on a computer), we have introduced:
  1. The counting numbers 1 2 3 4 etc.

  2. The use of lists and of names that are assigned referents by a copula.

  3. The iteration operator for=: ^: that applies a function for a specified number of times.

  4. The function addition.

  5. Its inverse (subtraction).

  6. The class of integers that includes zero, and the negative numbers _1 _2 _3 _4 etc. introduced by subtraction.

  7. The multiplication that is given by iterated addition.

  8. The division that is inverse to multiplication.

  9. The fractions or rationals that are introduced by division.

  10. The power function and the polynomials based upon it.
Some of the assigned names (such as the for assigned by the expression for=: ^:) are "utilities" that will be utilized throughout the text, and are collected for easy reference in Appendix 1.

The pace of this text is brisk, moving on quickly to further topics as soon as the essential foundations for them are established. For example, although the Polynomials of Chapter 4 could provide a rich subject in itself, we pass on after a brief three pages to the Power Series of Chaper 5, and the Slope and Derivative of Chapter 6.

This gives a quick exposure to significant, and sometimes surprising, consequences of otherwise dull foundations. On the other hand, the reader may eventually (or immediately) want further treatments of the successive foundations: these are provided in a separate part of the book called Supplement.

In a printed text, the need to move between a given section and the corresponding supplemental section in a different part of the book might prove onerous. However, in reading the text from a computer (through a Browser), this switching back and forth is made by a click of a mouse.

For example, click on the S1K that appears to the right of the heading for this section to read the further discussion in the supplemental section S1K, and click on its heading to return.

The Find facility can be used as an index to find the occurrences of words in the text; invoke it by pressing F while holding down the control key, or select it from the Search menu.

1L. Notes S1L.

On page 75 Hogben says:

It may therefore be soothing for many to whom mathematical expressions evoke a malaise comparable to being seasick, if they can learn to think of mathematics less as an exploit in reasoning than as an exercise in translating an unfamiliar script like Braille or the Morse code.

In this chapter we shall therefore abandon the historical approach and deal mainly with two topics: for what sort of communication do we use this highly space-saving – now international – written language, and on what sort of signs do we rely. To emphasize that the aim of this chapter is to accustom the reader to approach mathematical rules as Exercises in economical translation, every rule in the sign language of mathematics will have an arithmetical illustration …

He continues with:

In contradistinction to common speech which deals largely with the quality of things, mathematics deals only with matters of size, order, and shape. … First let us consider what different sorts of signs go to the making of a mathematical statement. We may classify these as:

  1. punctuation;
  2. models;
  3. labels (e.g. 5 or x) for enumeration, measurement, and position in a sequence;
  4. signs for relations;
  5. signs for operations.

Conventional mathematical notation uses three pairs of symbols for punctuation: ( ) and [ ] and { }. We will use only the pair ( ) for this purpose, and will use the others for operations: { for indexing (selection), {. and }. for take and drop of a first item, and {: and }: for take and drop of a last item.

Hogben offers the following suggestions for study:

Although care has been taken to see that all the logical, or, as we ought to say, the grammatical rules are put in a continuous sequence, you must not expect that you will necessarily follow every step in the argument the first time you read it. An eminent Scottish mathematician gave a very sound piece of advice for lack of which many people have been discouraged unnecessarily. “Every mathematical book that is worth anything”, said Chrystal, “must be read backwards and forwards …”

---------------------

…Always have a pen and paper, preferably squared paper, in hand …. when you read the text for serious study, and work out all the numerical examples as you read …. What you get out of the book depends on your co-operation in the business of learning.

To this we may add the advice to use the computer in the manner introduced in the next chapter, and illustrated throughout the entire text. In particular, do not hesitate to do any computer experiments that may occur to you – the worst that can happen is the appearance of an error message of some kind, after which you may continue without any special action.

2: Computer Use and Experimentation

2A. Introduction

2B. Number of places

2C. Displays

2D. Integer Lists

2E. Vocabulary

2F. Functions over lists

2G. Notes

2A. Introduction S2A.

A computer can be programmed to “interpret” or “execute” sentences expressed in a variety of notations or programming languages; commonly used languages include Cobol, Fortran, APL, C, and J. The treatment of numbers in Chapter 1 is all expressed in J, a system that can be obtained from Website www.jsoftware.com .

A computer-executed language such as J not only permits one to do extensive calculations quickly and accurately, it may also permit precise experimentation with mathematical ideas. In particular, J provides computation both in the rational arithmetic used in Chapter 1, and in the more familiar decimal notation.

For example, a list of rationals such as r=: 1r5 2r5 3r5 4r5 5r5 6r5 and a list of integers a=: 5 * r derived from it will produce results expressed as rationals when functions such as addition, multiplication, and division are applied to them. Thus:

   r=: 1r5 2r5 3r5 4r5 1 6r5
   a=: 5 * r
   % table a
+-+---------------------+
| |1   2   3   4   5   6|
+-+---------------------+
|1|1 1r2 1r3 1r4 1r5 1r6|
|2|2   1 2r3 1r2 2r5 1r3|
|3|3 3r2   1 3r4 3r5 1r2|
|4|4   2 4r3   1 4r5 2r3|
|5|5 5r2 5r3 5r4   1 5r6|
|6|6   3   2 3r2 6r5   1|
+-+---------------------+

   % table r
+---+-----------------------+
|   |1r5 2r5 3r5 4r5   1 6r5|
+---+-----------------------+
|1r5|  1 1r2 1r3 1r4 1r5 1r6|
|2r5|  2   1 2r3 1r2 2r5 1r3|
|3r5|  3 3r2   1 3r4 3r5 1r2|
|4r5|  4   2 4r3   1 4r5 2r3|
|  1|  5 5r2 5r3 5r4   1 5r6|
|6r5|  6   3   2 3r2 6r5   1|
+---+-----------------------+

However, the list c=: 1 2 3 4 5 6, which is identical to a except that it is not defined as a rational, yields decimal approximations under division. Thus:

   c=: 1 2 3 4 5 6
   % table c
+-+--------------------------------+
| |1   2        3    4   5        6|
+-+--------------------------------+
|1|1 0.5 0.333333 0.25 0.2 0.166667|
|2|2   1 0.666667  0.5 0.4 0.333333|
|3|3 1.5        1 0.75 0.6      0.5|
|4|4   2  1.33333    1 0.8 0.666667|
|5|5 2.5  1.66667 1.25   1 0.833333|
|6|6   3        2  1.5 1.2        1|
+-+--------------------------------+

It should be noted that the inclusion of even one rational in a list makes it behave as a rational.

The function x: applied to an argument causes its result to be treated as a rational when other functions are applied to it. Moreover, its inverse causes functions applied to its results to treat it in decimal form. Thus:

   rat=: x:
   dec=: rat^:_1
     
   d=: rat c
   d
1 2 3 4 5 6
   % table d
+-+---------------------+
| |1   2   3   4   5   6|
+-+---------------------+
|1|1 1r2 1r3 1r4 1r5 1r6|
|2|2   1 2r3 1r2 2r5 1r3|
|3|3 3r2   1 3r4 3r5 1r2|
|4|4   2 4r3   1 4r5 2r3|
|5|5 5r2 5r3 5r4   1 5r6|
|6|6   3   2 3r2 6r5   1|
+-+---------------------+
   e=: dec d
   e
1 2 3 4 5 6
   % table e
+-+--------------------------------+
| |1   2        3    4   5        6|
+-+--------------------------------+
|1|1 0.5 0.333333 0.25 0.2 0.166667|
|2|2   1 0.666667  0.5 0.4 0.333333|
|3|3 1.5        1 0.75 0.6      0.5|
|4|4   2  1.33333    1 0.8 0.666667|
|5|5 2.5  1.66667 1.25   1 0.833333|
|6|6   3        2  1.5 1.2        1|
+-+--------------------------------+
Exercises
  1. To gain familiarity with the use of the computer, enter some of the expressions from Chapter 1, and compare the results with those shown in the text.

2B. Number of places S2B.

The precision of the decimal approximations in the table % table c is limited to six digits after the decimal point. This is a matter of convenience in display -- the results are actually computed to about eighteen decimal digits, of which only the first few are shown.

The following function may be defined and used to display any number of digits:

   set=: 9!:11  
   set 12
   2 % 3
0.666666666667
   dec 2r3
0.666666666667
   set 6

2C. Displays S2C.

Tables and other results may also be displayed for convenient comparison, using the comma-dot to place them side-by-side, and the comma to place one table below another. For example:
   (+ table r),.(- table r)
+---+-------------------------+---+----------------------------+
|   |1r5 2r5 3r5 4r5    1  6r5|   |1r5  2r5  3r5  4r5    1  6r5|
+---+-------------------------+---+----------------------------+
|1r5|2r5 3r5 4r5   1  6r5  7r5|1r5|  0 _1r5 _2r5 _3r5 _4r5   _1|
|2r5|3r5 4r5   1 6r5  7r5  8r5|2r5|1r5    0 _1r5 _2r5 _3r5 _4r5|
|3r5|4r5   1 6r5 7r5  8r5  9r5|3r5|2r5  1r5    0 _1r5 _2r5 _3r5|
|4r5|  1 6r5 7r5 8r5  9r5    2|4r5|3r5  2r5  1r5    0 _1r5 _2r5|
|  1|6r5 7r5 8r5 9r5    2 11r5|  1|4r5  3r5  2r5  1r5    0 _1r5|
|6r5|7r5 8r5 9r5   2 11r5 12r5|6r5|  1  4r5  3r5  2r5  1r5    0|
+---+-------------------------+---+----------------------------+

  (* table a),(* table r)
+---+--------------------------------+
|   |        1  2  3  4  5  6        |
+---+--------------------------------+
| 1 |        1  2  3  4  5  6        |
| 2 |        2  4  6  8 10 12        |
| 3 |        3  6  9 12 15 18        |
| 4 |        4  8 12 16 20 24        |
| 5 |        5 10 15 20 25 30        |
| 6 |        6 12 18 24 30 36        |
+---+--------------------------------+
|   | 1r5   2r5   3r5   4r5   1   6r5|
+---+--------------------------------+
|1r5|1r25  2r25  3r25  4r25 1r5  6r25|
|2r5|2r25  4r25  6r25  8r25 2r5 12r25|
|3r5|3r25  6r25  9r25 12r25 3r5 18r25|
|4r5|4r25  8r25 12r25 16r25 4r5 24r25|
|  1| 1r5   2r5   3r5   4r5   1   6r5|
|6r5|6r25 12r25 18r25 24r25 6r5 36r25|
+---+--------------------------------+
Function tables may also be produced without their bordering arguments by using the operator /, and other functions may be applied to such tables. For example:
    a %/ a
1 1r2 1r3 1r4 1r5 1r6
2   1 2r3 1r2 2r5 1r3
3 3r2   1 3r4 3r5 1r2
4   2 4r3   1 4r5 2r3
5 5r2 5r3 5r4   1 5r6
6   3   2 3r2 6r5   1

   (a %/ a)*(a */ a)
 1  1  1  1  1  1
 4  4  4  4  4  4
 9  9  9  9  9  9
16 16 16 16 16 16
25 25 25 25 25 25
36 36 36 36 36 36

2D. Integer Lists S2D.

i.5 produces a list of the first five non-negative integers, and i:5 produces a symmetric list from _5 to 5. Both are convenient for exploring tables:
      (* table i.5),.(* table i:5)
+-+-----------+--+---------------------------------------+
| |0 1 2  3  4|  | _5  _4  _3  _2 _1 0  1   2   3   4   5|
+-+-----------+--+---------------------------------------+
| |           |_5| 25  20  15  10  5 0 _5 _10 _15 _20 _25|
| |           |_4| 20  16  12   8  4 0 _4  _8 _12 _16 _20|
| |           |_3| 15  12   9   6  3 0 _3  _6  _9 _12 _15|
|0|0 0 0  0  0|_2| 10   8   6   4  2 0 _2  _4  _6  _8 _10|
|1|0 1 2  3  4|_1|  5   4   3   2  1 0 _1  _2  _3  _4  _5|
|2|0 2 4  6  8| 0|  0   0   0   0  0 0  0   0   0   0   0|
|3|0 3 6  9 12| 1| _5  _4  _3  _2 _1 0  1   2   3   4   5|
|4|0 4 8 12 16| 2|_10  _8  _6  _4 _2 0  2   4   6   8  10|
| |           | 3|_15 _12  _9  _6 _3 0  3   6   9  12  15|
| |           | 4|_20 _16 _12  _8 _4 0  4   8  12  16  20|
| |           | 5|_25 _20 _15 _10 _5 0  5  10  15  20  25|
+-+-----------+--+---------------------------------------+
Exercises

  1. Examine the second multiplication table above, and formulate a rule for the sign of a product in terms of the signs of its factors.

  2. Examine the rows and columns, and give reasons for the alternation of signs between quadrants.
The signum or sign function denoted by * gives _1 for a negative argument, 0 for a zero argument, and 1 for a positive argument. When applied on (that is, to the result of) multiplication it yields a table that shows the pattern of the signs in the multiplication table more clearly. Thus:
   sign=: *
     on=: @
	 
   (sign on *) table i:5
+--+-------------------------------+
|  |_5 _4 _3 _2 _1 0  1  2  3  4  5|
+--+-------------------------------+
|_5| 1  1  1  1  1 0 _1 _1 _1 _1 _1|
|_4| 1  1  1  1  1 0 _1 _1 _1 _1 _1|
|_3| 1  1  1  1  1 0 _1 _1 _1 _1 _1|
|_2| 1  1  1  1  1 0 _1 _1 _1 _1 _1|
|_1| 1  1  1  1  1 0 _1 _1 _1 _1 _1|
| 0| 0  0  0  0  0 0  0  0  0  0  0|
| 1|_1 _1 _1 _1 _1 0  1  1  1  1  1|
| 2|_1 _1 _1 _1 _1 0  1  1  1  1  1|
| 3|_1 _1 _1 _1 _1 0  1  1  1  1  1|
| 4|_1 _1 _1 _1 _1 0  1  1  1  1  1|
| 5|_1 _1 _1 _1 _1 0  1  1  1  1  1|
+--+-------------------------------+   
The pattern of signs in the multiplication table may be made more understandable by considering the behaviour of individual rows and columns: each proceeds by "counting by" the number at its head. For example, the row headed by 3 begins with _15, and proceeds by steps of three through _12 and _9 to 15. At some point it passes through the column of zeros, and the result must therefore change sign. Similar remarks apply to "counting by negative numbers", and to columns.

2E. Vocabulary S2E.

The complete J vocabulary can be displayed by pressing the key labelled F1, can then be printed as indicated, and can be closed by pressing the Escape key (labelled Esc). With the vocabulary displayed, the complete definition of any of its items may be displayed (and perhaps printed) by clicking the mouse on the desired item.

It may be interesting to explore the behaviour of various functions by producing their tables, either before or after studying their definitions. Moreover, it may be helpful to first assign more familiar names. For example:

   gcd=: +.
   lcm=: *.
   (gcd table ,. lcm table) a
+-+-----------+-+----------------+
| |1 2 3 4 5 6| |1  2  3  4  5  6|
+-+-----------+-+----------------+
|1|1 1 1 1 1 1|1|1  2  3  4  5  6|
|2|1 2 1 2 1 2|2|2  2  6  4 10  6|
|3|1 1 3 1 1 3|3|3  6  3 12 15  6|
|4|1 2 1 4 1 2|4|4  4 12  4 20 12|
|5|1 1 1 1 5 1|5|5 10 15 20  5 30|
|6|1 2 3 2 1 6|6|6  6  6 12 30  6|
+-+-----------+-+----------------+
Composite functions can also be tabled. For example:
   ((lcm */ gcd) table ,. (* table)) a
+-+----------------+-+----------------+
| |1  2  3  4  5  6| |1  2  3  4  5  6|
+-+----------------+-+----------------+
|1|1  2  3  4  5  6|1|1  2  3  4  5  6|
|2|2  4  6  8 10 12|2|2  4  6  8 10 12|
|3|3  6  9 12 15 18|3|3  6  9 12 15 18|
|4|4  8 12 16 20 24|4|4  8 12 16 20 24|
|5|5 10 15 20 25 30|5|5 10 15 20 25 30|
|6|6 12 18 24 30 36|6|6 12 18 24 30 36|
+-+----------------+-+----------------+

Exercises

  1. Choose other functions from the Vocabulary for experiments such as:
       < table a
       ((< table ,. > table),(<: table,.= table)) a

  2. Make and study tables for the greatest common divisor (gcd=: +.) and the least common multiple (lcm=: *.).

  3. Exercise 3 of Section 1J asked to formulate rules for multiplying rational numbers. Re- examine the matter using the gcd function and the function nd=: 2&x: that gives the numerator and denominator (as a two-element list) of a rational number.

  4. Extend the discussion of the preceding exercise to the division of rationals.

  5. Use i. and i: to make tables of the comparison functions < and > and = .

  6. Make tables for <. (minimum) and >. (maximum).

  7. Make the table ! table i.5, and comment on the results.

The expression 3!5 gives the number of distinct collections of three items that can be chosen from a collection of five distinct items. For example, here are the ways of choosing three at a time from the first five letters of the alphabet:

   ABC
   ABD
   ABE
   ACD
   ACE
   ADE
   BCD
   BCE
   BDE
   CDE

The function ! might therefore be called outof but, for reasons that will appear later, we will call it the binomial coefficient function, and abbreviate it as bc. If the zeros in the table produced in Exercise 7 are ignored, a triangle remains. This triangle (or some orientation of it) is (wrongly, according to Hogben, p194) called Pascal’s triangle.

Functions for other useful lists are easily defined:

   even=:  2:*i.
    odd=:  1:+2:*i.
    pow=:  2:^i.
     i1=:  1:+i.
     i2=:  2:+i.
   (even,.odd,.pow,.i1,.i2) 6
 0  1  1 1 2
 2  3  2 2 3
 4  5  4 3 4
 6  7  8 4 5
 8  9 16 5 6
10 11 32 6 7

The expressions 2^3 and 2^2 are defined by 2*2*2 and 2*2, respectively, but it is not clear what this implies for 2^1 (multiplication with one factor?) or for 2^0 and 2^_1. Function tables give clues to the pattern to be expected:

   2 3 ^ table 2 3 4 5
+-+-----------+
| |2  3  4   5|
+-+-----------+
|2|4  8 16  32|
|3|9 27 81 243|
+-+-----------+

The patterns progress to the right by multiplying by the argument (2 or 3); conversely they progress to the left by dividing by the argument, giving the following results for the exponents 1 and 0, and for negative exponents:

   2 3 ^ table 0 1 2 3 4 5
+-+---------------+
| |0 1 2  3  4   5|
+-+---------------+
|2|1 2 4  8 16  32|
|3|1 3 9 27 81 243|
+-+---------------+

   2 3 ^ table i:5r1
+-+---------------------------------------+
| |   _5   _4   _3  _2  _1 0 1 2  3  4   5|
+-+---------------------------------------+
|2| 1r32 1r16  1r8 1r4 1r2 1 2 4  8 16  32|
|3|1r243 1r81 1r27 1r9 1r3 1 3 9 27 81 243|
+-+---------------------------------------+

   ^ table i:5r1
+--+-----------------------------------------------------+
|  |     _5    _4     _3   _2   _1 0  1  2    3   4     5|
+--+-----------------------------------------------------+
|_5|_1r3125 1r625 _1r125 1r25 _1r5 1 _5 25 _125 625 _3125|
|_4|_1r1024 1r256  _1r64 1r16 _1r4 1 _4 16  _64 256 _1024|
|_3| _1r243  1r81  _1r27  1r9 _1r3 1 _3  9  _27  81  _243|
|_2|  _1r32  1r16   _1r8  1r4 _1r2 1 _2  4   _8  16   _32|
|_1|     _1     1     _1    1   _1 1 _1  1   _1   1    _1|
| 0|      _     _      _    _    _ 1  0  0    0   0     0|
| 1|      1     1      1    1    1 1  1  1    1   1     1|
| 2|   1r32  1r16    1r8  1r4  1r2 1  2  4    8  16    32|
| 3|  1r243  1r81   1r27  1r9  1r3 1  3  9   27  81   243|
| 4| 1r1024 1r256   1r64 1r16  1r4 1  4 16   64 256  1024|
| 5| 1r3125 1r625  1r125 1r25  1r5 1  5 25  125 625  3125|
+--+-----------------------------------------------------+

2F. Functions over lists S2F.

The expression 1+4+1+4+2 is said to apply addition over the list 1 4 1 4 2. This sum may also be expressed by applying the over adverb / to the function +, as in +/1 4 1 4 2. It may be applied to other functions similarly:
   a=: 1 4 1 4 2
   +/a
12
   */a
32
   >./a
4
   +./a
1
   *./a
4
   n=: 6
   b=: i1 n
   b
1 2 3 4 5 6
   +/b
21
   */b
720
The / used in the expressions +/ and */ is called an adverb because it applies to a verb to produce a related verb. In math, an adverb is also called an operator, a rather non-committal term adopted by the mathematician Oliver Heaviside about a century ago.

The sum +/ and the list i. can be used to clarify (or at least re-express) the polynomial function introduced in Section 1I. Thus:

   x=: 4
   c=: 2 3 4
   c p. x
78
   x^0 1 2
1 4 16
   c*x^0 1 2
2 12 64
   +/c*x^0 1 2
78
   +/c*x^i.3
78

In the final expression above it was essential that the argument 3 equalled the number of items in the list of coefficients. This can be expressed for any coefficient list by using the number function # as follows:

   #c
3
   i.#c
0 1 2
   +/c*x^i.#c
78
   d=: 1 4 6 4 1
   +/d*x^i.#d
625
   (d p. x),(x+1)^4
625 625

2G. Notes S2G.

These two chapters have provided numerous examples of the evaluation of a variety of functions, but have not provided proofs or demonstrations of the properties of these functions or of relations among them.

On the other hand, the use of lists and tables has provided organized presentations of these examples that make it easy to recognize properties -- properties such as the commutativity of the functions plus, times, maximum, and greatest common divisor in the symmetry of their tables, as well as certain “skew-symmetries” evident in the tables for subtraction, division, and less-than.

Careful study of function tables can provide other insights such as the “counting by a constant” that occurs in rows and columns of certain functions, leading, in particular, (in Section 2D) to an informal proof or demonstration of the necessity for the familiar behaviour of the products of signed numbers -- the product of numbers of opposite signs is negative, and the product of two of the same sign is positive.

Conclusions about functions (such as the relation of prime numbers to the multiplication table, and rules for the multiplication of rational numbers) have been left to Exercises, as in those for Sections 1G and 1J. It is important to attempt these Exercises -- to repeat Hogben’s advice: “What you get out of the book depends on your co-operation in the business of learning”.

Nevertheless, we will devote some attention to deriving certain relations, and will devote a separate chapter (11) to the treatment of proofs. Similarly in the matter of language (whose importance is so strongly stated by Hogben in the paragraph shown in our preface), we have introduced the necessary notation in context with no general discussion of the grammar involved, and will defer such matters to a separate chapter (10).

However, these cited chapters are relatively self-contained, and can be consulted at any point. But first we will introduce graphing as a further tool for making certain mathematical relations evident. Concerning graphs, Hogben has this to say (p 86):

A third kind of pictorial language used in mathematics has its origin in the construction of star maps and later of earth maps in the last two centuries before the beginning of the Christian era.

Such is co-ordinate geometry for which the slang word is graphs. It did not come into its own before the century of Newton, whereafter it led to many discoveries.

Unlike Euclid’s geometry, it can bring the measurement of time into the picture. For instance, it exposes (Fig. 1) why and when Achilles (pp 12-13) caught up with (and passed) the tortoise.

3: Graphs and Visualization

3A. Plotting

3B. Local behaviour and area

3C. Graphs versus function tables

3D. Notes

3A. Plotting S3A.

A table of the function “twenty-five minus the square”, or “twenty-five with minus on the square” for each item of the argument x=: i:5 can be prepared as follows:

   f=: 25 with - on *:
   x=: i:5
   x,:f x
_5 _4 _3 _2 _1  0  1  2  3 4 5
 0  9 16 21 24 25 24 21 16 9 0
Study of such a function table can reveal much about the behaviour of the function: for example, from 0 at the argument _5, it grows at an ever-decreasing rate to a high point at 0 25, and then declines at an ever-increasing rate to 5 0.

However, the characteristics of the function can be seen more easily in a graph of the function, produced by plotting each column of the table as follows: starting at an arbitrary point on a sheet of squared paper measure a distance x to the right (or left, if negative), and a distance f x upward (or downward, if negative), and mark the resulting point. Then join adjacent points by "lines", and points to arguments by "sticks".

Graphs can be produced quickly and accurately by the computer as follows:

   load 'plot'
   PLOT=: 'line,stick' with plot
   PLOT x;f x
A plot can be removed from the screen (to permit further computation) by pressing the key labelled Esc. However, anyone unfamiliar with such graphs should perhaps make a few by hand, using simple functions such as the cube (f=: ^ with 3), negation (f=: -), and the identity (f=: ]).

Plots of polynomial functions may show further interesting characteristics. For example, study the plot of the following function, use x,:fs x or x,.fs x to make its table, and compare your observations with the remarks given below:

   fs=: 0 1 0 _1r6 0 1r120 0 _1r5040 with p.
   x=: 1r3*i:10
   PLOT x;fs x

Remarks: fs appears to be an oscillating function that begins at about (-3+1r7),0; drops at a decreasing rate to a low of _1; rises through 0 0 to a high of 1; and again drops to about (3+1r7),0.

The result of PLOT x;f x is said to be a plot of f x “against” or “versus” the argument x. A function can also be plotted against another function, as illustrated in the following exercise.

Exercises

  1. Execute the following sentences, and comment on the results:
       fc=: 1 0 _1r2 0 1r24 0 _1r720 0 1r40320 with p.
       set 5
       x,.fc x
       
       PLOT x;fc x
       
       (fc x),.(fs x)
       
       PLOT (fc x);(fs x)

To anyone familiar with the functions sine and cosine of trigonometry, it may be evident that the functions fs and fc are approximations of them.

Moreover, the cosine and sine of a given angle are sometimes defined as the coordinates of a point on the unit circle of radius 1, located at the given angle (that is, the arc length along the circumference). It should therefore come as no surprise that the plot of fs against fc in the preceding exercise produced an approximate circle.

The expression d,:e produces a two-rowed table from the lists d and e, and expressions of the form c,d,:e form multi-rowed tables from further lists. Moreover, PLOT x;c,d,:e plots each of the lists against x in a single graph, providing visual comparison of the functions represented by the lists.

Exercises

  1. PLOT x;(fs x),:fc x)

  2. PLOT x;(fs x),:fc x-3r2)

3B. Local behaviour and area S3B.

In addition to providing an overall view of a function, its graph shows the local behaviour, the slopes of the individual segments reflecting its local rates of growth and decay.

Moreover, the graph provides a direct view of the area under it, a result of considerable significance.

This will be illustrated by a plot of a semi-circle. The function cir=: 0 with o. gives the square root of one minus the square of its argument. Its plot for the argument a=: 1r5*i:5 is therefore a rough approximation to a semi-circle with a radius of one unit. Thus:

   cir=: 0 with o.
   a=: 1r5 * i:5
   a
_1 _4r5 _3r5 _2r5 _1r5 0 1r5 2r5 3r5 4r5 1
   PLOT a;cir a

The function sum=: +/ sums a list, and sum cir a therefore sums the altitudes of the graph of the semi-circle, thus giving an approximation to its area (except that the sum must be multiplied by 1r5, the common width of the trapezoids that form the area). Thus:

   sum=: +/
   1r5 * sum cir a
1.51852
   2*1r5 * sum cir a
3.03705

The last result is the approximate area of the complete circle, and is therefore an approximation to the constant pi. Better approximations are provided by a larger number of points:

   b=: 1r1000 * i:1000
   2 * +/1r1000 * cir b
3.14156

3C. Graphs versus function tables S3C.

Insights provided by the graph of the function cir that are not provided so directly by its function table are based upon the pairwise views of adjacent points; the slopes of the line segments between them reflect the rate of change of the function, and the trapezoids defined by them provide a basis for the area.

Tables of functions that apply pairwise to their arguments can, however, provide similar insights. Moreover, they can provide other information (such as the rate of change of the rate of change) not readily grasped from a graph. To this end we will define a pairwise operator pw, a sum function, a commuted difference function, and an average or mean function. Thus:

   pw=: 1 : '2 with (u.\)'
   sum=: +/
   dif=: -~/
   mean=: sum % #
   y=:  cir a
   y
0 0.6 0.8 0.917 0.98 1 0.98 0.917 0.8 0.6 0
   mean y
0.69
   mean pw y NB. Average heights of the trapezoids
0.3 0.7 0.86 0.95 0.99 0.99 0.95 0.86 0.7 0.3
   dif pw y
0.6 0.2 0.12 0.063 0.02 _0.02 _0.063 _0.12 _0.2 _0.6
We will further illustrate the pairwise operator on a function for the Fibonacci numbers, using a definition discussed under “generating functions” in [2]:
   fib=: (0 1 with p. % 1 _1 _1 with p.)t.
   x=:  1 2 3 4 5 6 7 8 9 10 11 12 13   
   fib x
1 1 2 3 5 8 13 21 34 55 89 144 233

   sum pw fib x
2 3 5 8 13 21 34 55 89 144 233 377

   sum pw sum pw fib x
5 8 13 21 34 55 89 144 233 377 610

   dif pw fib x
0 1 1 2 3 5 8 13 21 34 55 89

   gm=: %/pw fib x  NB. Pairwise ratios
   set 4
   gm NB. Appproximations to golden mean
1 0.5 0.6667 0.6 0.625 0.6154 0.619 0.6176 0.6182 0.618 0.6181 0.618
   gm * 1 + gm
2 0.75 1.111 0.96 1.016 0.9941 1.002 0.9991 1 0.9999 1 1

Pairwise relations such as dif pw f x are easily seen in a graph of f, but repeated use (as in dif pw dif pw f x) are not. They can, however, provide interesting results when applied to familiar functions. For example:

   sqr=: ^ with 2
   sqr x
1 4 9 16 25 36 49 64 81 100 121 144 169
   dif pw sqr x
3 5 7 9 11 13 15 17 19 21 23 25
   dif pw dif pw sqr x
2 2 2 2 2 2 2 2 2 2 2
   dif pw dif pw dif pw sqr x
0 0 0 0 0 0 0 0 0 0

   dp=: dif pw
   dp sqr x
3 5 7 9 11 13 15 17 19 21 23 25
   dp dp sqr x
2 2 2 2 2 2 2 2 2 2 2

   cube=: ^ with 3
   cube x
1 8 27 64 125 216 343 512 729 1000 1331 1728 2197
   dp cube x
7 19 37 61 91 127 169 217 271 331 397 469
   dp dp cube x
12 18 24 30 36 42 48 54 60 66 72
   dp dp dp cube x
6 6 6 6 6 6 6 6 6 6
Exercises

  1. Experiment with pairwise differences of other power functions, and of polynomials.

  2. Experiment with the function p2=: 2 with ^ and the use of the pair-wise quotients %/ pw and %~/ pw on it.

3D. Notes S3D.

Chapters 2 and 3 introduced two important facilities for the study of functions, the function table, and graphs. Chapter 1 introduced one particularly important function, the polynomial -- important because it can approximate, and therefore be used to study, a wide range of functions. The next chapter examines it further.

Any reader puzzled by certain notations (such as the double use of * for both signum and multiplication in Section 1D) may wish to turn now to the two-page discussion of trains, inflections, ambivalence, and bonding in Section 10D.

4: Polynomials

4A. Bonding

4B. Notes

4A. Bonding S4A.

The polynomial function introduced in Chapter 1 is a function of two arguments, the first of which is commonly called the coefficients of the function. Using the example from Chapter 1:
   x=: 4
   2 3 4 p. x
78
   c=: 2 3 4
   c p. x
78
   g=: c with p.
   g x
78
The expression g=: c with p. illustrates the fact that the function p. can be bonded with a list of coefficients to define a specific polynomial function g. Consider the following examples:
   c2=: 1 2 1
   c3=: 1 3 3 1
   c4=: 1 4 6 4 1
   y=: 0 1 2 3 4 5
   f2=: c2 with p.
   f2 y
1 4 9 16 25 36

   f3=: c3 with p.
   f3 y
1 8 27 64 125 216

   (f2 y) * (f3 y)
1 32 243 1024 3125 7776
   g=: f2 * f3
   g y
1 32 243 1024 3125 7776
The Taylor operator t. applies to a polynomial such as f3 to produce a function which, applied in turn to an integer i, gives coefficient i of the polynomial. For example:
   f3 t. 2
3
   f3 t. 0 1 2 3 4 5 6
1 3 3 1 0 0 0
   (f2 * f3) t. 0 1 2 3 4 5 6
1 5 10 10 5 1 0
The result of f2 f3 y is said to be the result of applying f2 to the result of f3. The corresponding function is denoted by f2 on f3. For example:
   f3 y
1 8 27 64 125 216
   f2 1 8 27 64 125 216
4 81 784 4225 15876 47089
   f2 f3 y
4 81 784 4225 15876 47089
   h=: f2 on f3
   h y
4 81 784 4225 15876 47089
   h t. 0 1 2 3 4 5 6 7 8
4 12 21 22 15 6 1 0 0

Exercises

  1. Determine the coefficients of various polynomials such as:
       g1=: f2 * f2
       g2=: f2 * f2 * f2
       g3=: f3 - f2
       g4=: f3 on g

Polynomials are important for a number of reasons:

* Because of the wide choice of coefficients available, polynomials can be defined to approximate most functions of practical interest.

* As already illustrated for sums, products, and composition of polynomials, they are closed under a number of important functions, in the sense that the resulting function is again a polynomial. These include:

SUM          c with p. + d with p.

DIFFERENCE   c with p. - d with p.

PRODUCT      c with p. * d with p.

COMPOSITION  (c with p.) on (d with p.)

SLOPE        or rate of increase over an interval

DERIVATIVE   or limit of the slope over small intervals

AGGREGATE    or area under the graph of a function

INTEGRAL     or limit of the area for small intervals

In most of these cases, the Taylor operator can be used to obtain the coefficients of the resulting polynomial.

4B. Notes S4B.

This brief treatment of polynomials is enough to provide a basis for the treatment of the important topics of Power Series, Slope and Derivative, Growth and Decay, and Vibrations in the next four chapters. We therefore defer further discussion of the polynomial to Chapter 16: Polynomials and Number Systems. That chapter may, however, be attempted at any point.

With increasing use of computer experimentation, it becomes important to learn to use the available tools. In particular:

  1. Use the left and right arrows to position the cursor, and use the delete (Del) and Backspace keys to delete text.

  2. Use the up arrow to move the cursor to an earlier line, press the Enter key to bring it to the entry line, and then edit and re-enter it.

  3. Hold down the Ctrl key and press N to open a script window that does not execute entries, but allows them to be freely edited and then run (in the execution window, to which you may return by entering Ctrl Tab).

  4. The run is performed by entering Ctrl Shift W, or silently by entering Ctrl W. A selected segment may be run by using the mouse or shift key to highlight it, and then entering Ctrl E.

  5. Learn to use more general facilities by using the mouse to drop the Help menu, and then using it to select the index and other information offered.

  6. Any unfamiliar term such as sine or magnitude (or its synonym absolute value) may be found in an English dictionary, or it may be ignored and returned to as suggested in Section 1L.

5: Power Series

5A. Introduction

5B. Truncated power series

5C. Notes

5A. Introduction S5A.

Elements of a list may be identified and selected by its indices, beginning at zero. For example:
   a=:  1 2 3 4 5 6 ^ 3
   a
1 8 27 64 125 216
   0 { a
1
   1 { a
8
   5 { a
216
   6 { a
|index error
|   6    {a
A polynomial whose coefficients may be expressed as a function of their indices is called a power series. For example:
   g=: ! with 3
   g i. 8
1 3 3 1 0 0 0 0
   (g i.8) with p. 0 1 2 3 4 5 6
1 8 27 64 125 216 343
g 0 gives the number of distinct ways that zero things can be chosen from three things; g 1 gives the number of ways that one thing can be chosen, and so on, to the case g 4 which shows that four things can be chosen from three in no ways. The resulting coefficients are those used in c3 in Section 4A; h=: ! with 4 gives those used in c4, and so on. The coefficients:
   0 1 0 _1r6 0 1r120 0 _1r5040
   1 0 _1r2 0 1r24 0 _1r720 0 1r40320
used in Section 3A can also be expressed as power series. Both lists are reciprocal factorials (such as 1r24 and 1r120) multiplied by _1 or 0 or 1. The power series function for the first is given by:
   ps=: % on ! * 2 with | * _1: ^ 3: = 4: | ]
   ps 0 1 2 3 4 5 6 7 8 9 10r1
0 1 0 _1r6 0 1r120 0 _1r5040 0 1r362880 0

Exercises

  1. Define a power series function pc for the second list of coefficients given above.

5B. Truncated power series S5B.

For the power series g=: ! with 3, the coefficients following the first four are all zero, and the truncated series g i.4 therefore defines a polynomial that is equivalent to the longer list produced by g i.8. Thus:
   g i.4
1 3 3 1
   (g i.4) with p. x=: 0 1 2 3 4 5 6
1 8 27 64 125 216 343
   g i.8
1 3 3 1 0 0 0 0
   (g i.8) with p. x
1 8 27 64 125 216 343

On the other hand, the power series: ps=: % on ! * 2 with | * _1: ^ 3: = 4: | ] never “terminates” with all zeros. However, the reciprocal factorial factor (% on !) ensures that successive terms diminish rapidly in magnitude, and a short series may therefore provide a good approximation. For example:

   ] c12=: ps i. 12r1
0 1 0 _1r6 0 1r120 0 _1r5040 0 1r362880 0 _1r39916800
   ] c10=: ps i. 10r1
0 1 0 _1r6 0 1r120 0 _1r5040 0 1r362880
   set 9
   dec (c12 with p. ,c10 with p.) 2
0.909296136 0.909347443
However, the definition of the polynomial in Section 1I shows that successive coefficients are multiplied by successive powers of the argument x. For large arguments, the growth of this factor may be fast enough to overpower the decrease in the coefficient. For example:
   dec (c12 with p. ,c10 with p.) 5
_1.1336173 0.08963018
For small arguments (particularly for those less than one in magnitude), reasonably short power series of the type that includes a reciprocal factorial factor provide good approximations. For example:
   dec ((ps i.20) with p.,(ps i.18) with p.) 5
_0.958933165 _0.958776369
   y=: 1r5 * i:5
   y
_1 _4r5 _3r5 _2r5 _1r5 0 1r5 2r5 3r5 4r5 1

   sin=: 1 with o.   
   ((ps i.10) with p.,.(ps i.8) with p.,.sin) y
_0.841471010 _0.841468254 _0.841470985
_0.717356093 _0.717355723 _0.717356091
_0.564642473 _0.564642446 _0.564642473
_0.389418342 _0.389418342 _0.389418342
_0.198669331 _0.198669331 _0.198669331
           0            0            0
 0.198669331  0.198669331  0.198669331
 0.389418342  0.389418342  0.389418342
 0.564642473  0.564642446  0.564642473
 0.717356093  0.717355723  0.717356091
 0.841471010  0.841468254  0.841470985 

As illustrated by the last column, these truncated power series are approximations to the trigonometric sine function (on radian arguments). Moreover, the Taylor operator t. can be used to produce the power series for the sine as follows:

   sin t. i. 12r1
0 1 0 _1r6 0 1r120 0 _1r5040 0 1r362880 0 _1r39916800

   sign sin t. i. 12r1
0 1 0 _1 0 1 0 _1 0 1 0 _1

Exercises

  1. Try Taylor series of other functions, including the exponential ^

  2. Comment on the results of the following:
       q=: (^t.i),.(1 with o.t.i),.(2 with o.t.i=: i.12x)
       q,.*q

5C. Notes S5C.

Power series are of great importance in math, and it is tempting to digress in a discussion of reasons for this importance, much as was done for polynomials in Section 4A.

However, it was possible to confine that discussion to rather elementary ideas, whereas a meaningful discussion of the uses of power series would quickly lead to more advanced and less familiar mathematical notions outside the experience of many readers.

The same is true of many topics (such as the derivative, symbolic logic, sets, and permutations), and we will leave the reader to observe the importance of topics as they are exploited in later work. In other words, some faith is expected of the reader – a belief that topics will be introduced only if they are both important and interesting.

6: Slope and Derivative

6A. Approximation to the derivative (rate of change)

6B. Derivatives of polynomials

6C. Taylor coefficients

6D. Notes

6A. Approximation to the derivative (rate of change) S6A.

As remarked in Section 3B, the slopes of the segments of a graph show the average rate of change of a function between adjacent points. Plotting more points at lesser intervals gives a better approximation. For example:
   c=: 4 _3 _2 1
   f=: c with p.
   x1=: i.4
   PLOT x1;f x1
 

   x2=: 1r10*i.31
   PLOT x2;f x2
 

   x3=: 1r100 * i.301
   PLOT x3;f x3

Considered as a sample of points on a continuous graph of the function (using an infinite number of points), these sloping lines are secants (cutting lines) to the continuous curve, and the slope at a point is the tangent (touching line) to the curve, which may be approximated by a secant with a small interval.

The expression ((f x+r)-(f x))%r gives the slope of the graph of f between arguments x and x+r as the ratio of the rise (f x+r)-(f x) to the run r. For example:

   x=: 2
   r=: 1r10
   ((f x+r)-(f x)) % r
1.41
   x=: 0 1 2 3 4 5 6
   r=: 1r1000
   ((f x+r)-(f x)) % r
_3.002 _3.999 1.004 12.007 29.01 52.013 81.016

   r=: 1r10000
   ((f x+r)-(f x)) % r
_3.0002 _3.9999 1.0004 12.001 29.001 52.001 81.002
For these small values of the run, the slopes appear to be “approaching a limiting value” given approximately by the run of one ten-thousandth. This limiting value is the derivative of the function f, that is, the slope of the tangent. The value r=: 0 might seem appropriate, but this only gives the meaningless division of a zero rise by a zero run. Thus:
   r=: 0
   ((f x+r)-(f x)) % r
0 0 0 0 0 0 0
The desired result is given by the derivative operator d., with f d.1 giving the (first) derivative of f and f d.2 giving the second derivative (that is, the derivative of the derivative), and so on. For example:
   f d.1 x
_3 _4 1 12 29 52 81
   f d.2 x
_4 2 8 14 20 26 32
   f d.1 2 3 4 5 x
_3 _4 6 0 0
_4  2 6 0 0
 1  8 6 0 0
12 14 6 0 0
29 20 6 0 0
52 26 6 0 0
81 32 6 0 0
Moreover, the application of the Taylor operator to the resulting derivatives show them to be terminating power series, that is, ordinary polynomials:
   d=:  f d.1 t. i.7
   d
_3 _4 3 0 0 0 0
   f d.2 t. i.7
_4 6 0 0 0 0 0
   d with p. x
_3 _4 1 12 29 52 81
   d with p. d.1 x
_4 2 8 14 20 26 32
   f d.2 x
_4 2 8 14 20 26 32
The coefficients d of the first derivative polynomial must bear some relation to the coefficients c of the original polynomial f. We will explore this relation by examining their ratios, as seen in their divide table:
   d % table c
+--+----------------+
|  |   4  _3   _2  1|
+--+----------------+
|_3|_3r4   1  3r2 _3|
|_4|  _1 4r3    2 _4|
| 3| 3r4  _1 _3r2  3|
| 0|   0   0    0  0|
| 0|   0   0    0  0|
| 0|   0   0    0  0|
| 0|   0   0    0  0|
+--+----------------+
The diagonal of successive integers 1 2 3 suggests that d may be obtained from c by multiplying by successive integers, and rotating the result one place to the left:
   c
4 _3 _2 1
   #c NB. number of elements in c
4
   i.#c
0 1 2 3
   c * i.#c
0 _3 _4 3
   1 |. c * i.#c
_3 _4 3 0
   d
_3 _4 3 0 0 0 0
We will first test this relation on another polynomial function and then, in the following section, examine the question of why the relation holds in general:
   c2=: ! with 5 i.6
   c2
1 5 10 10 5 1
   f2=: c2 with p.
   d2=: f2 d.1 t. i.5
   d2
5 20 30 20 5
   1 |. c2 * i.#c2
5 20 30 20 5 0

6B. Derivatives of polynomials S6B.

The polynomial f=: 4 1 3 2 with p. is a sum of four monomials. Thus:
   f=: 4 1 3 2  with p.
   f0=: 4 with * on (^ with 0)
   f1=: 1 with * on (^ with 1)
   f2=: 3 with * on (^ with 2)
   f3=: 2 with * on (^ with 3)
   (f0,f1,f2,:f3) x
4 4  4  4   4   4   4
0 1  2  3   4   5   6
0 3 12 27  48  75 108
0 2 16 54 128 250 432
   (f0+f1+f2+f3) x
4 10 30 76 160 294 490
   f x
4 10 30 76 160 294 490
Any slope of a function that is a sum of functions equals the sum of the corresponding slopes of the component functions, and the derivative of a sum of functions is therefore the sum of the derivatives of the corresponding functions. For example:
   (f0 d.1 , f1 d.1 , f2 d.1 ,: f3 d.1) x
0 0  0  0  0   0   0
1 1  1  1  1   1   1
0 6 12 18 24  30  36
0 6 24 54 96 150 216

   (f0 d.1 + f1 d.1 + f2 d.1 + f3 d.1) x
1 13 37 73 121 181 253
   f d.1 x
1 13 37 73 121 181 253
Similar remarks apply to the multiplication that occurs in the monomials. For example, in f2=: 3 with * on (^ with 2), the multiplication by three of the square function (^ with 2) multiplies each of its slopes by three, and therefore multiplies its derivative by three. It remains to determine the derivative of power functions such as the square. If f=: ^ with 2, then the rise (f x+r)-(f x) is given by the square of x+r (that is, (x+r)*(x+r)) minus the square of x.

Multiplication of the sums gives the square of x plus 2*x*r plus the square of r, and subtraction of the square of x then leaves a rise of 2*x*r plus the square of r. The slope of the square function (for the run r) is then given by dividing this sum by r to obtain (2*x)+r. The derivative is then given by the case for r=: 0, that is, 2*x (or, equivalently, 2*x^1).

Similar calculations for the product (x+r)*(x+r)*(x+r)gives 3*x^2 for the derivative of the cube ^ with 3, and, in general, gives n*x^(n-1)for the derivative of ^ with n. The contribution of a monomial cn * x ^ n to the derivative polynomial is therefore the monomial n * cn * x ^ (n-1), which therefore appears as a coefficient n * cn displaced one place to the left in the list of coefficients.

This is all embodied in the calculation d=: 1: |. c * i.#c given in the preceding section for the coefficients d of the derivative polynomial. These results will be summarized by defining a function der which, applied to a list of coefficients of a polynomial, gives the list of coefficients of the derivative polynomial. We will illustrate its use on the polynomial graphed in Section A, and will graph it together with the secant slopes of the function so that they can be compared:

   der=: 1: |. ] * i. on #
   c=: 4 _3 _2 1
   d=: der c
   d
_3 _4 3 0
   x2=: 1r10*i.31
   PLOT x2 ; (c with p. ,: d with p.) x2

Note that the zero value of the graph of the derivative occurs at the argument value for which the original function reaches its low point, that is, where its graph is horizontal.

The phrase derivative of f correctly suggests that it is a function derived from f, but it is only one among many (such as the inverse) also derived from f. The phrase slope of f would be more informative, and could be distinguished from the associated secant slope of f.

6C. Taylor coefficients S6C.

It is also interesting to compare the Taylor coefficients of the derivative of the polynomial d with p. with the result of the function der:
   d with p. d.1 t. i.8
_4 6 0 0 0 0 0 0
   der d
_4 6 0 0
As a foretaste of the growth and oscillating functions of the next two chapters, we will also show Taylor series for the exponential and sine functions:
   exp=: ^
   exp t. i=:  i.10r1
1 1 1r2 1r6 1r24 1r120 1r720 1r5040 1r40320 1r362880

   exp d.1 t. i
1 1 1r2 1r6 1r24 1r120 1r720 1r5040 1r40320 1r362880
   exp d.2 t. i
1 1 1r2 1r6 1r24 1r120 1r720 1r5040 1r40320 1r362880

   sin=:  1 with o.
   ]s=: sin t. i.12r1
0 1 0 _1r6 0 1r120 0 _1r5040 0 1r362880 0 _1r39916800
   der s
1 0 _1r2 0 1r24 0 _1r720 0 1r40320 0 _1r3628800 0
   sin d.1 t. i.11r1
1 0 _1r2 0 1r24 0 _1r720 0 1r40320 0 _1r3628800
   der der s
0 _1 0 1r6 0 _1r120 0 1r5040 0 _1r362880 0 0
   der der der s
_1 0 1r2 0 _1r24 0 1r720 0 _1r40320 0 0 0
   der der der der s
0 1 0 _1r6 0 1r120 0 _1r5040 0 0 0 0
   s
0 1 0 _1r6 0 1r120 0 _1r5040 0 1r362880 0 _1r39916800

6D. Notes S6D.

For an arbitrary function f (such as any one of the functions of trigonometry), the matter of the limiting value of the secant slope ((f x+r)-(f x)) % r as r “approaches” zero (discussed in Section 6A) raises difficult questions that are properly answered only by lengthy analysis of the notion of limits. This is what makes Calculus such a forbidding subject.

In this chapter we have skirted the issue by confining attention to polynomial functions, for which the limit of the secant slope is easily obtained. We will, however, extend these results to the many important functions that can be approximated by the power series (themselves polynomials) that were discussed in Chapter 5.

Can we be certain that the derivative of a polynomial approximation to a function f is a good approximation to the derivative of f ? Yes, but only for functions that are “uniformly continuous”. This is true of a wide range of functions of practical interest, including all of those to be treated in subsequent chapters.

7: Growth and Decay

7A. Growth polynomials

7B. The name "exponential"

7A. Growth polynomials S7A.

It is a common observation that growing things (such as young plants and animals, young commercial companies, and a colony of bacteria) change not at a constant rate, but at a rate roughly proportional to present size.

The simplest case is where the rate of growth is equal to the size -- this is described by the exponential function, denoted here by ^ . In a graph of this function this relation may be seen approximately in the slopes of the secants. Thus:

   x=: 1r2*i.11
   x
0 1r2 1 3r2 2 5r2 3 7r2 4 9r2 5
   set 4
   ^ x
1 1.649 2.718 4.482 7.389 12.18 20.09 33.12 54.6 90.02 148.4
   PLOT x;^x

Since a polynomial may be found that can approximate almost any function, it should be possible to find one that approximates the exponential. Consider the following:

   c=: 1 1 1r2 1r6 1r24 1r120 1r720 1r5040
   der=: 1:|.]*i.@:# NB. Gives coeffs of derivative 
   d=: der c
   d
1 1 1r2 1r6 1r24 1r120 1r720 0

   dec c with p. x
1 1.649 2.718 4.481 7.381 12.13 19.85 32.23 51.81 82.22 128.6
   dec d with p. x
1 1.649 2.718 4.478 7.356 12.01 19.41 30.95 48.56 74.81 113.1
The two polynomials differ only in the term 1r5040*x^7, and are therefore nearly equal for reasonably small values of x. Moreover, the pattern required of further coefficients is clear: coefficient k must be 1%!k. Thus:
   ! i. 12r1
1 1 2 6 24 120 720 5040 40320 362880 3628800 39916800
   a=: 1 % ! i. 12
   b=: der a
   (a with p. ,. b with p. ,. ^) x
    1     1     1
1.649 1.649 1.649
2.718 2.718 2.718
4.482 4.482 4.482
7.389 7.389 7.389
12.18 12.18 12.18
20.08 20.08 20.09
33.11 33.08 33.12
54.55 54.44  54.6
 89.8 89.42 90.02
147.6 146.4 148.4

Exercises

  1. Experiment with expressions such as ^(x+3) and (^x) * (^3), and comment on the results.

  2. Try the following expressions, and comment on the results:
       (^x) * (^-x)
       ^(x+-x)
       set 2
       ^-x
       % ^ x
       decay=: ^ on -
       decay x
       decay t. i. 10

7B. The name Exponential S7B.

In the dyadic use of the symbol ^, the expression x^e is said to denote the base x to the exponent e, and the function x with ^ may therefore be said to be an exponential function. For example:

   e=: 1r10*i.11
   e
0 1r10 1r5 3r10 2r5 1r2 3r5 7r10 4r5 9r10 1
   3^e
1 1.1 1.2 1.4 1.6 1.7 1.9 2.2 2.4 2.7 3
   3 with ^ e
1 1.1 1.2 1.4 1.6 1.7 1.9 2.2 2.4 2.7 3
   ^e
1 1.1 1.2 1.3 1.5 1.6 1.8 2 2.2 2.5 2.7
   2 with ^ e
1 1.1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.9 2
The exponential function ^ appears to lie between the functions 2 with ^ and 3 with ^. Thus:
   set 7
   (^,.2.5 with ^,.2.75 with ^,.2.71 with 
^,.2.718 with ^,.1x1 with ^) e
       1        1        1        1        1        1
1.105171 1.095958 1.106454 1.104834 1.105159 1.105171
1.221403 1.201124  1.22424 1.220658 1.221377 1.221403
1.349859 1.316382 1.354565 1.348624 1.349817 1.349859
1.491825   1.4427 1.498763 1.490005 1.491763 1.491825
1.648721 1.581139 1.658312 1.646208 1.648636 1.648721
1.822119 1.732862 1.834846 1.818786 1.822005 1.822119
2.013753 1.899144 2.030172 2.009456 2.013607 2.013753
2.225541 2.081383 2.246292 2.220115 2.225356 2.225541
2.459603 2.281109 2.485418 2.452858 2.459374 2.459603
2.718282      2.5     2.75     2.71    2.718 2.718282
The base that gives the exponential exactly is called Euler’s number, and is denoted in math by e and in J by 1x1 .

8: Vibrations

8A. Introduction

8B. Harmonics

8C. Decay

8A. Introduction S8A.

Vibrations are commonly seen in the motions of a clock pendulum, of a piano string, and of a weight (such as a plumb bob suspended on a rubber band or steel spring). If the bob is pulled straight down a certain distance from its rest position and released, it visibly oscillates above and below its rest position until it is brought to rest by friction in the air and in the suspension.

If b is a function that gives the position of the bob as a function of time, then its speed or velocity is given by b d.1 (the rate of change of position), and its acceleration is given by the second derivative b d.1 d.1 (the rate of change of its velocity).

Moreover, the acceleration is caused by the “restoring force” exerted by the spring, which is proportional to its extension as measured by the position b of the bob. In other words, the second derivative b d.1 is proportional to -b.

In the simplest case -b is equal to b d.1 d.1, and we seek a polynomial with this property. Consider the coefficients of the function fs introduced in Section 3A:

   c=:  0 1 0 _1r6 0 1r120 0 _1r5040
   der c
1 0 _1r2 0 1r24 0 _1r720 0
   der der c
0 _1 0 1r6 0 _1r120 0 0
   -der der c
0 1 0 _1r6 0 1r120 0 0
The required pattern is clear: it is the same as for the exponential of Chapter 7, except that alternate coefficients are zero, and that the other coefficients alternate in sign. The function with this property is called the sine, commonly abbreviated to sin:
   sin=: 1 with o.
   sin t. i.12
0 1 0 _1r6 0 1r120 0 _1r5040 0 1r362880 0 
_1r39916800
   sin t. 20 21 22 23
0 1r51090942171709440000 0 _1r25852016738884976640000

8B. Harmonics S8B.

The function sin on (2:*]) applies the sin to the double of its argument, and therefore produces a vibration (or oscillation) of twice the frequency. It is called an harmonic of the oscillation sin. This may be seen in a combined plot of the two functions:
  x=: 1r10 * i.65
  plot x;(sin x) ,: (sin on (2:*]) x)

Exercises

  1. Replace the 2 in the function sin on (2:*]) by other integers to produce other harmonics, and plot the results.

  2. Plot the function cos and some of its harmonics.

  3. Plot the function cos against its harmonic cos on (2:*]).

8C. Decay S8C.

Because of "friction" of some sort, vibrations commonly decay, usually at an approximately exponential rate determined by a function of the form decay=: ^ on - on (] % [).

Exercises

  1. Plot the decaying oscillation sin * 6 with decay .

  2. Plot sine and cosine functions with rates of decay other than 6, and plot them together with their non-decaying counterparts.

9: Inverses and Equations

9A. Inverse

9B. Equations

9C. The method of false position

9D. Newton’s method

9E. Roots of Polynomials

9F. Logarithms

9A. Inverse S9A.

The predecessor function (<:) introduced in 1D is said to be the inverse of the successor function (>:) because it “undoes” its work. For example:
   >:1 2 3 4 5
2 3 4 5 6
   <:>:1 2 3 4 5
1 2 3 4 5
Conversely, >: is also the inverse of <:, and we may simply say that the two are inverses.

The need for inverse functions arises frequently. For example, the heat produced by an electric heater may be given by the function h=: (* with 4) on sqr, where sqr=: *: is the square function. In order to determine the voltage required to produce a desired heat, we need the inverse v=: sqrt on (% with 4), where sqrt=: %: is the square root function. Thus:

   h=: (* with 4) on sqr
     sqr=: *:
   v=: sqrt on (% with 4)
     sqrt=: %:
   h 0 1 2 3 4 5 6 7
0 4 16 36 64 100 144 196 
   v h 0 1 2 3 4 5 6 7 
0 1 2 3 4 5 6 7 
   v 0 1 2 3 4 5 6 7 
0 0.5 0.707107 0.866025 1 1.11803 1.22474 1.32288 
   h v 0 1 2 3 4 5 6 7 
0 1 2 3 4 5 6 7
For many (but not all) functions, the inverse operator INV=: ^:_1 produces the inverse function. For example:
   INV=: ^:_1
   <:INV 0 1 2 3 4 5 6 7
1 2 3 4 5 6 7 8
   cube=: ^ with 3
   cuberoot=: cube INV

   cube 0 1 2 3 4 5 6 7
0 1 8 27 64 125 216 343
   cuberoot cube 0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7

   ^ with 4 INV 0 1 2 3 4 5 6 7
0 1 1.18921 1.31607 1.41421 1.49535 1.56508 1.62658
   ^ with 4 ^ with 4 INV 0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7

   f=: ^ with 3 + ^ with 4
   f 0 1 2 3 4 5 6 7
0 2 24 108 320 750 1512 2744
   f INV 0 1 2 3 4 5 6 7
|domain error
|       f INV 0 1 2 3 4 5 6 7

9B. Equations S9B.

However, for a specific argument, say y=: 20, we could find the value of the inverse of f by guessing the result x, and applying f to it to guide us to an improved guess, by either increasing or decreasing x. For example:
   y=: 20
   x=: 2
   f x
24
   x=: x-1r2 
   set 5
   f x
8.4375
   x=: x+1r4
   dec f x
14.738
   dec f x=: x+1r8
18.951
   dec f x=: x+1r16
21.365
   dec f x=: x-1r32
20.131
   dec f x=: x-1r64
19.535
   dec f x=: x+1r128
19.831
   dec f x=: x+1r256
19.981
   dec f x=: x+1r512
20.056
   dec x
1.9043
This problem is commonly stated as the equation (f x)=y, implying that one is to find a value of x such that the relation is true. Moreover, the problem of solving equations is commonly introduced with little or no clue as to why the matter is important.

The function g=: - with y on f differs from f in subtracting y from the result, and a solution of (g x)=0 is therefore a solution of (f x)=y. A solution of (g x)=0 is said to be a root of the function g.

9C. The method of false position S9C.

If one knows two values a and b such that g a and g b differ in sign, then a root of g must lie somewhere between them; the list ab=: a,b is said to bracket the root. Evaluation of f at its midpoint m (that is, m=: mean ab) will either yield zero (in which case m is a root of g), or it will differ in sign from one of the two results of g ab.

The element of ab that differs can be used with m to form a tighter bracket, whose mean will give a better approximation to the root of g. This process may be repeated to obtain as close an approximation as desired. For example:

   g=: - with y on f
   g ab=: 1,2
_18 4
   mean=: +/ % #
   ]m=: mean ab
1.5
   g m
_11.563
   ]ab=: m,1{ab
1.5 2
   g ab
_11.563 4
In general, a bracket of a root of a function g may be tightened by the function tighten, defined and illustrated below:
   tighten=:  mean,(sign on{. on g = sign on g on mean) { ]
   tighten ab=: 1,2
1.5 2
   tighten tighten tighten ab
1.875 2
   g tighten tighten tighten ab
_1.0486 4
The function tighten may be paraphrased as follows: Compare the sign of the first element ({.) of the result of g for equality with the sign of g on the mean, and use the result (0 or 1) as an index to select from the argument; finally, catenate the selection with the mean. The operator ^: can be used to apply a function repeatedly, as illustrated below:
   tighten^:3 ab
1.875 2
   z=: tighten^:0 1 2 3 4 5 6 7 8 9 10 11 12 ab
   z;g z
+---------------+-------------------------+
|      1       2|         _18            4|
|    1.5       2|    _11.5625            4|
|   1.75       2|    _5.26172            4|
|  1.875       2|    _1.04858            4|
| 1.9375   1.875|     1.36501     _1.04858|
|1.90625   1.875|    0.131333     _1.04858|
|1.89063 1.90625|   _0.465246     0.131333|
|1.89844 1.90625|   _0.168624     0.131333|
|1.90234 1.90625|  _0.0190637     0.131333|
| 1.9043 1.90234|   0.0560301   _0.0190637|
|1.90332 1.90234|    0.018457   _0.0190637|
|1.90283 1.90332|_0.000309859     0.018457|
|1.90308 1.90283|  0.00907195 _0.000309859|
+---------------+-------------------------+

9D. Newton’s method S9D.

If x=: 2 is an appoximation to the root of g, then (as suggested by the small “triangle” with apex at the point x,g x in the accompanying graph) a good correction is provided by dividing g x by the derivative g d.1 x that gives the slope of the tangent to the graph at the point x,g x:
    PLOT x;g x=: 1r10*i.22
   x=: 2
   (g , g d.1 , g%g d.1) x
4 44 0.0909091
   
   x=: x - (g%g d.1) x
   g x
0.24124
   x=: x - (g%g d.1) x
   g x
0.00106658
   
   newton=: ] - g % g d.1
   newton 2
1.90909
   g newton 2
0.24124
   
   newton^:(i.4) 2
2 1.90909 1.90287 1.90284
   g newton^:(i.4) 2
4 0.24124 0.00106658 2.1139e_8
   
   g newton ^:(i.3 5) 25
  406230     128520      40655     12855.8     4061.08
 1279.01    399.129    121.057     33.5929     7.07075
0.658183 0.00775433 1.11692e_6 2.13163e_14 3.55271e_15

Although Newton’s method converged rather rapidly for the function g, its convergence is not guaranteed in general, especially for initial guesses far from the root.

9E. Roots of Polynomials S9E.

The (possibly multiple) roots of a polynomial c with p. may, in principle, be obtained by the methods of sections 9C and 9D, but it may be difficult to find suitable brackets or initial guesses. However, the function roots=: > on {: on p. may be applied to the coefficients c to obtain the roots. For example:
   roots=: > on {: on p.
   c=: _1 0 1
   r=: roots c
   r
1 _1
   c p. r
0 0
   
   d=: 6 1 _4 1
   s=: roots d
   s
3 2 _1
   d p. s
3.55271e_15 2.66454e_15 0
Because of the limited precision of the computations leading to the roots s, the application of the polynomial to them yields tiny results, but not exact zeros. The following function (the product of the sign function with the magnitude) serves to make such results more readable by "zeroing" tiny results:
   zero=: **|
   zero d p. s
0 0 0
A graph of the polynomial 1 0 1 with p. (one plus the square) indicates that it has no roots, because the graph never drops to zero:
   e=: 1 0 1
   x=: i:4
   PLOT x;e p. x

Nevertheless, the function roots applies as follows:

   roots e
0j1 0j_1
   e p. roots e
0 0
The root 0j1 is an example of an imaginary number, to be discussed in Chapter 19. Its square is negative one:
   0j1*0j1
_1

9F. Logarithms S9F.

The logarithm (^.) is the function inverse to the exponential:
   ^ ^:_1
^.
   ^. ^:_1
^   
   ]x=: i.8
0 1 2 3 4 5 6 7
   ^x
1 2.71828 7.38906 20.0855 54.5982 148.413 403.429 1096.63
   ^.^x
0 1 2 3 4 5 6 7
   
   ^.x
__ 0 0.693147 1.09861 1.38629 1.60944 1.79176 1.94591
   ^^.x
0 1 2 3 4 5 6 7
As discussed in Section 7B, the exponential ^ is equal to e with ^, where e=: 1x1 is Euler's number. Similarly, e with ^. is inverse to e with ^, as illustrated below:
   e=: 1x1
   e
2.71828
   e with ^ x
1 2.71828 7.38906 20.0855 54.5982 148.413 403.429 1096.63
   e with ^. e with ^ x
0 1 2 3 4 5 6 7
   
   10 with ^ x
1 10 100 1000 10000 100000 1e6 1e7
   10 with ^. 10 with ^ x
0 1 2 3 4 5 6 7
   
   10 with ^. 1 10 100 1000 10000 100000
0 1 2 3 4 5
The function 10 with ^. is the base-10 logarithm, more commonly used in elementary math than the natural log ^. .

The logarithm is discussed further in Chapter 20.

10: Language and Grammar

10A. Introduction

10B. Word formation

10C. Parsing

10D. Conventional mathematical Notation

10A. Introduction S10A.

Despite its importance, the grammar of our native language is not acquired by formal instruction, but by imitation and casual guidance in conversation. Formal grammar becomes important only at a later stage, in addressing more complex and more precise uses of language.

Formal grammar becomes particularly important in writing, where the reader has no recourse to interjected questions, but must extract meaning from the text alone.

Similar considerations apply in mathematics. Although the Hogben remarks cited in our preface emphasize the importance of language and grammar, we have introduced the grammar of our language J only informally, allowing us to concentrate on the mathematical notions it has been used to convey.

This informal approach has been made tolerable by limiting the writing required of a student in Exercises to imitation of expressions already used, and by providing guidance through conversation with the computer, a native speaker of the language. This chapter will address the formal grammar of J, and will also comment on the more loosely structured grammar of conventional mathematical notation.

10B. Word formation S10B.

Grammar is commonly taken to concern parsing the words of a sentence into phrases, and determining the order in which the phrases are to be interpreted. However, it is worth noting that the comprehension of a sentence must begin by first breaking it into its component words.

In a written English sentence this process is so simple as to go unnoticed, although the separation by spaces is somewhat complicated by things such as hyphens and apostrophes. In oral communication it is also unnoticed, not because the breaking of a continuous stream of sound into words is simple, but because (except in the case of a foreign language) it is so deeply ingrained.

In the case of J the word formation requires some attention, although it is simple enough to have been thus far treated informally by example. The computer provides a word-formation function that may be applied to a sentence enclosed in quotes. Thus:

   ;: '12+27'
+--+-+--+
|12|+|27|
+--+-+--+
   ;: '12+.27'
+--+--+--+
|12|+.|27|
+--+--+--+
   ;: '12+0.27'
+--+-+----+
|12|+|0.27|
+--+-+----+
   ;: '+/1 2 3 4'
+-+-+-------+
|+|/|1 2 3 4|
+-+-+-------+
The formal rules are stated in the J Dictionary as follows:

The alphabet is standard ASCII, comprising digits, letters (of the English alphabet), the underline (used in names and numbers), the (single) quote, and others (which include the space) to be referred to as graphics.

Alternative spellings for the national use characters (which differ from country to country) are discussed under Alphabet (a.).

Numbers are denoted by digits, the underbar (for negative signs and for infinity and minus infinity -- when used alone or in pairs), the period (used for decimal points and necessarily preceded by one or more digits), the letter e (as in 2.4e3 to signify 2400 in exponential form), and the letter j to separate the real and imaginary parts of a complex number, as in 3e4j_0.56. Also see the discussion of Constants.

A numeric list or vector is denoted by a list of numbers separated by spaces. A list of ASCII characters is denoted by the list enclosed in single quotes, a pair of adjacent single quotes signifying the quote itself: 'can''t' is the five-character abbreviation of the six-character word 'cannot'. The ace a: denotes the boxed empty list <$0 .

Names (used for pronouns and other surrogates, and assigned referents by the copula, as in prices=: 4.5 12) begin with a letter and may continue with letters, underlines, and digits. A name that ends with an underline or that contains two consecutive underlines is a locative, as discussed in Section II.I.

A primitive or primary may be denoted by a single graphic (such as + for plus) or by a graphic modified by one or more following inflections (a period or colon), as in +. and +: for or and nor. A primary may also be an inflected name, as in e. and o. for membership and pi times. A primary cannot be assigned a referent.

It would clearly be confusing if it were possible to assign the name + to multiplication, as in +=: * .

10C. Parsing S10C.

The complete parsing rules are stated in the J dictionary as follows. The leading five-point summary will suffice for most purposes:

A sentence is evaluated by executing its phrases in a sequence determined by the parsing rules of the language. For example, in the sentence 10%3+2, the phrase 3+2 is evaluated first to obtain a result that is then used to divide 10. In summary:

  1. Execution proceeds from right to left, except that when a right parenthesis is encountered, the segment enclosed by it and its matching left parenthesis is executed, and its result replaces the entire segment and its enclosing parentheses.

  2. Adverbs and conjunctions are executed before verbs; the phrase ,"2-a is equivalent to (,"2)-a, not to ,"(2-a).

    Moreover, the left argument of an adverb or conjunction is the entire verb phrase that precedes it. Thus, in the phrase +/ . */b, the rightmost adverb / applies to the verb derived from the phrase +/ . *, not to the verb * .

  3. A verb is applied dyadically if possible; that is, if preceded by a noun that is not itself the right argument of a conjunction.

  4. Certain trains form verbs, adverbs, and conjunctions, as described in Section F.

  5. To ensure that these summary parsing rules agree with the precise parsing rules prescribed below, it may be necessary to parenthesize an adverbial or conjunctival phrase that produces anything other than a noun or verb.

One important consequence of these rules is that in an unparenthesized expression the right argument of any verb is the result of the entire phrase to its right. The sentence 3*p%q^|r-5 can therefore be read from left to right: the overall result is 3 times the result of the remaining phrase, which is the quotient of p and the part following the %, and so on.

Parsing proceeds by moving successive elements (or their values except in the case of proverbs and names immediately to the left of a copula) from the tail end of a queue (initially the original sentence prefixed by a left marker §) to the top of a stack, and eventually executing some eligible portion of the stack and replacing it by the result of the execution.

For example, if a=: 1 2 3, then b=: +/2*a would be parsed and executed as follows:


§ b =:  + / 2 * a  
§ b =:  + / 2 *          1  2  3
§ b =:  + / 2          * 1  2  3
§ b =:  + /          2 * 1  2  3
§ b =:  +         /  2 * 1  2  3
§ b =:  +             /  2  4  6
§ b =:              + /  2  4  6
§ b             =:  + /  2  4  6
§ b                       =:  12
§                       b =:  12
§                            12
                           § 12
The foregoing illustrates two points: 1) Execution of the phrase 2 * 1 2 3 is deferred until the next element (the /) is transferred; had it been a conjunction, the 2 would have been its argument, and the monad * would have applied to 1 2 3; and 2) Whereas the value of the name a moves to the stack, the name b (because it precedes a copula) moves unchanged, and the pronoun b is assigned the value 12.

Parsing can be observed using the trace conjunction 13!:16 (q.v.). The executions in the stack are confined to the first four elements only, and eligibility for execution is determined only by the class of each element (noun, verb, etc., an unassigned name being treated as a verb), as prescribed in the following parse table.

The classes of the first four elements of the stack are compared with the first four columns of the table, and the first row that agrees in all four columns is selected. The bold italic elements in the row are then subjected to the action shown in the final column, and are replaced by its result. If no row is satisfied, the next element is transferred from the queue:

EDGE      VERB        NOUN   ANY        0  Monad
EDGE+AVN  VERB        VERB   NOUN       1  Monad
EDGE+AVN  NOUN        VERB   NOUN       2  Dyad 
EDGE+AVN  VERB+NOUN   ADV    ANY        3  Adverb
EDGE+AVN  VERB+NOUN   CONJ   VERB+NOUN  4  Conj
EDGE+AVN  VERB        VERB   VERB       5  Trident
EDGE      CAVN        CAVN   CAVN       6  Trident
EDGE      CAVN        CAVN   ANY        7  Bident
NAME+NOUN ASGN        CAVN   ANY        8  Is
LPAR      CAVN        RPAR   ANY        9  Paren

Legend:	AVN	denotes	ADV+VERB+NOUN
CAVN    denotes	CONJ+ADV+VERB+NOUN
EDGE    denotes	MARK+ASGN+LPAR

10D. Conventional mathematical notation S10D.

This section is a discussion of mathematical notation from the vantage point of programming languages, with emphasis on ideas from programming that might be adopted without conflict in mathematical notation.

It includes a discussion of the learnability of mathematical notation as compared with other specialized notations and with native languages, as well as the importance of such learnability.

SOME HISTORICAL VIEWS ON NOTATION Mathematicians have often noted the power and importance of notation. In Part IV of his two-volume A History of Mathematical Notations [3], Florian Cajori offers the following examples:

By relieving the brain of all unnecesary work, a good notation sets it free to concentrate on more advanced problems, and in effect increases the mental power of the race... By the aid of symbolism we can make transitions in reasonings almost mechanically by the eye... A. N. Whitehead

Nothing in the history of mathematics is to me so surprising or impressive as the power it has gained by its notation or language ... But in Napier’s time, when there was practically no notation, his discovery or invention [of logarithms] was accomplished by mind alone, without any aid from symbols. J.W.L. Glaisher

Some symbols, like an, ..., log n, that were used originally for only positive integral values of n stimulated intellectual experimentation when n is fractional, negative, or complex, which led to vital extensions of ideas. F. Cajori

The quantity of meaning compressed into small space by algebraic signs, is another circumstance that facilitates the reasonings we are accustomed to carry on by their aid. Charles Babbage

Symbols which initially appear to have no meaning whatever, acquire gradually, after subjection to what might be called experimenting, a lucid and precise significance. E. Mach

On the other hand, Cajori comments on the paucity of publications concerning the general question of notation, and quotes De Morgan (“a close student of the history of mathematics”) as follows: Mathematical notation, like language, has grown up without much looking to, at the dictates of convenience and with the sanction of the majority.

In Sections 740 ff, Cajori laments the lack of standardization of mathematical notation in the following excerpts:

§740 Uniformity of mathematical notations has been a dream of many mathematicians ...

§741 The admonition of history is clearly that the chance, haphazard procedure of the past will not lead to uniformity.

§746 In this book we have advanced many other instances of “muddling along” through decades, without endeavor on the part of mathematicians to get together and agree on a common sign language.

§748 In the light of the teaching of history it is clear that new forces must be brought into action in order to safeguard the future against the play of blind chance. ... We believe that this new agency will be organization and co-operation. To be sure, the experience of the past in this direction is not altogether reassuring.

However, in William Oughtred: A Great Seventeenth-Century Teacher of Mathematics [4], Cajori touches on a quite different agency that bears upon the development and teaching of mathematics -- the mathematical instrument. On page 88 we have:

In that preface William Forster quotes the reply of Oughtred to the question of how he (Oughtred) had for so many years concealed his invention of the slide rule from himself (Forster) whom he had taught so many other things. The reply was:
That the true way of Art is not by Instruments, but by Demonstration: and that it is a preposterous course of vulgar Teachers, to begin with Instruments, and not with the Sciences, and so in-stead of Artists, to make their Scholers only doers of tricks, and as it were Iuglers ... That the vse of instruments is indeed excellent, if a man be an Artist: but contemptible being set and opposed to Art. And lastly, that he meant to commend to me, the skill of Instruments, but first he would haue me well instructed in the Sciences.
On page 93 Cajori continues with:
It may be claimed that there is a middle ground which more nearly represents the ideal procedure in teaching. Shall the slide rule be placed in the student’s hands at the time when he is engaged in the mastery of principles? Shall there be an alternate study of the theory of logarithms and of the slide rule -- on the idea of one hand washing the other -- ...
Writing in the early 1900’s, Cajori could not have foreseen the advent of that universal mathematical instrument, the modern computer, nor its spawning of the development and study of the notations of programming languages.

PROGRAMMING LANGUAGES Early computers provided a small set of operations such as addition and multiplication, and were controlled by programs specifying sequences of these operations. For example, on the Harvard Mark IV [5], the program:

      00 0080 10
      00 0081 11
      10 0082 11
loaded the number contained in register 80 into the accumulator, added register 81 to it, and stored the resulting sum in register 82.

Programs were later developed to translate from languages more congenial to mathematicians into equivalent machine language programs for subsequent execution. For example, in BASIC, a language largely derived from FORTRAN (Formula Translator) [6], one might write:

      Let a=3
      Let b=5
      Let c=(a+b)*(a-b)
Although a few symbols from programming languages (such as FORTRAN’s * for multiplication) have been widely adopted in math, the mathematical notation used in exposition has been largely unaffected. On the other hand, many mathematicians have been forced to learn programming languages, or to work with programmers who translate their mathematical expressions.

Moreover, many have moved to Computer Science, unwittingly following the advice of Newton, as expressed in the following excerpt from page 95 of Cajori [4]:

“I doubt not but that there shall be in convenient time, brought to light many precepts which may tend to ye perfecting of Navigation, and the help and safety of such whose Vocations doe inforce them to commit their lives and estates in the vast Ocean to the providence of God.” Thus farr that very good and judicious man Mr. Oughtred. I will add, that if instead of sending the Observations of Seamen to able Mathematicians at Land, the Land would send able Mathematicians to Sea, it would signify much more to the improvemt of Navigation and safety of Mens lives and estates on that element.
The need to make translation manageable has led to the development of languages with simple and precisely defined grammars, that is, rules for word-formation and parsing. Although mathematical notation undoubtedly possesses parsing rules, they are rather loose, sometimes contradictory, and seldom clearly stated. It is perhaps significant that Cajori’s History makes no mention of the matter of grammar.

The proliferation of programming languages shows no more uniformity than mathematics. Nevertheless, programming languages do bring a different perspective. Not only do they provide precisely defined grammars, but they address a much wider range of applications than do any one of the notations treated by Cajori. Moreover, they sometimes adopt notions from advanced mathematics and apply them fruitfully at elementary levels.

For example, the essential notion of Heaviside’s operators [7] (introduced in the treatment of differential equations) is the application of an entity (called an operator) which, applied to a function, produces a related function; a notion more familiar in the form f ' for the derivative of f. In APL [8], an operator (denoted by /) is used to provide reduction over a vector argument. The sum over a vector is obtained as follows:

   v<-2 7 1 8 2 8
   +/v
28
The operator applies to any function, such as * (times), >. (max), or <. (min), and may therefore obviate the use of many symbols such as the capital Greek sigma and pi for summation and product:
   (*/v),(>./v),(<./v)
1792 8 1
Because of their application to a broad range of topics, their strict grammar, and their strict interpretation, programming languages can provide new insights into mathematical notation. We begin with the matter of symbols.

ECONOMY OF SYMBOLS Far from introducing further symbols in the manner of Oughtred’s list (of some 150) shown in §181 of Cajori [3], programming languages are largely confined to a standard alphabet (ASCII) whose special characters are limited to the following familiar list:

    = < > _  + * - %  ^ $ ~ |  . : , ;  
    # ! / \  [ ] { }  " ' ` @ & ? 
This economy is achieved in part by adopting from mathematics the use of reserved words such as sin, cos, e, and log -- reserved from use as names for variables. Further economies are implicit in notions that have been used in mathematics but not systematically exploited. We will illustrate them by their use in J, a language derived from APL.

TRAINS Some writers, such as March and Wolf in their Calculus [10], denote the function that is the sum of functions f and g by f+g. This notion can be exploited more generally, including constructs such as f+g*h for f added to the product of g and h. For example, using % for divide, and # for number of elements:

   mean=:  +/ % #    NB. Arithmetic mean or average
   mean 1 2 3 4 5
3
   com=:  ] - +/ % # NB. ] is the identity function
   com 1 2 3 4 5    NB. Center on mean
_2 _1 0 1 2
Non-mathematical functions can be used in a train. For example, the function ; (which boxes each argument and catenates the boxed results) can be used to display results for convenient comparison:
   (];mean;com;] - +/ % #) 1 2 3 4 5
+---------+-+-----------+-----------+
|1 2 3 4 5|3|_2 _1 0 1 2|_2 _1 0 1 2|
+---------+-+-----------+-----------+

INFLECTION A symbol formed by appending a dot or colon to a given function symbol will be said to be inflected, and such inflection is used to assign related symbols to related functions, providing names that therefore have some mnemonic value. For example, in his Laws of Thought [9], George Boole used 1 and 0 to denote true and false, and used the symbols for times and plus to denote the logical functions and and or.

The analogy between times and and was helpful, and the conflict with the normal use of the symbols was of no concern within the confines of logic. In a wider context it is a concern, and J uses *. for and and +. for or. Similarly, = is used as a truth-function (like < and >), whereas =: is used as a copula (to assign a referent to a name), and <. is used for lesser-of (that is, minimum). Thus:

   p=:  0 0 1 1 [ q=:  0 1 0 1
   (p *. q);(p +. q);(p + q);(p < q);(p <. q)
+-------+-------+-------+-------+-------+
|0 0 0 1|0 1 1 1|0 1 1 2|0 1 0 0|0 0 0 1|
+-------+-------+-------+-------+-------+
AMBIVALENCE In the expression a-b the symbol - denotes subtraction (a function of two arguments), whereas in -b it denotes negation, a different (albeit related) function of one argument. This ambivalence (a “binding power” of either two or one) introduces no confusion in conventional notation, and could be exploited for other functions:
   a=: 2
   b=: 5
   (a-b),(-b)   NB. Subtraction and Negation (0-b)
_3 _5
   (a%b),(%b)   NB. Division and Reciprocal (1%b)
0.4 0.2
   (a^b),(^b)   NB. Power and Exponential (e^b)
32 148.413
   (a^.b),(^.b) NB. Base-a log, Natural log (e^.b)
2.32193 1.60944
BONDS In their Combinatory Logic [11], Curry and Feys developed a set of combinators, which we will treat as operators in the sense of Heaviside. One of these bonds a function of two arguments (such as ^) to one of its arguments (such as 3) to produce a function of one argument (the cube), an operation that has come to be called Currying in honour of its author. For example:
   cube=:  ^ with 3
   log10=:  10 with ^.
   (cube ; log10) 10 50 100 200 
+-------------------+-------------------+
|1000 125000 1e6 8e6|1 1.69897 2 2.30103|
+-------------------+-------------------+
Conclusion. Taken together, trains, inflection, ambivalence, and bonds provide highly mnemonic representations for a host of functions. Their advantages can be fully appreciated only by careful comparison with the alternatives now used in mathematics.

A UNIFORM NOTATION Cajori recognizes the importance of individual invention, but warns against individual efforts to impose a uniform system:

§727 Invention of Symbols. -- Whenever the source is known, it is found to have been individualistic -- the conscious suggestion of one mind.

§742 This confusion is not due to the absence of individual efforts to introduce order. Many an enthusiast has proposed a system of notation for some particular branch of mathematics, with the hope, perhaps, that contemporary and succeeding workers in the same field would hasten to adopt his symbols and hold the originator in grateful remembrance. Oughtred in the seventeenth century used over one hundred and fifty signs for elementary mathematics -- algebra, geometry, and trigonometry.

Comments about the hope of grateful remembrance appear unkind; perhaps Oughtred invented symbols to clarify his own thinking, and as a tool for teaching. Nevertheless, Cajori’s main point is sound -- any attempt to impose an individual system is vain and hopeless.

However, such a system can be used as a basis for the discussion of mathematical notation: the precision provided (or enforced) by programming languages and their execution can identify lacunas, ambiguities, and other areas of potential confusion in conventional notation.

Discussion here will focus on such matters, and may suggest remedies. Discussion will also center on a single programming language (J), for the following reasons:

* As indicated in my A Personal View of APL [12], it was designed “as a simple, precise, executable notation for the teaching of a wide range of subjects”.

* It has received some use in mathematical exposition.

* Its simple grammar is defined by a ten-by-four table in terms of six parts of speech.

* It uses vectors, matrices, and higher-dimensional arrays, based on the unifying concept of rank or order in Tensor Calculus [13].

* In addition to the bond operator already discussed, it embraces some fifteen or more operators (such as dual, Taylor, and Hypergeometric) of interest in mathematics.

GRAMMAR The evaluation, interpretation, or execution of the mathematical expression (or sentence) log(a+b)*(a-b) is carried out by identifying the primitive operations (such as addition) and then performing them in an appropriate order. The process begins with word-formation (identification of the individual words: log, left parenthesis, a, +, b, etc.), and continues with parsing the sequence of words according to a formal or informal grammar based upon the parts of speech (variables, functions, punctuation, etc.).

In natural language, the word-formation is largely unnoticed, except in listening to an unfamiliar language. In programming languages, the word-formation and parsing are commonly lumped together under the term syntax.

In J, the word- formation may be made explicit by applying the word-formation function (;:) to a quoted character string:

   ;:'log(a+b)*(a-b)'
+---+-+-+-+-+-+-+-+-+-+-+-+
|log|(|a|+|b|)|*|(|a|-|b|)|
+---+-+-+-+-+-+-+-+-+-+-+-+

Although programming languages adopt the term grammar from English, most use terms for the parts of speech adopted fro