This action might not be possible to undo. Are you sure you want to continue?
MASSACHUSETTS INSTITUTE OF TECHNOLOGY
ARTIFICIAL INTELLIGENCE LABORATORY
HAKMEM
by
M. Beeler
R.W. Gosper
R. Schroeppel
February 1972
This report describes research done at the Artificial Intelligence
Laboratory of the Massachusetts Institute of Technology. Support
for the Laboratory's artificial intelligence research is provided
in part by the Advanced Research Projects Agency of the Department
of Defense under Office of Naval Research contract N0001470A0362
1
.
0002.
This version allows the text to be searched, created by applying OCR to
ftp://publications.ai.mit.edu/aipublications/pdf/AIM239.pdf GWH (2009)
•
Compiled with the hope that a record of the
random things people do around here can save
some duplication of effort  except for fun.
page 1
Here is some little known data which may be of interest to
computer hackers. The items and examples are so sketchy that to
them may require more sincerity and curiosity than a
nonhacker can muster. Doubtless, little of this is new, but
nowadays it's hard to tell. So we must be content to give you an
insiaht, or save you some cycles, and to welcome further
contributions of items, new or used.
The classification of items into sections is even more illogical
than necessary. This is because later elaborations tend to shift
perspective on many items, and this elaboration will (hopefully)
continue after pUblication, since this text is retained in
"machinable" form. foraive in advance anyone deterred by this
wretched typography.
People referred to are
from the A. I. Lab:
Marvin Minsky
Bill Gosper
Michael Beeler
John Roe
Richard Stallman
Jerry Freiberg
once at the A. I. Lab but now
Jan Kok
Rici Liknaitzky
Peter Samson
Roger Banks
Mike Paterson
Rich Schroeppel
Michael Speciner
Gerald Sussman
Joe Cohen
David tz
David Silver
elsewhere:
William Henneman
George Mitchell
Stuart Nelson
Rollo Silver
at Digital Equipment Corporation:
Jud Lenard Dave Plumer
Ben Gurley (deceased) Steve Root
elsewhere at M.I.T.:
Gene Salamin
Eric Jensen
Edward Fredkin
PDPI hackers
Frances Yao
once at M.I.T., but now elsewhere:
Jackson Wright Steve Brown
Malcolm Rayfield
in France:
Marco Schutzenberger Henry Cohen
at Computer Corporation of America: Bill Mann
at BBN: Robert Clements
CAVEATS:
Some of this material is very inside
excuse cryptic references.
page 2
many readers will have to
The label "PROBLEM" ~ o e s not always mean exercise;
if no solution is given, it means we couldn't solve it.
If you solve a problem in here, let us know.
Unless otherwise stated, all computer programs are in PDP6/l0
assembly language.
CONTENTS, HAKMEM 140
3 GEOMETRY, ALGEBRA, CALCULUS
6 RECURRENCE RELATIONS
10 BOOLEAN ALGEBRA
12 RANDOM NUMBERS
13 NUMBER THEORY, PRIMES, PROBABILITY
2S AUTOMATA THEORY
26 GAMES
30 PROPOSED COMPUTER PROGRAMS
36 CONTINUED FRACTIONS
45 GROUP THEORY
45 SET THEORY
46 QUATE RN IONS
48 POLYOMINOS, ETC.
51 TOPOLOGY
54 SERIES
61 FLOWS AND ITERATED FUNCTIONS
67 PI
72 PROGRAMMING HACKS
82 PROGRAMMING ALGORITHMS, HEURISTICS
87 HARDWARE
Page
19, 20
21
31, 32
34
50
58, 59
62
66
84
Figure
la, Ib
2
3a, 3b
4
5
6a, 6b
7
8
9
Binary integers radix iI, i+l.
Radix iI fraction parts (Knuth).
Squared square, rectangle.
Square, hexagon dissection.
Hexiamond solutions.
"clock hands" series.
Binary numbers radix 2.
"C" curves.
Incremental curve drawing.
"
*********************************************
GEOMETRY, ALGeBRA, CALCULUS
*********************************************
page 3
ITEM 1 (Schroeppel):
(1/3)! and (2/3)! are interexpressible.
(1/4)! and (3/4) 1 are interexpressible.
Thus these two pairs are of dimensionality one.
(1/10)! and (2/l0)! are sufficient to express (N/lO)! for all N.
(1/12)! and (2/l2)! are sufficient to express (N/12) I for all N.
(1/3)! and (1/4) I are sufficient to express (N/12) 1 for all N.
Thus the three cases above are of dimensionality two.
PROBLEM: Find some order to this dimensionality business.
The reflection and multiplication formulas:
Z!(Z)! = nZ/sin nZ
(NI)/2
( 2n)
NZl/2
N (NZ)! = Z! (Zl/N) I (Z2/N) 1 ••• (Z (NI) /N) I
ITEM 2 (Jan Kok):
PROBLEM: Given a regular ngon with all diagonals drawn, how many
regions are there? In particular, how many triple (or Ntuple)
concurrences of diagonals are there?
ITEM 3 (Schroeppel):
Regarding convergence of Newton's method for quadratic equations:
Draw the perpendicular bisector of the line connecting the two
roots. Points on either side converge to the closest root.
On the line:
1 they do not converge
2 there is a tiense set of points which involve division by zero
3 there is a dense set of points which loop, but roundoff error
propagates so all loops are unstable
4 being on the line is also unstable (if the roots are imaginary
and you are on the real axis, you may be doing exact computation
of the imaginary part (0), hence stay on the line. Example:
X
2
+ 1 = 0, XO = random real floating point number.)
ITEM 4 (Schroeppel): page 4
»y Mathlab, the discriminant of X
lt
+ FX
3
+ GX2 + IIX + 1 is
(as the discriminant ofAX
2
+ 8X + C is 8
2
 4AC):
 27 Hit + 18 FGII'  4 F'H
3
 4 G
3
H
2
+ F
2
G
2
H
2
+ 1 * [144 GH
2
 6 F
2
11
2
 80 FG
2
H
+ 18 F
3
GH + 16 G
it
 4 p
2
G
3
]
+ 1
2
* , 192 Fli  128 G
2
+ 144 F
2
G  27 Fit]
256 I
ITEM 5:
In general, the discriminant of an nth degree polynomial is
n (ROOT  ROOT )2 ~ square of determinant whose i,i element
i<i i i
iI
is ROOT (The discriminant is the lowest degree symmetric
i
function of the roots which is 0 when any two are equal.)
ITEM 6 (Schroeppel):
If A is the first symmetric function of N variables
~ X + Y + Z + •••
and 8 is the second symmetric function of N variables
= XY + XZ + ••• + YZ + •••
(8 = sum of pairs), then X
2
+ y2 + Z2 + ••• = A
2
 28.
X
3
+ y
3
+ Z3 + •••• A
3
_ 3AB + 3C.
X
lt
+ ylt + Zit + •••• A
it
_ 4A
2
8 + 28
2
+ 4AC  4D.
ITEM 7 (Gosper):
If f(liX,Y •••• ) is the Ith symmetric function on N variables,
o if I > N
f(liX,Y, ••• ). I if I • 0
X*f(ll;Y.Z, ••• ) + f(ljy.Z •••• )
The 2enerating function is simply
N I
1: f(liX,Y.Z, ••• )*S • (I+XS)(I+YS)(l+ZS) •••
1=0
(NI variables)
\
ITEM 8 (Schroeppel):
Solutions to F(X) = X
3
 3BX
2
+ CX + 0 • 0 are
I
F' (B) IF(B) IF(B)
] 3
B  K * I
+
1[_]2
+ (
r 2 I 2 3
I
IF(B) IF(B) F' (D)
_ K
2
*
I
+
1[_]2
+ [
] 3
,
2 I 2 3
where K is one of the three cuberoots of 1:
1, ( 1+1=3) I 2, (  1I:J) I 2•
page 5
ITEM 9 (Schroeppel &Salamin):
If X ~ + BX
2
+ CX + D • 0, then 2X = I!f + I!! + I!!
Zl, Z2, Z3 are roots of Z3 + 2BZ
2
+ (B
2
• 4D)Z  C
2
• o.
The choices of square roots must satisfy (IZT) em) (1Z3) • c.
ITEM 10 (Salamin):
An easy solution of _4X
3
+ 3X  a • 0 is X = sin((arcsin a)/3).
In a similar manner, the general quintic can be solved exactly by
use of the elliptic modular function and its inverse.
See Davis: Intro. to Nonlinear Differential and Integral
Equations (Dover), p. 172. Unfortunately, there exists
~ 1 typo, since his eqs. (7) and (13) are inconsistent.
ITEM 11 (Salamin):
The following operations generate onetoone conformal mappings
of Euclidean Nspace onto itself.
1) Translate Nspace.
2) Expand Nspace about one of its points.
3) Stereographically project Nspace onto an Nsphere,
rotate the sphere, then project back onto Nspace.
PROBLEMS:
Show that all such conformal maps are generated by these
operations for any N. If the onetoone and onto conditions are
removed, then for N=2, conformal maps can be obtained by analytic
functions. Show that for N>2, no new conformal maps exist.
**************************************************
RECURRENCE RELATIONS
**************************************************
page 6
ITEM 12 (Gosper &Salamin):
"the Fast Fibonacci Transform" (motivation for next item)
Define mUltiplication on ordered pairs
(A,B){C,D)=(AC+AD+8C,AC+BD).
This is just (AX+B)*(CX+D) mod X
2
Xl, and so is associative,
etc. We note (A,B){1,0)=(A+8,A), which is the Fibonacci
N
iteration. Thus, (1,0) = (FIB(N),FI8(Nl», which can be
computed in log N steps by repeated squaring, for instance.
FIB(lS) is best computed using N = 16, thus pushing the minimal
binary addition chain counterexample to 30 (Liknaitzky). (See
Knuth vol. 2, p 398.) By the last formUla,
1
(1,0) • (FIB(1),FIB(2» = (1,1),
which, as a mUltiplier, backs up one Fibonacci step (further
complicating the addition chain question). Observing that
(1,0) 0 • (FIB(O) ,FIB(l» • (0,1)
= the (multiplicative) identity, equate it with scalar 1. Define
addition and scalar multiplication as with ordinary vectors.
1
(A,B) = (A,A+B)/(B
2
+ABA
2
),
so we can compute rational functions when the denominator isn't
zero. Now, by using power series and Newton's method, we can
(X,Y)
compute fractional Fibonaccis, and even e and 10g(X,Y).
If we start with (1,0) and square iteratively, the ratio will
converge to the larger root of x
2
_x_l (. the golden ratio)
about as rapidly as with Newton's method.
This method generalizes for other polynomial roots, being an
improvement of the method of Bernoulli and Whittaker (Rektorys,
Survey of Applicable Math., p 1172). For the general second
order recurrence, F{N+l) • XF(N) + YF(Nl), we have the
multiplication rule: (A,B)(C,D) = (AD+BC+XAC,BD+YAC).
1
Inverse: (A,B) • (A,XA+B)/(B
2
+XABYA
2
).
N
Two for the price of one: (F(l),YF(O»(l,O) • (F(N+I),YF(N».
\
ITEM 13 (Salamin &Gosper):
LINEAR RECURRENCE RELATIONS
Recurrence relation: A. C A + ••• + C A
k nl kl 0 kn
page 7
(1)
wi th A , ••• , A gi ven as ini tial values.
o nl
Consider the algebra with basis vectors
nl
XO, Xl, X
2
, ••• , X
n nl
and the identification X • C X + ••• + C Xo. (2)
nl 0
Thus if U, V, \'1 are vectors and W • U V, then componentwise
W = 1: T U V, (3)
i j,k ijk j k
is already a basis vector, so we get A •
L n Ln k
X • X X
• A (0 < m < n).
 m
can be done by kn+l applications of (2) or by
in (3) and then applying (3) O(log k) times.
k
n, X k <
• (C
nl
procedure yields A :
k
combination of the basis
k
Computation of X
computing the T's
PROOF: If 0 <

Suppose the procedure works for k < L.
nl Ln
X + ••• +C) X
o
Ll
= C X
nl
Ln
+ ••• + C X
o
m L
The procedure evaluates each X to A , so X evaluates to
m
C A +
• • •
+ C A
•
A
•
QED
nl Ll 0 Ln L
The same procedure will work for negative k using
1 nl n2
X
=
(X

C X

...

C )/C , (4)
nl 1 0
the unique vector which when multiplied by X yields
XO •
page 8 ,
Let (2) be F { X ) ~ O and V be the algebra constructed above.
Then V is a field iff F(X) is irreducible in the field of the
coefficients of V.
PROOF: Note that an element P of V is zero iff P(X)=O mod F(X).
If G(X) H(X) ~ F ( X ) , DEG G,II < DEG F, then the product of two
nonzero elements is zero and so V can't be a field.
Let P be an arbitrary nonzero element of V.
DEG{GCD(P,F» < DEG P < DEG F.
If F(X) is irreducible, then GCD(P,F)=l, so there exist
Q{X), R(X) such that Q{X) P(X) + R(X) F(X) • 1.
Then Q(X) peX)l mod F{X). Since P has an inverse, V is a field.
ITEM 14 (Gosper &Sala.in):
Yet another way to rapidly evaluate recurrences is to observe
that if F(N+l) = X*F(N) + V*F(Nll,
then F(N+2). (X
2
+2V) *F(N)  V *F(N2).
This rate doubling formula can be applied iteratively to compute
the Nth term in about log N steps, e.g., to get the 69th term
given terms 1 and 2, we form 1, 2, 3, 5, 9, 13, 21, 37, 69.
This sequence is computed from right to left by iteratively
sUbtracting half the largest possible power of 2. This is
sufficient to guarantee that some term further left will differ
from the left one by that same (halved) power of 2; e.g., 5,
••• ,21,37 have a common difference of 2, so that term 37 can be
found from term 5 and term 21 using the fourth application of the
rate doubling formula.
The rate tripling formula is F(N+3)  (X3+3XY)*F(N) + y3*F(N3).
For the Ktupling formula: F(N+K) ~ P(K)*F(N) + Q(K)*F(NK)
P(K+l) • X*P(K) + Y*P(Kl) (the same recurrence as F)
Q(K+l)  Y*Q(K)
pel) • X Q(l)  Y
P(O)  2 Q(O) • 1
1C
Q(K) • (Y)
1/2
pel)  2(Y) *T(K;X/I=4Y) where T(KiX) is the
Kth Chebychev polynomial  cos (K arccos X)
If A(I), BCI), and C(I) obey the same second order recurrence,
(I)
is independent of I and J, provided the inverse exists.
(This is true even if coefficients are not constant,
since any two independent sequences form a basis.)
page 9
Plugging in F and P as defined above, we get an expression for
the Nth term of the general second order recurrence in terms of
peN) and P{N+I):
[peN)
P{N+I)] [P{O)
P(I)
P(I) ] I [F(O) ]
P(2) F(I) = F (N) •
Setting X = Y = I, we get FIB(N) = (2P(N+I)P(N»/S, which is a
complex but otherwise square root free closed form. ( ~ . 2i)
With constant coefficients, the invariance (I) implies:
A ~ + J J
A
Q+I+K
A
Q+I+L
A
Q+J+K
A
Q+J+L
1
A
R+K
A
R+L
•
A
PQ+R
These matrix relations generalize directly
for Nth order recurrences.
ITEM IS (Chebychev):
The Nth Chebychev polynomial T(N) = T(N;x) = cos (N arccos x).
T{O) = I, T{ I) = x, T(N+I) • 2x T(N)  T(NI).
N IN
T(N;T(M» clearly • T(NM). x  2 T(N); whose degree is N2,
N
is the polynomial of degree < N which stays closest to x in the
IN
interval (1,1), deviating by at most 2 at the N+l places
where x = cos(K*n/N), K=O,I, ••• N.
N
Generating function: E T(N)*S = (lxS)/(12xS+S
2
).
First order (nonlinear) recurrence:
T(N+I) = xT(N)  {(I_x
2
.... )"'!""(I_t.... ("P'!'N)2y.
N
(T(N+I) ,T(N» = (T(I) ,T(O» (1,0) ,
where (A,B)(C,D) = (AD+BC+2xAC,BUAC).
ITEM 16: n n
I ( 1+ i x)

(1 i x)
tan (n arctan x)
=

*
n n
i ( 1+i x) + (Iix)
*********************************************
BOOLEAN ALGEBRA
*********************************************
page 10
ITEM 17 (Schroeppel):
Problem: Synthesize a given lo&ic function or set of functions
using the minimum number of twoinput AND gates. NOT gates are
assumed free. Feedback is not allowed. The given functions are
allowed to have X (don't care) entries for some values of the
variables. P XOR Q requires three AND gates. MAJORITY(P,Q,R)
requires 4 AND gates. "PQRS is a prime number" seems to need
seven gates. The hope is that the best Boolean networks for
functions might lead to the best algorithms.
ITEM 18 (Speciner):
number of monotonic increasing Boolean
N functions of N variables
o 2 (T, F)
1 3 (T, F, P)
2 6 (T, F, P, Q, P AN D Q, P 0 R Q)
3 20
4 168 • 8 * 3 * 7
5 7581 • 3 * 7 * 19
2
6 7,828,354 • 2 * 359 * 10903 (Ouchl)
N from 0 to 4 sugeest that a formula should exist, but 5 and 6
are discouraging. A difficult generalization: Given two partial
orderings, find the number of maps from one to the other that are
compatible with the ordering. A related puzzle: A partition of
N is a finite string of nonincreasing integers that add up to N.
Thus 7 3 3 2 1 1 1 is a partition of 18. Sometimes an infinite
string of zeros is extended to the right, filling a halfline.
The number of partitions of N, P{N), is a fairly well understood
function. m n m k
The generating function is t Pen) x a 1 I n (Ix) •
nO kl
A planar partition is like a partition, but the entries are in a
twodimensional array (the first quadrant) instead of a string.
Entries must be nonincreasing in both the x and y directions.
A planar partition of 34 would be: 1
3 1
322 1
7 6 431
Zeros fill out the unused portion of the quadrant. The number of
planar partitions of n, PL(n), is not a very well understood
function. m n m k k
The generating function is t PL(n) x • 1 I n (Ix) •
nO k=l
No simple proof of the generating function is known. Similarly,
one can define cubic partitions with entries in the first octant,
but nO one has been able to discover the generating function.
Some counts for cubic partitions and a discussion appear in
Knuth, Math. Camp. 1970 or so.
ITEM 19 (Schroeppel): page 11
The 2NOTs problem: Synthesize a black box which computes NOTA,
NOTB, and NOTC from A, B, and C, using an arbitrary number of
ANUs and ORs, but only 2 NOTs.
Clue: (Stopl Perhaps you would like to work on this awhile.)
Lemma: Functions synthesizable with one NOT are those where
the image of any upward path (through variable space) has at
most one decrease (that is, from T to F).
ITEM 20 (Roger Banks):
A Venn diagram for N variables where the shape representing each
variable is convex can be made by superimposing successive Mgons
(M = 2, 4, 8, ••• ), every other side of which has been pushed out
to the circumscribing circle. If you object to superimposed
boundaries, you may shrink the nested Mgons a very slight amount
which depends on N.
ITEM 21 (Schroeppel &Waltz):
PROBLEM: Cover the Execuport character raster completely with the
minimum number of characters. The three characters I, Hand'
works. Using capital letters only, the five characters B, I, H,
V and X is a minimal solution. Find a general method of solving
such problems.
ITEM 22 (Gasper):
PROBLEM: Given several binary numbers, how can one find a mask
with a minimal number of I bits, which when ANDed with each of
the original numbers preserves their distinctness from each
other? What about permuting bit positions for m ~ n i m u m numerical
spread, then taking the low several bits?
ITEM 23 (Schroeppel):
(A ANU B) + (A OR B) = A + B • (A XOR B) + 2(A AND B).
ITEM 24 (Minsky):
There exists a convex figure n congruent copies of which,
n
for any n, form a Venn diagram of 2 regions.
*********************************************
RANDOM NUMBERS
*********************************************
page 12
ITEM 2S (Schroeppel):
Random number generators, such as Rollo Silver's favorite,
which use SHIFTs and XORs, and give as values only some part
of their internal state, can be inverted. Also, the outputs
may often be used to obtain their total internal state.
For example, 2 consecutive values from Rollo's suffice
to allow prediction of its entire future. Rollo's is:
RANUOM: MOVE A,HI iregister A gets loaded with "high" word
MOVE B,LO iregister B gets loaded with "low" word
MOVEN A,LO iregister A gets stored in "low" word
LSHC A,3S. ishift the 72bit register AB left 3S
XORB A,HI ibitwise exclusiveor of A and HI
replaces both
This suggests a susceptibility to
analysis of mechanical code machines.
See LOOP DETECTOR item in FLOWS AND ITERATED FUNCTIONS section.
ITEM 26 (1 via Salamin):
A mathematically exact method of generating a Gaussian
distribution from a uniform distribution: let x be uniform on
[0,1] and y uniform on [O,2W], x and y independent. Calculate
r • Ilog x. Then r cos y and r sin yare two independent
Gaussian distributed random numbers.
ITEM 27 (Salamin):
PROBLEM: Generate random unit vectors in'Nspace uniform on the
unit sphere. SOLUTION: Generate N Gaussian random numbers and
normalize to unit length.
•••••••••••••••••••••••••••••••••••••••••••••
NUMBER THEORY, PRIMES, PROBABILITY
••••••••••••••••••••••••••••••••• * •••••••••••
page 13
ITEM 28 (Schroeppel):
After about 40 minutes of run time verify the absence of
any nontrivial factors less than 2
3
, the 125th Mcrsenne
number, 2
125
 I, was factored on January 5, 1971,
in 371 seconds run time as follows: 2
1
 1 •
31 • 601 • 1801 • 26 90898 06001 • 4710 88316 88795 06001.
John Brillhart at the University of Arizona had already
done this. M137 was factored on Frid,y, July 9, 1971 in
about 50 hours of computer 2
11
 1 ::I
32032 21559 64964 35569 • 54 39042 18360 02042 90159.
ITEM 29 (Schroeppel):
For a random number X, the probability of its largest prime
factor being (!) greater than If is In 2.
(2) less than rx is about 4.86\. This suggests
that similar probabilities are independent of X: for instance,
the probability that the largest prime factor of X is less than
2tx may be a fraction independent of the size of X.
RELEVANT DATA:
([ ] denote the expected value of adjacent entries.)
2.4
10
1.7
:52 ::I 10
CUMULATIVE SUM OF COUNT
10018
2820
402 [487]
48 :252 ::I
8
1
o
COUNT
7198 [6944]
2466
354
40
7
1
o
RANGE
10
12
TO 10'
10' TO 10"
10" TO 10
3
10
3
TO 252
252 TO 100
100 TO 52
51 TO 1
where:
"COUNT" is the number of numbers between 10
12
+ 1 and
10
12
+ 10018 whose largest factor is in "RANGE".
The number of primes in 10
1
+ 1 to 10
12
+ 10018 is 335; the
prime number theorem predicts 363 in this range. This is
relevant to Knuth's discussion of Legendre's factoring method,
vol. 2, p. 351354.
ITEM 30 (Schroeppe1):
Twin primes:
166,666,666,667 • (10
12
+ 2)/6
166,666,666,669
The number 166,666,666,666,667 is prime, but
166,666,666,666,669 is not.
The primes which bracket 10
12
are 10
12
+ 39 and 10
12
 11.
The primes which bracket 10
15
are 10
15
+ 37 and 10
15
 11.
The number 23,333,333,333 is
Various primes, using T ::I 10
1
, are:
40T + 1, 62.5T + 1, 200T  3, SOOT  1, SOOT  7.
ITEM 31 (Schrocppel): N page 14
Ramanujan's problem of solutions to 2  7 • X
2
was searched
to about N I: l O ~ o ; only his solutions (N • 3, 4, 5, 7" 15) were
found. It has recently been proven that these are the only ones.
Another Ramanujan problem: Find all solutions of nJ + 1 I: x
2
•
ITEM 32 (Schroeppel):
Take a random real number and raise it to large powers; we expect
the fraction part to be uniformly distributed. Some exceptions:
1  ~ I: (1 + 1!)/2
2 all 1 < X < 1
3 12 (half are integers, other half
are probably uniformly distributed)
4 1 + 12  Proof:
N N
(1 + I!) + (1  11) • integer (by induction);
N
the (1  I!) goes to zero.
5 2 + I ~  similar to 1 + I!
6 any algebraic number whose conjugates
are all inside the unit circle
Now, 3 + I! is suspicious; it looks nonuniform, and seems to
have a cluster point at zero. PROBLEM: Is it nonuniform?
ITEM 33 (Schroeppel):
Numbers whose right digit can be repeatedly removed and
they are still prime: CONJECTURE: There are a finite
number of them in any radix. In decimal there arc 51,
the longest being 1,979,339,333 and 1,979,339,339.
ITEM 34 (Schroeppel):
PROBLEM: Can every positive integer be expressed
in terms of 3 and the operations factorial and
/
integer square root? E.g., 5 • 11"31T.
ITEM 35 (Schroeppel):
Take as many numbers as possible from 1 to N such that no 3 are
in arithmetic progression. CONJECTURE: As N + ~ , the
(In 2)/(ln 3)
uensity of such sets approaches zero, probably like N
XX.XX is a known solution for N • 5
XX.XX•••• XX.XX is a known solution for N • 14
Conjecture that XX.XX just keeps getting copied. If the
(In 2)/(ln 3)
N can be proved, it follows that there are
infinitely many primes PI, P2, P3 in arithmetic progression,
(In 2)/(ln 3)
since primes are much more common than N
ITEM 36 (Schroeppel):
PROBLEM: How many squares have no zeros
in their decimal expression? Ternary?
ITEM 37 (Gosper):
The number of n digit strings base B in which all 8
at least once is just the Bth forward difference at
powers of 0, 1, •••• E.g., for n a 4:
o 1 16 81 256 625
1 15 65 175 369
14 50 110 194
36 60 84
24 24
o
page 15
digits occur
o of the nth
" ' ~ , .•
so there are 14 (a 2 ~  2 ) such 4bit strings, 36 such 4digit
ternary strings, 24 (a 41) such quaternary, and 0 for all higher
bases. 27 (= 10e?) random decimal digits are required before it
is more likely than not that every digit has occurred; with 50
digits the likelihood is 95%.
ITEM 38 (Fredkin):
By the binomial theorem, the bth forward difference at 0 of
b
the 0, 1, 2, ••• powers of n is (nl) • E.g., for n • 4:
1 4 16 64 256
3 12 48 192
9 36 144
27 108
81
In fact, any straight line with rational slope through such an
array will always go through a geometric sequence with common
a b
ratio of the form n (n·l). In the above, east by southeast
knight's moves give the powers of 12: 1, 12, 144, ••••
ITEM 39 (Schutzenbcrger):
PROBLEM: Using N digits, construct a string of digits which
at no time has any segment appearing consecutively twice.
N = 2 + finite maximum string
N = 10 + known infinite
Uetermine maximum string length for N • 3.
SUBPROBLEM: How many sequences exist of any particular length?
ITEM 40 (Gosper):
The variance of a pseudoGaussian distributed random variable
made by adding T independent, uniformly distributed random
inteier variables which range from 0 to N1, inclusive, is
T((N  1)/12).
ITEM 41 (Salamin):
There are exactly 23000 primes less than 2
18
•
page 16
ITEM 42 (Gosper):
To show that
N N+l L N+l L
E (BINOMIAL N+L L)*(X (IX) + (IX) X) • 1
LO
set N to 20 and observe that it is the probability that one or
the other player wins at pingpong. (X = probability of first
player gaining one point, L • score, deuce rUle
irrelevant.) If this seems silly, try more conventional methods.
PROBLEM: If somehow you determine A should spot B 6 points for
their probabilities of winning to be equal, and B should spot C
9 points, how much should A aive C?
ITEM 43 (Schroeppel):
Let (A,B,C••• ) be the mUltinomial coefficient
(A+ B+C••• ) ! / AI B1CI •••
This is equal modulo the prime p to
(AO,BO,CO ••• )(Al,Bl,Cl ••• )(A2,B2,C2 ••• ) •••
where AJ is the Jth from the right digit of A base p.
Thus (BINOMIAL A+B A) mod 2 is 0 iff (AND A B) is not.
The exponent of the largest power of p which divides (A,B,C••• )
is equal to the sum of all the carries when the base p
expressions for A, B, C, ••• are added up.
ITEM 44 (Gosper):
Recurrences for mUltinomial coefficients:
(A,B,C, ••• ) • (A+B,C, ••• )(A,B) • (A+B+C, ••• )(A,B,C) ••••
PROBLEM 45 (Gosper):
Take a unit step at some heading (angle).
Uouble the angle, step again. Redouble, step, etc.
For what initial heading angles is your locus bounded?
PARTIAL ANSWER (Schroeppel, Gosper): When the initial angle is
a rational mUltiple of n, it seems that your locus is bounded
(in fact, eventually periodic) iff the denominator contains as a
factor the square of an odd prime other than 1093 and 3511, which
must occur at least cubed. (This is related to the fact that
1093 and 3511 are the only known primes satisfying
P 2
2 = 2 mod P ). But a denominator of 171 = 9 * 19 never loops,
probably because 9 divides Similarly for 9009 and 2525.
Can someone construct an irrational mUltiple of n with a bounded
lOCUS? 00 such angles form a set of measure zero in the reals,
even though the "measure" in the rationals is about .155?
About .155 = the fraction of rationals with denominators
containing odd primes squared • 1  IT over odd primes of
1  l/P(P + 1). 'This product • .84533064 ± a smidgen, and
is not, alas, Ii71 ARCERF(1/4) • .84534756. This errs by 16
times the correction factor one expects for 1093 and 3511, and is
not even salvaged by the hypothesis that all primes> a million
satisfy the congruence. It might, however, be salvaged by
quantities like 171.
ITEM 46 (Schroeppel): page 17
The most probable suit distribution in bridge hands is 4432,
as compared to 4333, which is the most evenly distributed.
This is because the world likes to have unequal numbers:
a thermodynamic effect saying things will not be in the state of
lowest energy, but in the state of lowest disordered energy.
ITEM 47 (Beeler):
The Fibonacci series modulo P has been studied. This series has
a cycle length L and within this cycle has subcycles which are
bounded by zero members.
The length of powers of primes seems to be
powerl
L = (length of prime) * prime
The length of products of powers of primes seems to be
L • least common mUltiple of lengths of powers of primes
which are factors.
There can be only 1, 2 or 4 subcycles in the cycle of a prime.
Primes with 1 subcycle seem to have lengths
L a (prime  l)/N, N covering all integers.
Primes with 2 subcycles seem to have lengths
M
L • (prime  (1) )/M, M covering
all integers except of form 10 K + S.
Primes with 4 subcycles seem to always be of form 4 K + 1,
and seem to have lengths
L • 2 (prime + l)/R or (prime  l)/S,
R covering all integers ~ f form 10 K + 1, 3, 7 or 9;
S covering all integers.
At Schroeppel's suggestion, the primes have been separated
mod 40, which usually determines their number of sUbcycles:
PRIME mod 40 SUBCYCLES
1, 9 usually 2, occasionally 1 or 4 (about equally)
3, 7, 23, 27 2
11, 19, 31, 39 1
13, 17, 33, 37 4
21, 29 1 or 4 (about equally)
2 (only 2) 1
5 (only 5) 4
Attention was directed to primes which are 1 or 9 mod 40 but have
1 or 4 subcycles. 25 X
2
+ 16 y
2
seems to express those which are
9 mod 40; (10 X ± 1)2 + 400 y2 seems to express those which
are 1 mod 40. PROBLEM: Can some of the "seems" above be proved?
Also, can a general test be made which will predict exact length
for any number?
ITEM 48 (Gosper, Schroeppel): .
I
A point of the 2 dimensional lattice is called visible iff its
coordinates are relatively prime. The invisible 2 by 2 square
with smallest X has its near corner on (14,20).
(I.e., (14,20), (15,20), (14,21), and (15,21) are all invisible.)
The corresponding 3 by 3 is at (104,6200). By the Chinese
remainder theorem, there exist invisible sets of every finite
shape. Excellent reference: Amer. Math. Monthly, May '71, p487.
page 18
"magic hexagon" of side 3:
First discovered hy Clifford W. Adams.
who worked on the problem from 1910.
9 In 1957. he found a solution.
(Sec Aug. 1963 Sci. Am., Math. Games.)
Other length sides are impossible.
unique
18
1 11
6
8 14
15
5
4
13
2
19
16
12
10
ITEM 49:
There is a
3 17
7
ITEM 50 (Schroeppel):
There is no magic cube of order 4.
Proof: Let K em 130) be the sum of a row.
Lemma 1: In a magic square of order
four. the sum of the corners is K.
Proof: Add together each edge of the square and the two
diagonals. This covers the square entirely, and each corner
twice again. This adds to 6K, so twice the corner sum is 2K.
Lemma 2: In a magic cube of order 4, the sum of any
two corners connected by an edge of the cube is K/2.
Proof: Call the corners a and b. Let c, d and e, f be the
corners of any two edges of the cube parallel to abe Then
abcu, abef, and cdef are all the corners of magic squares. So
a+b+c+d + a+b+e+f + c+d+e+f m 3K; a.b+c+d+e+f m 3K/2; a+b • K/2.
Proof of magic cube impossibility: Consider a corner x.
There are three corners connected by an edge to x.
Each must have value K/2  x. QED
ITEM 51 (Schroeppel):
By similar reasoning, the center of an order 5 magic cube must
be 63 = K/5. COROLLARY: There is no magic tesseract of order 5.
ITEM 52 (Salamin):
The probability that two random integers are relatively prime is
6/n
2
• PSEUDOPROOF: Let X be the probability. Let S be the set
of points in the integer lattice whose. coordinates are relatively
prime, so that S occupies a fraction X of the lattice points.
Let S(U) be the set of points whose coordinates have a GCD of D.
S(O) is S expanded by a factor of D from the origin. So S(D)
occupies a fraction X/v
2
of the lattice, or the probability that
two random integers have a GCD of D is X/0
2
• If D unequals D',
then 5(0) intersect S(Dt) is empt{, and union of all S(O) is the
entire lattice. Therefore X*(l/1 +1/2
2
+1/3
2
+••• ) • I,
so X • 6/w
2
• This argument is not rigorous, but can be made so.
ITEM 53 (Salamin):
The probability that N numbers will lack
a Pth power common divisor is l/t(NP).
ITEM 54 (Salamin & Gasper):
The probability that a random rational number
has an even denominator is 1/3.
ITEM 5S (Schroeppel): GAUSSIAN INTEGERS
See following illustrations; also PI section.
Figure lea). This diagram is to substantiate the claim
that every Gaussian integer has a unique bit combination.
l{unning through bit combinations 0,1,10,11, ••• , the
uiagram is a map of values, radix iI. The origin is circled;
the dot is at the 127th combination (1111111 = 2 + Si),
which is merely the last point drawn.
·
· :
·•
•
I
I
•
•
I
i
•
f
•
•
•
•
•
,..... . "··7
! t .' :
,0 • .':
. .' .
......_...J .....1. ......1 ','
. .. .'
'. :
.•..•, ••' I
r··a.. f
• ..... , •• , a .......
A
.,.· · .. · ........ ·
...... • • "...... I •
I' .... • ........1 , __L. <116::..& ..__..
.. /' : .,
,. .
....... . ....
, . i ' ..
I r·
/' 1 i i
L_.J l .
Figure l{b). As lea), but radix i+l. Large circle is origin.
iJashes indicate continuity of curve at confusing places.
Uotted curve is with an infinity of ones to the left
(big dot = ••• 1111 = i). The solid and dotted curves are
symmetrical about the point marked with a small circle.

1
li i
+1 +i
+1
+li
Figure 2. Similar to lea), but showing fraction parts as well.
Reprinted by special permission from Knuth, The Art of
c o m ~ u t e r Programming, Volume 2, Seminumerical Algorithms,
196 , AddisonWesley, Reading, Mass.
ITEM 56 (Beeler): page 22
The "length" of an Ndigit decimal number is defined as the
number of times one must iteratively form the product of its
digits until one obtains a onedigit product (see Technology
Review Puzzle Corner, December 1969 and April 1970). For various
N, the following shows the maximum "length", as well as how many
distinct numbers (permutation groups of N digits) there are:
N MAX L DISTINCT
2 4 54
3 5 219
4 6 714
5 7 2,001
6 7 5,004
7 8 11,439
8 9 24,309
9 9 48,619
10 10 92,377
11 10 167,959
12 10 293,929
Also, for N • 10, 11 and 12, a tendency for there to be many
fewer numbers of "length" • 7 is noted. Other than this, the
frequency of numbers of any given N, through N • 12, decreases
with increasing "length". CONJECTURE (Schroeppel): No L > 10.
ITEM 57 (Beeler, Gosper):
There is at least one zero in the decimal expression of each
power of 2 between 2
86
• 77,371,252,455,336,267,181,195,264
and where the program was stopped. If diaits of
such powers were random, the that there is another
zeroless power would be about Assuming there aren't
any then raises the question:
How many final nonzero digits can a power of two have?
ANSWER (Schroeppel): Arbitrarily many. If we look at the last
n digits of consecutive powers of 2, we see:
a) None end in zero.
n
b) After the nth, they are all mUltiples of 2 •
nl
c) They get into a loop of length 4 * 5 •
(Because 2 is a primitive root of'powers of 5.)
nl n
But there are only 4 * 5 multiples of 2 which don't end with
n
zero and are < 10 , so we will see them all. In particular, we
will see the one composed entirely of l's and 2's, which ends
••• 11112111211111212122112.
ITEM 58 (Fredkin):
3
3
+ 4
3
+ 53 • 6
3
•
ITEM S9 (Schroeppe1):
91038 90995 89338 00226 07743 74008 17871 09376
2
•
82880 83126 51085 58711 66119 71699 91017 17324
91038 90995 89338 00226 07743 74008 17871 09376
ITEM 60 (Beeler):
If S • the sum of all integers which exactly divide N,
including 1 and N, then "perfect numbers" are S • 2 N;
the first three numbers which are S • 3 N are:
120 • 2
3
* 3 * 5 = 1111000 base 2
672 = 2
5
* 3 * 7 = 1010100000 base 2
523,776 = 2' * 3 * 11 * 31 = 1111111111000000000 base 2
page 23
ITEM 61 (Root):
Consider iteratively forming the sum of the factors (including 1
but not N) of a number N. This process may loop; "perfect
numbers" are those whose loop is one member, N. For example,
N • 28 = 1 + 2 + 4 + 7 + 14. An example of a twomember loop is:
sum of factors of 220 • 284
sum of factors of 284 • 220
Twomember loops are called "amicable pairs."
A program to search for loops of length> 2, all of whose.
members are < 6,600,000,000 found the known loops of length 5
(lowest member is 12496) and 28 (lowest member is 14316),
but also 13 loops of 4 members (lowest member is given):
1,264,460 • 2
2
* 5 * 17 * 3,719
2,115,324 • 2
2
* 3
2
* 67 * 877
2,784,580 • 2
2
* 5 * 29 * 4,801
4,938,136 • 2
3
* 7 * 109 * 809
7,169,104 • 2' * 17 * 26,357
18,048,976 = 2' * 11 * 102,551
18,656,380 • 2
2
* 5 * 932,819
46,722,700 • 2
2
* 52 * 47 * 9,941
81,128,632 • 2
3
* 13 * 19 * 41,057
174,277,820 • 2
2
* 5 * 29 * 487 * 617
209,524,210 • 2 * 5 * 7 * 19 * 263 * 599
330,003,580 • 2
2
* 5 * 16,500,179
498,215,416 = 2
3
* 19 * 47 * 69,739
ITEM 62 (Speciner): page 24
The first four perfect numbers are 6, 28. 496, 8128.
Twomember loops (amicable pairs) are:
220 ++ 284
1184 ++ 1210
2620 ++ 2924
5020 ++ 5564
6232 ++ 6368
10744 ++ 10856
12285 ++ 14595
17296 ++ 18416
63020 ++ 76084
66928 ++ 66992
67095 ++ 71145
69615 ++ 87633
79750 ++ 88730
100485 ++ 124155
122265 ++ 139815
122368 ++ 123152
141644 ++ 153176
142310 ++ 168730
171856 ++ 176336
176272 ++ 180848
185368 ++ 203432
196724 ++ 202444
(Exhaustive to smaller member ~ 196724 and larger member < 2
35
.)
A prime decade is where N+1, N+3. N+7 and N+9 are all prime.
The first occurrence of two prime decades wi th the 'theoretical
minimum separation is N • 1006300 and N • 1006330. The 33Sth
prime decade is N • 2342770. There are 172400 primes < 2342770.
ITEM 63 (Schroeppe1, etc.):
The joys of 239 are as follows:
n • 16 arctan (1/5)  4 arctan (1/239),
which is related to the fact that 2 * 1 3 ~ • 1 • 239
2
,
which is why 239/169 is an approximant (the 7th) of 12.
arctan (1/239) • arctan (1/70)  arctan (1/99)
• arctan (1/408) + arctan (1/577)
239 needs 4 squares (the maximum) to express it.
239 needs 9 cubes (the maximum, shared only with 23) to express it.
239 needs 19 fourth powers (the maximum) to express it.
(Although 239 doesn't need the maximum number of fifth powers.)
1/239 •• 00418410041841 •••• which is related to the fact that
1,111,111 • 239 * 4,649.
The 239th Mersenne number, 2
23
'  1, is known composite,
but no factors are known.
239 • 11101111 base 2.
239 • 22212 base 3.
239 • 3233 base 4.
There are 239 frimes < 1500.
K239 is Mozart s only work for 2 orchestras.
Guess what memo this is.
And 239 is prime, of course.
_.
* * * * * * * * * ~ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
AUTOMAT A THE ORY
*********************************************
page 2S
N in one of the counters, cannot
ITEM 64 (Schroeppel):
A 2counter machine, given
N
generate 2 •
rediscovered
Proven Saturday, Sept. 26, 1970. (Independently
by Frances Yao). But (Minsky, Liknaitzky), given
N
N 2
2 , it can generate 2 (A 2counter machine has a fixed,
finite program containing only the instructions "ADD 1",
"SUBTRACT 1", "JUMP IF NOT ZERO", which refer to either of two
unlimited counters. Such machines are known universal, but
(due to the above) they must have specially encoded inputs.)
ITEM 6S (Schroeppel):
What effort is required to compute n(X), .7
the number of primes < X1 Shanks and Brillhart claim about X
ITEM 66 (Gosper):
See spacefilling curve machine item in TOPOLOGY section.
*********************************************
GAMES
*********************************************
page 26
ITEM 67 (Schroeppel):
Regarding "poker coins" game" whose rules are:
1 a player throws N coins;
he then puts one or more aside and rethrows the rest
2 this throwing is repeated until he no longer has any to throw
3 highest score (dice) or maximum number of heads (coins) wins
For poker coins, the optimal strategy, with N coins thrown" is:
Z • number of zeros (tails)
if Z • 0, quit
if Z • 1, throw the zero
if 1 < Z < N, save one one" throw the other Nl coins
if Z • N" save a zero" throw the other Nl coins
The optimal strategy for poker dice is hairier.
ITEM 68 (Schroeppel):
PROBLEM: Solve Blackout, a game as follows: Two players
alternate placing X's on a rectangular grid. No two X's may
appear adjacent along a side or across the diagonal at a corner.
The last X wins. Some theory: The "indicator" for a position is:
make all possible moves from the given position.
Evaluate the indicator of each of these successor positions.
The indicator of the first position is the smallest number which
is not the indicator of a successor position. The indicator of
the null position is o. The second player wins iff the indicator
is o. Example of calculating an indicator for the 3 x 3 board:
There are 3 distinct moves possible  corner, side" center.
Playing in the center leaves the null position, indicator o.
Playing on the side leaves a 1 x 3 line, indicator 2. Playing in
the corner leaves a 3 x 3 L, indicator 3. The smallest number
not appearing in our list is 1, so the indicator of a 3 x 3
square is 1. For two boards (not touching) played
simultaneously, the indicator is the XOR of the indicators for
the separate boards. For any position, the indicator is ~ the
maximum game length.
PROBLEM: Find some nonexponential way to compute the indicator
of a given position. For lines, a period of 34 is entered after
the line is about 80 long. For Ls: if one leg is held fixed, the
indicator Cas a function of the other leg) seems to become
periodic with period 34. The time to enter the period becomes
greater as the fixed leg increases.
On an odd x odd board, the 1st player wins.
On a 4 x N board, the 2nd player wins.
On a 6 x 6 board, the 1st player wins by playing
at the center of one quarter.
This indicator analysis is similar for many other
takeaway games" such as Nim.
ITEM 69:
Berlekamp of Bell Labs has done the 9 squares
(16 dots) Dots game; the 2nd player wins.
, ,.
ITEM 70: page 27
A neat chess problem, swiped from "Chess for Fun and Chess for
8lood", by Edward Lasker: white: pawns at QN3 and KN7, knight at
QN4, bishop at K87, king at Q82; black: pawn at QN3, king at QR6.
White mates in three moves.
ITEM 71 (Beeler):
There is only one distinct solution to the commercial
"Instant Insanity" coloredfaces cubes puzzle, which is
how it comes packed. (Independently discovered by Dave Plumer.)
Mike Paterson has discovered a clever way to solve the puzzle.
ITEM 72 (Beeler):
A windowdice game is as follows:
1 The player starts with each of nine windows open,
showing the digits 1  9.
2 Roll two dice.
¥ 3 Cover up any digits whose sum is the sum on the dice.
4 Iterate throwing and closing windows until the equality of sums
is impossible.
5 Your score is the total of closed windows (highest wins).
An optimum strategy has been tabulated. Usually it is best
to take the largest digits possible, but not always;
it also depends critically on the remaining numbers.
ITEM 73 (8eeler):
Sim is a game where two players alternately draw lines connecting
six dots. The first person to form a triangle in his color
loses. The second player can always win, and whether his first
move connects with the first player's first move doesn't matter;
from there on, however, the strategy branches to a relatively
gruesome degree.
PROBLEM: 6 dots is minimum to ensure no stalemate with 2 players;
how many dots are required with 3 players?
ITEM 74 (Beeler):
The 4 x 4 game of Nim, also known as Tactix, is a win
for the second player, who on his first move can reply
centersymmetrically unless the first player's first move
was Bl and B2 (analyzed on RLE PDPI).
ITEM 7S (Gosper, Brown, Rayfield): page 28
A 1963 PDPl computer proaram gave us some interesting data on
the traditional game of peg sOlitaire (33 holes in a plus shape).
A B C
D E F
G H I J K L M
N P
Q • 5 T U
V W X Y Z I 2
3 4 S
6 7 8
From the starting position, complement the board. This is the
ending position. Now from the starting position, make one move,
then complement the board. This is a position one move from a
win. By induction, you can win from the complement of any
position you can reach. Thus every successful game has a dual
game whose positions are the complements of the original ones.
This debunks the heuristic of emptying the arms of the plus first
and then cleaning up the middle, because there are just as many
dual games which empty out the middle first and then the arms!
The program found one counterintuitive win which at one point
left the center nine empty but had ten in the arms.
• B •
DE.
• • • • • • •
• P • •
V W • •
• T U
• 4 •
• 7 •
By dualizing and permuting a solution from the folklore,
we found a similar winning position with 20.
(T Q 4 R 1 L J II \'1 Y MJ) leaves:
A 0 C
0 E F
G H
•
L
•
N
• •
· ·
. U
V W
• • •
1 2
3
·
5
6 7 8
then (8 V A C/O 2 6 G M F/K 5 8 I Y V 3 Q A II E).
page 29
Another useful observation is that the pegs and their orieinal
hole positions fall into four equivalence classes in which they
stay throughout the game. Thus the four pegs which can reach the
center on the first move are the only ones that ever can.
Similarly, the peg jumped over on the last move must be in one of
the two classes of eight members which get reduced on the first
move. The program's main heuristic was to reduce the larger
classes first.
a b a
c d c
a b a b a b a
c d c . c d c
a b a b a b a
c d c
a b a
With its heuristics disabled, the program simply scanned
lexicographically (left to right in the inner loop, then top to
bottom) for a peg which could move. At one point, there is a peg
which can move two ways; it chose west. Twelve moves from the
end it stopped and went into an exhaustive tree search, in which
it found two basically different wins. (Try it yourself.)
· . .
· .
• • •
• • K
• • Q • • • •
• • X Y Z 1 2
345
678
ITEM 76 (Beeler):
Triangular HiQ (or peg solitaire) is IS pegs in a triangle.
One peg is removed, and thereafter pegs jump others,
which are removed. With pegs numbered 1 at the top,
2 and 3 in the next row, etc.,
REMOVE CAN END WITH ONLY THE PEG
1 1, 7 = 10, 13
2 2, 6, 11, 14
4 3 a 12, 4, 9, 15
5 13
Removing only one, no way exists to get to either 1 + 11 + 15
(tips) or 4 + 6 + 13 (centers of sides). Starting with peg 1
removed, 3,016 positions are attainable (not turning board); the
sum of ways to get to each of these is 10,306. An example is:
remove peg 1, then jump as follows: 6, 13, 10, 1, 2, 11, 14/13,
6, 12/13, 15, 7/4, 13, 4; leaving p ~ g 1.
*****.*.*******.**.*.* •••••••••• ****** •••• **.
PROPOSED COMPUTER PROGRAMS, IN ORDER OF
INCREASING RUNNING TIME (Schroeppel)
**********************.* •••••• *••••••••••••••
page 30
PROBLEM 71: Count the polyominos up to, say, order 20.
From Applied Combinatorial Mathematics, pages 201 and 213:
ORUER E. II. NOT ENCLOSING HOLES
III
211
322
455
5 12 12
6 35 35
7 108 107
8 369 363
9 1285 1248
10 4655 4271
11 17073
12 63600
13 238591
14 901971
15 3426576
16 13079255
17 50107911
18 192622052
The order 13 through 18 data is from Computers in Number Theory,
1971, Atkin &Birch, ed., Academic Press, which has not been
independently checked. It also gives bounds 3.72 < limit as
N goes to infinity of Nth root of number of po1yominos of order N
(including those enclosing holes) < 4.5. Also an asymptotic
formula for the number of polyominos:
N .98±.02
4.06 • (N ) * constant. Polyominos may he constructed
in 3space (Somalike pieces) or higher dimensions; a curious
thought is into how many dimensions does the average, say,
20omino extend?
PROBLEM 78: Solve "minichess", chess played on :1 5 x 5 board
where each side has lost the king's rook, knight, bishop,
and 3 pawns, and the opponents are shoved closer together
(1 empty row intervening, no double pawn moves).
PROBLEM 79: Solve the tiger puzzle, a sliding block puzzle
mentioned in Scientific American February 1964, pages 122  130.
PROBLEM 80: Find smallest squared square (a square composed
entirely of smaller, unequal squares). Smallest known has 24
small squares (Martin Gardner's Scientific American Book,
vol. 2, page 206). See also the following two illustrations.
Recently, someone constructed a squared rectangle with sides
in the ratio 1:2. It contains 1353 squares.
39
55
81
16
~ 14
44
~ 5
3
1
18
20
56
38
30
51
31
29
8
64
2
43
33 35
Figure 3(a). The smallest known '(in 1961, and
yet today as far as we know) squared square.
Reprinted by special permission from Martin Gardner,
The Second Scientific American Book of Mathematical Puzzles
and Uiversions, 1961, Simon and Schuster, New York, New York.
,
\)0
0
00
tP
S
\0
\.t'
()
....D
N
()
N
N
'6
0
N
0"
.......
"
0
•

.
.......
fllC
\on
I'"
0
\n
r.
fI\
\n
0
\n
\n ...
N
"
0 "
'eIO

.
....
......
11ft fP
'"

......
'"
cr
,...
'"
tt\
"
",
"
,....
I(
I' 0
:t
....
.....
.
0 e.I
:l
'll
\C\
0
\6
lP
...
tf) ......

$
" ......
...
::to .
.
.....
cr
,..
.
..
:r
tf'
0
,...
0
:r

c( ..
tl
flO
M
er
r

Figure 3(b). A squared rectangle found by Schroeppel
using "String Handling Interpretive Translator,"a string
processing language written by Samson. Sides are 884808
= 2
3
* 3
2
* 12289 and 752225 = 52 * 30089; semiperimeter
is 1637033 = 419 * 3907. This has 28 squares, which is
more than most published squared rectangles.
page 33
PROBLEM 81: Count the magic squares of order 5. There are
about 320 million, not counting rotations and reflections.
PROBLEM 82: List (that is, count) the semigroups of 7 clements;
also, the groups of 256 clements (estimated: 11000).
PR08LEM 83 (Gosper): Compute the integervalued step function
F(R), O<R<l, the number of circles of radius R which fit into a
unit circle. F skips the value 6, and probably 18. How many and
how big are the gaps in the range of F? What happens in n
dimensions (including n = infinity)?
PROBLEM 84: Solve pentominos on an 8 x 8 checkerboard game(s).
Rules:
1 The checkerboard is for aid in orienting only;
black and white are the same.
2 The two players may each have a full complement of 12
pentominos, or they may "choose up" their half of one set.
3 Players alternate placing pentominos on the board.
Pentominos must not overlap.
4 The last player to place a pentomino wins.
PROBLEM 85: With regard to dissection theorems, the following are
known: a triangle into a square, 4 pieces (proven minimal); a
pentagon into a square, 6 pieces (best known) etc. ("Geometric
Uissections" by Harry Lindgreen, Scientific American November
~  1961). A program can probably check t h ~ known dissections for
minimalityl See following illustration, for example.
Figure 4. A surprising square ++ hexagon dissection,
adapted from page 164 of the November, 1961 issue of Scientific
American, which see for further diagrams and discussion.
page 35
PROBLEM 86: Find the number of domino coverings for various
objects. For example, an asymptotic formula is known for
rectangles; also, on a square board, if side mod 4 • 0, coverings
appears to be a square; on a square board, if side 4 D 2,
coverings appears to be twice a square. See Applied Comb. Math.,
chap. 4.44.6, p. 105  121. Article by E. W. Montroll.
PROBLEM 87: Analyze giveaway chess, which is as follows:
1 captures must be made,
although you can choose which capture to make
2 pawns Blust be promoted to queens
3 king is just another piece
4 player to give away all pieces first wins
PROBLEM 88: Analyze "escalation chess", where white gets 1 move,
black 2, white 3, etc. If a player is in check, he must get out
of check on his first move. lie may not move into check. Taking
your opponent's king is verboten, but you can pile up triple
checks, etc. A player is checkmated if he can't get his king out
of check on his first move.
PROBLEM 89: In the game "4 pawns", black has 4 pawns, a king, and
two moves to white's one. Prove the pawns win. The object in
this game is to capture the king. Black is allowed to move
through check.
PROBLEM 90: Solve Scarne's game, "Tecko," which is played on a
5 x 5 board by two players who alternate placing, one at a
their 4 counters each, after which the counters are moved around
(including diagonally). 4 in a row or square wins.
PROBLEM 91: Solve "fiveinarow" on an infinite board.
PROBLEM 92: Solve TicTacToe on a 4 x 4 x 4 board.
The consensus is a win for the first player, but it's unproven.
The first player wins on 4 x 4 x 4 x 4.
PROBLEM 93: Solve checkers. There are about 10
12
positions.
(Computing time currently estimated (Schroeppel) at 1 year).
Programs below this line are considered unfeasible.
PROBLEM 94: Solve Hex on large boards (11 to 23 on a side);
through order 7 have been analyzed by hand. There is a
proof that in games where having an extra move can never
(repeat: never) hurt you, the worst the first player can
be forced to do is draw. Thus, with lIex, in which there
is no draw, the first player can always win.
PR08LEM 95: Solve chess. There are about possible
positions; in most of them, one side is hopelessly lost.
PROBLEM 96: Solve Go. About 10
170
positions.
*********************************************
CONTINUED FRACTIONS
*********************************************
page 36
ITEM 97 (Schroeppel):
Simple proofs that certain continued fractions are 12, IJ, etc.
Proof for 12:
X • (1, 2, 2, 2, ••• l
(Xl)(X+l) • [0, 2, 2, 2, ••• l * [2, 2. 2, 2, ••• l • 1
X
2
 1 • 1
X • I!
Proof for I!:
V • [1, 1, 2, 1, 2, ••• l
(V + 1)(Y  1) :I [2, 1, 2, 1, 2, ••• l * [0, 1, 2, 1, 2, ••• l
• 2 * [I, 2, 1, 2, I, ••• l * [0, 1, 2, 1, 2, ••• l • 2
VI  1 • 2
V I: IJ
Similar proofs exist for IS and 16; but 11 is hairy.
ITEM 98 (Schroeppe1):
The continued fraction expansion of the positive minimum
of the factorial function (about 0.46) is
[0, 2, 6, 63, 135, 1, 1, I, 1, 4, 1, 43, ••• l.
ITEM 99 (Schroeppe1):
The value of a continued fraction with partial quotients
increasing in arithmetic progression is
I (2/D)
A/D
[A+D, A+20, A+3D, ••• l •
I (2/0)
l+(A/D)
where the I's are Bessel functions.
I (2)
o
A special case is [1, 2, 3, 4, ••• l •
I (2)
1
ITEM 100 (Perron):
11
n (1 + 1/Ak) •
kl
1 +
1
Al 
(AI + l)Al
Al+A2+1 
(A2 + 1)A2
A2+A3+ 1 
• • •
(A(nl) + l)A(nl)
A(nl)+An+l
ITEM lOlA (Gosper): page 37
On the theory that continued fractions are underused, probably
because of their unfamiliarity, I offer the following propaganda
session on the relative merits ~ f continued fractions versus
other numerical representations. For a good cram course in
continued fractions, see Knuth, volume 2, page 316. (In what
follows, "regular" means that all numerators are 1, and any radix
can be read in place of decimal.)
0) 11' is 3. But not really 3, more like 3 + 1/7.
7, more like 7 + 1/15. But not really IS, ••••
continued fraction for 11' is written 3 7 15 1 292
But not really
So the regular
1 1 ••• •
1) The continued fractions for rational numbers always come out
even, and rather quickly. Thus, the number of inches per meter
is exactly 100/2.54 or 39 2 1 2 2 1 4. The corresponding decimal
fraction 39.3700787 ••• has period 42, making it almost impossible
to tell if the number is rational. (But if our data are ALL
rational, the ordered pair 5000/127 is even more concise.)
2) Quadratic surds, which are of course inexpressible as
rationals, are generally unrecognizable in decimal. Their
continued fractions, on the other hand, are periodic. Nth roots
of e
2
, ratios of Bessel functions, and ratios of linear functions
of these all have regular continued fractions formed by
interleaving one or more arithmetic sequences. These special
properties will show up regardless of number base. You might
recognize 5.436563 ••• as 2e, but even Schroeppel might not notice
2/3 2/3
that 6.1102966796 ••• was (4 e  2)/(e  1) until he wrote
it as 6 9 15 21 27 33 ••••
The familiar transcendental functions of rational arguments also
have simple continued fractions, but these are generally not
regular and cannot be reconstructed from numerical values by a
simple algorithm, since nonregular representations aren't unique.
The point is, however, that numbers like e, 11', 0/2, sin .5,
17 arctan 17, etc. can be expressed to unlimited precision by
simple programs which produce the terms on demand.
3) If 'ie define a rational approximation to be "best" if it
comes closer than any other rational with such a small
denominator, then continued fractions give the complete set of
best rational approximations to the value which they represent.
That is, if you truncate a (regUlar) continued fraction, at any
point, then the reSUlting rational number is a best approximation.
Furthermore. this remains true if the last term of this
approximation is replaced by any smaller positive integer other
than 1. All best approximations can be generated in this manner,
in order of increasing denominators (or numerators). For e x a ~ p l e ,
the approximants to 11' = 3 7 15 1 292 ••• are:
3: 1/1, 2/1, 3/1 page 38
7: (4/1), 7/2. 10/3. 13/4, 16/5, 19/6, 22/7
IS: (25/8), 47/15, 69/22, 91/29, 113/36, ••• 311/99, 333/106
1: 355/113
... ...
Note that they are all automatically in lowest terms. The size
of a Jenominator is greater than the product of the terms
involved and less than the product of the numbers I greater than
the terms. The approximations are low if the number of terms is
odd, high if it's even. (Note that if a I ends a continued
fraction, it should be added in to the previous term. Thus, to
"round off" a continued fraction after a certain term, add in the
next term iff it is ±l. In the above, 4/1 and 25/8 correspond to
termination with a 1 and are not "best"; 355/113 is "best"
because the corresponding term really should be I.) The error is
smaller than lover the product of the denominator squared and
the first neglected term, so that the total number of digits
(numerator and denominator) is usually slightly smaller than with
equally accurate decimal fractions. 355/113 is good to 7.5
places instead of 5.5, due to the unusually large term (292)
which follows.
4) Numerical comparison of continued fractions is slightly harder
than in decimal, but much easier than with rationals  just
invert the decision as to which is larger whenever the first
discrepant terms are evennumbered. Contrast this with the
problem of comparing the rationals 113/36 and 355/113.
5) Regular continued fractions are in I to 1 correspondence with
the real numbers, unlike decimal (.5 = .49999 ••• ) or rationals
(2/3 • 6/9, 16 • ?). Even infinity has a continued fraction,
namely, the empty one! (Minus and plus infinity are the same in
continued fraction notation.)
6) Each representation favors certain operations.
uecimal favors mUltiplication by powers of 10. Rationals favor
reciprocation, as do continued fractions. To reciprocate a
regular continued fraction, add (or if possible, delete) an
initial 0 term. To negate, negate all the terms, optionally
observing that a, b, c, <1 •••• aI, 1, bel, c, d ••••
7) The strongest argument for positional (e.g., decimal or
floating) representation for nonintegers is that arithmetic is
easy. Rational number arithmetic often loses because numerators
and denominators grow so large as to require icky multiprecision.
Algorithms for arithmetic on continued fractions seem generally
unknown. The next items describe how to arithmetically combine
continued fractions to produce new ones, one term at a time.
page 39
Unfortunately, the effort required to perform these operations
manually is several times that for decimal, but the rewards for
machine implementation arc considerable (which can also be said
of floating point). Specifically, these rewards will be seen
to be: unlimited significance arithmetic without multiprecision
multiplication or diVision, built in error analysis, immorally
easy computation of algebraic functions, no unnecessary
computations, no discarding of information (as with roundoff. and
truncation), reversibility of computations, and the terms of the
answer start to come out right away and continue to do so until
shut off.
ITEM 1018 (Gosper):
Continued Fraction Arithmetic
Continued fractions let us perform numerical calculations a
little at a time without ever introducing any error, such as
roundoff or truncation. As if this weren't enough, the
calculations provide automatic error analysis, and obviate most
forms of successive approximation. This means we can start with
an arithmetic expression like 137i
2
;e I (tanh IS  sin 69)
and immediately begin to produce the value as a sequence of
continued fraction terms (or even decimal digits, if we should be
so reactionary), limited only by time and storage. If there are
quantities in the expression which are known only approximately,
the calculation can prOVide error bounds on the answer as well as
identify the quantity that limited the significance.
All this is possible because each operation (+, I, , t) in the
arithmetic expression requests terms from the continued fractions
of its operands only when necessary,and consequently produces
terms of its own value as soon as possible. Numbers like nand e
and functions like sin and tanh have continued fraction terms in
simple sequences which can be produced by short programs.
Imprecise quantities can also be programs which deliver terms
until they run out of confidence, whereupon they initiate special
action. By then, the last guaranteeable term of the overall
expression will have already been produced.
We see then that no calculation is performed unnecessarily,
so that, for example, a subexpression which happened to be
multiplied by zero would never be evaluated. AlSO, an operation
detecting a deficiency in two or more of its operands prOVides a
natural mechanism for allocating mUltiprocessor resorces, should
you have some.
Here are the algorithms for the elementary
arithmetic operations on continued fractions.
page 40
Let x be a continued fraction p + q /(p + q /( ••• • p + q lx'
001 I 0 0
where x' is again a continued fraction and the p's and q's are
integers. We shall call a (p q) pair a "term" of the continued
fraction for x. Often, only the p's are mentioned, in which case
the q's are implicitly alii, and x is called a "regular"
continued fraction.
Instead of a list of p's and q's, let x be a computer subroutine
which produces its next p and q each time it is called. Thus on
its first usage x will "output" p and q and, in effect, change
o 0
itself into x'. Similarly, let y be another procedurally
represented continued fraction r + slY'. Our problem will be
o 0
solved if we can write such subroutines for z(x,y) = x+y, xy,
xy. and x/y. When called upon to output a term of z, the
subroutine might in turn call for (or "input") terms from x and y
until it is satisfied that the unread portions of x and y cannot
affect the pending term of z. Then it would output this term and
change itself into z', so that it could produce the next term
next time. Unfortunately, when we try to do this, our
expressions quickly complicate. Let us preempt this complication
by computing instead the more general function
z(x,y) = (axy+bx+cy+d)/(exy+fx+gy+h)
(or (a b c d)/(e f g h) for short) where a through h are integer
variables whose initial values we are free to choose. Various
choices express
ad\lition: x+y
=
(0 1 1 0)/(0 0 0 I) ,
subtraction: xy
•
(0 I 1 0)/(0 0 0 I) ,
mUltiplication: xy
•
(1 0 0 0)/(0 0 0 I) , and
division: xly
•
(0 I 0 0)/(0 0 1 0) •
As we shall see, the process of inputting terms of x and y and
output tina terms of z will reduce to replacing the eight integers
a through h with linear combinations of each other.
When z inputs a term of x, z becomes a n e ~ function of x'.
To see how this happens, substitute p + q/x' for every occurrence
of x in the expression for zex,y), then multiply numerator and
denominator through by x':
z(x',Y) • (pa+c pb+d qa qb)/(pc+g pf+h qe qf).
If x was, rational and has run out of terms,
it has in effect become infinite:
z(oo,y) = (0 0 a b)/(O 0 e f)
If instead we input a term of y by substituting
r + slY' for every occurrence of y:
z(x,y') = (ra+b sa rc+d sc)/(re+f se rg+h sg).
If Y runs out of terms:
Z(X,oo) = (0 a 0 c)/(O e 0 g)
To output the term (t u), so that z • t + u/z'
(i.e., z· = u/(zt»:
z'(x,y) = (ue uf ug uh)/(ate btf ctg dth).
Thus this basic eight variable form is preserved by all
three operations, which can be performed in any order
since they represent independent substitutions.
page 41

For simplicity, let us assume that z will output in standard
form, that is, every u = 1 (regular) and every output term
t ~ 1 except perhaps the first. This means that ~ . will always
exceed 1 and thus 0 ~ u/z' < 1, so that the integer t = z  u/z'
must = [z], the greatest integer ~ z.
Since z generally varies with x and y, it should not output
unless [z] is constant for the range of possible x and y. We can
easily compute the range of z given the ranges of x and y if we
represent each range by the endpoints of an interval (in either
order), along with a bit indicating Inside or Outside. Thus if z
is in standard form, we can say that z will always be (Inside 1 00)
(or (Outside _00 1) after the first term. If z were to always
output its nearest integer instead of its greatest, then none of
the terms after the first would be 1, although they would
probably vary in sign. In this case, z would be (Outside 2 2).
Now hold y fixed and examine the behavior of z with x. If x is
(Inside a b) then z is (Inside zeal z(b» unless the denominator
of z changes sign between a and b (i.e., z has its pole in this
interval), whereupon z is (Outside zeal z(b». Symmetrically,
when x is (Outside a b) then z is (Outside zeal z(b» unless the
signs of the denominators of zeal and z(b) differ, whereupon z is
(Inside zeal z(b». This argument still holds with x and y
interchanged.
page 42
Now suppose that with y fixed at one of its endpoints, x
constrains z (Inside 1 2), and at y's other extreme, zex) is
(Outside 0 3). Suppose further that at the two extremes of x,
z(y) is (Inside 1 3) and (Outside 0 2). Then z(x,y) is
(Outside 0 1), the union of the four ranges. (Outside 0 2) is
the widest, indicating that z will probably get more information
from a term of y than a term of x. (Topology hackers should
recognize this InsideOutside nonsense as ordinary intervals in
toroidal space. The clue is that both plus and minus infinity
are denoted by the empty continued fraction.)
Due to the basically monotonic behavior of z, we can guarantee
that the actual range of z will be the union of these four ranges,
and that this range will be Inside or Outside some interval.
If it is (Inside zl z2) and [zl] = [z2], z can output the term
t • [zl]. Otherwise, z must input a term from x or y, whichever
was associated with the widest of the four ranges of z.
(Outside narrowness) is wider than (Outside wideness) is wider
than (Inside wideness) is wider than (Inside narrowness).
Evaluating z on these endpoints may be facilitated by keeping
estimates for the integer variables in floating point.
Even if z doesn't produce a term, narrowing the range of possible
z will still help in computing the range of a function of z,
especially if z gets stuck trying to output the last term of a
rational number resulting from irrational x and y. (There is no
way to guarantee that x or y won't eventually deviate, whereupon
z would egest a gigantic term.)
z can produce its value as decimal digits by mUltiplying
by 10 instead of reciprocating, after outputting t • [z):
z' (x,y) = (IO(ate) ·IO(btf) lOCctg) 10(dth»/(e f g h).
Strange to say, it is not serious if z for some reason outputs
the terms 7 S 1 when it should have produced 6 9. As soon as
permitted, it will simply recant with 0 1 S and continue with
the correction 1 9. The sequence 7 5 1 0 1 S 1 9 is
equivalent to 6 9 because b 0 c is the same as b+c. In order to
undo these computations, z violates the condition (Outside 1 1)
when it is 0 1 S •••• This condition is obeyed by nearly all
convergent continued fractions after their first term, and its
violation will very probably cause further retractions among the
functions dependent upon z.
This computation reversal trick is also handy for mechanizing and
denoting imprecise quantities. Instead of 2.997930 ±.000003, we
have 2 1 4Hl 0 2, meaning between 2 1 481 and 2 1 483. Similarly,
137 26 0 1 replaces 137.0373 ±.0006.
page 43
Successive approximations methods benefit considerably from not
requesting terms until needed. Consider Newton's method for
algebraic roots. We expect successive approximations to have
about twice as many correct terms each time. Since the
production of these terms cannot be aided by reading incorrect
terms, the additional correct terms must be produced before the
bad ones of the previous approximation are used. But this means
that there is no need to read in the bad ones at all. By feeding
back the output terms in place of the approximation, we get the
correct answer directly! (69\ of the credit for this goes to
Schroeppel.)
The basic eight variable form exemplified above by z(x,y) is not
the only form preserved by continued fraction term transactions.
We need only four variables and a single interval check to
compute z(x) = (ax+b)/(cx+d), the homographic function of one
argument. On the other hand, z(w,x,y) (linear in all three
arguments) requires sixteen variables and a twelve way interval
check. Each of these forms can be solved for x in terms of
z etc. to get a function of the same form. This is not true of
z(x) • (ax
2
+bx+c) l(dx
2
+ex+f),
for example, even though this form is also preserved. This form
is not guaranteed monotone, thus theoretically invalidating the
interval check algorithm, but it hardly ever errs. Even if it
did, it would quickly correct itself anyway. This form is not
only more economical than z(x,x), it is essential for the success
of the Newton's method feedback trick, which must know when two
variables. are really the same one.
By choosing the eight coefficients a h properly,
it should be possible to rewrite expressions as
compositions of considerably fewer of forms than one for
each +, , *, and I. The reader is to investigate the
problem of trying to find minimal Depending on
the met ric for min i mal i t y, the ques t ion c al:n beeompi i cat ed by
allowing higher powers of x and y. I f the' highest powers of
x, y, z, ••• in an invariant form are i, jl, k, ••• , then the
number of integer variables required for coefficients (mostly
because of all of the cross terms) is 2(i+'1) (j+l) (k+l) ••••
r
I
It is awkward in this system to evaluate transcendental functions
of irrational arguments. The problem is that you may need any
number of continued fraction (or series) terms which, instead of
being numbers, are symbolic functions of x, some infinite
continued fraction. My suggestion is to represent each symbolic
term of the function by a subroutine which is a function of x and
the next term, with this next term really a dummy until actually
called upon for output, whereupon it replaces itself with a full
fledged term subroutine which in turn refers to x and a new dummy.
page 44
Sad to say, the integer variables in these algorithms do not
usually shrink on outputs as much as they grow on inputs.
Fortunately, the operations for input and output only require
(besides addition) multiplication by terms which are almost
invariably small. (I have not seen a term exceed 20776 except
in specially constructed numbers.) It is fairly safe! then, to
declare any function which has gotten (Outside _2
35
2 5) to be
infinite, thus terminating its continued fraction. Better still,
note that the term 20776 is equivalent to the terms
20000 0 700 0 70 0 6, i.e., a very large term can be transmitted
piecewise. Although this is just thinly disguised rnultiprecision
mUltiplication, that first piece of the term will probably
satisfy its recipient for quite some time.
In some special cases, the integer variables will become periodic
rather than large, especially when all but one of the arguments
to a function have terminated. Then, we have the form
z(x) • (ax+b)/(cx+d), known as a homographic function. If adbe
is ±l, then a, b, c, d will eventually become 1, 0, 0, 1,
whereupon z will output the terms of x unmodified. Periodicity
will also occur when x is a Hurwitz number, i.e., when the terms
af x are the values of one or more polynomials evaluated on
consecutive integers and then interleaved. Coth 1/69, ~ , and
e are Hurwitz numbers whose polynomials are linear or constant.
Hurwitzness is preserved by homographic functions. If one can
show that 11' is not a Hurwitz number, one confirms the long
standing conjectuTes that e*11', e+11', e/11', etc. are all irrational •
.
If z, x, :and yare all regular, then it generally won't be
possible to reduce z by finding a GCD of a through h which is > 1.
However, it has been determined empirically that much reduction
is often possible in o t h ~ r cases. This reduction is almost
always by a divisor of an input or output term numerator (or 10
if output is decimal digits) and can be facilitated by keeping
cetain of the integer variables around modulo these quantities.
ITEM 10lC (Gosper):
Problem: Given an interval, find in it the rational
number with smallest numerator and denominator.
Solution: Express the endpoints as continued fractions. Find
the first term where they differ and add 1 to the lesser term,
unless it's last. Discard the terms to the right. What's left
is the continued fraction for the "smallest" rational in the
interval. (If one fraction terminates but matches the other as
far as '1 t goes, append an infini ty and proceed as above.)
*********************************************
GROUP THEORY
*********************************************
ITEM 102 (Schroeppel):
As opposed to the usual formulation of a group,
where you are given
1 there exists an I such that A * I • I * A • A, and
2 for all A, 8 and C, (A * B) * C • A * (8 * C), and
3 for each A there exists an A such that
page 45
A * X • X * A = I, and
4 sometimes you are given that I and'X are unique.
If instead you are given A * I • A and A * A • I, then
the above rules can be derived. But if you are given A * I • A
and A* A = I, then something very much like a group, but not
necessarily a group, results. For example, every clement is
duplicated.
ITEM 103 (Gosper):
The Hamiltonian paths through the N! permutations of N objects
using only SWAP (swap any specific pair) and ROTATE (1 position)
are as follows:
N PATHS + DISTINCT REVERSES
2 2 + 0, namely: S, R
3 2 + 1, namely: SRRSR, RRSRR
4 3 + 3, namely:
SRR RSR SRR RSR RRS RSR RSR RR
RSR SRR RSR RRS RSR RRS RSR RR
SRR RSR RRS RRS RSR RRS RRR SR
PROBLEM: A questionable program said there are none for N • 5;
is this so?
ITEM 104 (Schroeppel):
Any permutation on 72 bits can be coded with a routine
containing only the PDP6/10 instructions "ROT" and "ROTC".
*********************************************
SET THEORY
*********************************************
ITEM 105 (Komolgoroff, maybe?):
Given a set of real numbers, how many sets can you
get using only closure and complement? Answer: 14.
**************************************
QUATERN IONS
**************************************
page 46
ITEM 107 (Salamin):
A quaternion is a 4tuple which can be regarded
as a scalar plus a vector. Quaternions add linearly
and multiply (noncommutatively) by
(Sl+Vl){S2+V2) • 51 52  VI.V2 + 51 V2 + VI 52 + VI x V2
where
Sscalar part, Vvector part, .dot product, xcross product.
If Q = 5+V • (QO,Ql,Q2,Q3), then S  QO, V = (Ql,Q2,Q3).
Define conjugation by (5+V)* • SV. The (absolute value)2
of a quaternion is Q02 + Ql2 + Q2
2
+ Q3
2
• Q Q* = Q* Q.
The nonzero quaternions form a group under multiplication
with (1,0,0,0)  1 as identity and l/Q = Q*/(Q* Q). The unit
quaternions, which lie on a 3sphere embedded in 4space, form a
subgroup. The mapping F(Q) • PQ (P a unit quat.ernion) is a rigid
rotation in 4space. .This can be verified by expressing PQ as a
4
X
4 matrix times the 4vector Q, and then noting that the matrix
is orthogonal. F(Q) restricted to the unit quaternions is a
rigid rotation of the 3sphere, and because this mapping is a
group translation, it has no fixed point.
We can define a dot product of quaternions as the dot
product of 4vectors. Then Ql.Q2  a iff Ql is perpendicular to
Q2. Let N be a unit vector. To each unit quaternion Q  5+V,
attach the quaternion NQ  N.V + N S + N x V. Then it is seen
that (NQ).(NQ) • N.N  I and (NQ).Q • O. Geometrically this
means that NQ is a continuous unit 4vector field tangent to the
3sphere. No such tangent vector field exists for the ordinary
2sphere. Clearly the Isphere has such a vector field.
PROBLEM: For which Nspheres does a
continuous unit tangent vector field exist?
page 47
Let W be a vector with zero scalar part) and
Q = S+V. Then Q W Q* • (5 + V.V)W + 2 5 V x W + 2 V(V.W).
Let N be a unit vector and Q the unit quaternion
Q = ±(cos(6/2) + N sin(6/2». Then
Q W Q* • (cos 6)W + (sin 6)(N x W) + (Icos 6)N(N.W), which is W
rotated thru angle 6 about N. If Q thus induces rotation R, then
QI Q2 induces rotation RI R2. 50 the projective 3sphere
(+Q and Q identified) is isomorphic to the rotation group
(3
X
3 orthogonal matrices). Projectiveness is unavoidable since a
211' rotation about any axis changes Q • I continuously into
Q :I: 1.
Let U be a neighborhood of the identity in the rotation
group (ordinary 3 dimensional rotations) and Ul the corresponding
set of unit quaternions in the neighborhood of 1. If a rotation
R carries U into U', then a quaternion corresponding to R carries
Ul into Ul'. But quaternion multiplication is a rigid rotation
of the 3sphere, so Ul and UI' have equal volume. This shows
that in the quaternion representation of the rotation group, the
llaar measure is the Lebesgue measure on the 3sphere.
Every rotation is a rotation by some angle 6 about some
axis. If rotations are chosen "uniformly", what is the
probability distribution of 6' By the above, we choose points
uniformly on the 3sphere (or hemisphere since it is really
projective). Going into polar coordinates, one finds
pea) = (2/11') (sin 8/2)2, 0 < 6 < 11'.
In particular, the expected value of 0 is 11'/2+2/11'.
Quaternions form a convenient 4parameter representation
of rotations, since composition of rotations is done by
multiplication. In contrast, 3parameter
representations like Euler angles or (roll, pitch, yaw) require
trigonometry for composition, and orthogonal matrices
9parameter. In space guidance systems under development at
UIab, the attitude of the spacecraft is stored in the iuidance
computer as a quaternion.
•••••••••••••••••••• **** •• ******.**.**•••• **.
POLYOMINOS, ETC.
** ••••••••••••••••••• *.*••••••••• *.*••• *•••••
ITEM 108:
See the PROPOSED COMPUTER PROGRAMS section
for counts of polyominos of orders < 19.
page 48
ITEM 109 (Schroeppel):
Tessellating the plane with polyominos:
Through all hexominos, the plane can be tessellated with
each piece ( w i t h o u ~ even flipping any over). All but the
four heptominos below can tessellate the plane, again without
beini flipped over. Thus, flipping does not buy you anything
through order 7. (There are 108 heptominos).
II II IIHH II II
HIlHIlII II If IUIHH IIHBH
fiB II H
II H
ITEM 110 (Schroeppel):
PROBLEM: What rectangles are coverable
by various polyominos? For example,
xx
X
YYYY
can cover rectangles which are 3N x M,
except if N • I, then M must be even.
can be shown by coloring to cover only rectangles
having at leaat one side divisible by four.
ITEM III (Schroeppel):
PROBLEM: Find a necessary and sufficient condition for
an arbitrary shape in the plane to be domino coverable.
ITEM 112 (Beeler):
"Iamonus" are made of equilateral triangles, like diamonds.
"(Poly)ominos" are made of squares, like dominos.
"Hexafrobs" are made of hexagons.
"Somalike" pieces are made of cubes.
See also "Polyiamonds," Math. Games, Sci. Am., December 1964.
Left and right 3dimensional forms are counted as distinct.
ORDER IAMONOS OMINOS HEXA'S SOMALIKE
1 1 1 1 1
2 1 1 1 1
31232
4 3 S 7 8
S 4 12 22 29
6 12 3S
7 24
8 66
9 160
10 448
page 49
Polyominos of order 1. 2 and 3 cannot form a rectangle. Orders
4 and 6 can be shown to form no rectangles by a checkerboard
coloring. Order 5 has several boards and its solutions are
documented (Communications of the ACM. October 1965):
BOARD DISTINCT SOLUTIONS
3 x 20 2
4 x 15 368
5 x 12 1010
6 x 10 2339 (verified)
two 5 x 6  2
8 x 8 with 2 x 2 hole in center  65
CONJECTURE (Schroeppel): If the ominos of a given order
form rectangles of different shapes, the rectangle which
is more nearly square will have more solutions.
Order4 hexafrob boards and solution counts:
side 7 triangle  no solutions
parallelogram. base 7. side 4  9 distinct solutions
e.g.. A A A ABC C
DEB B C F C
DEE B F G G
o 0 E F F G G
Order6 iamond boards and solution counts (see illustration):
side 9 triangle with inverted side 3 triangle
in center removed ~  no solutions
trapezoid, side 6. bases 3 and 3+6  no solutions
two triangles of side 6  no SOlutions
trapezoid. side 4, bases 7 and 7+4
 76 distinct solutions
parallelogram, base 6, side 6  156 distinct solutions
parallelogram, base 4, side 9  37 distinct solutions
parallelogram. base 3. side 12  no solutions
triangle of side 9 with triangles of side 1, 2 and 2
removed from its corners (a commercial puzzle)
 5885 distinct solutions
With Somalike pieces. orders I, 2 and 3 do not have interesting
boxes. Order 4 has 1390 distinct solutions for a 2 x 4 x 4 box.
1124 of these have the fourinarow on an edge; the remaining
266 have that piece internal. 320 solutions are due to
variations of ten distinct solutions decomposable into
two 2 x 2 x 4 boxes. A Somalike 2 x 4 x 4 solution:
AAAA BBIIH
BCCC SIIHC
DODE FGGE
FDGE FFGE
The commercial Soma has 240 distinct solutions; the booklet
which comes with it says this was found years ago on a 7094.
Verified by both Beeler and Clements.
Figure S. Some hexiamond solutions.
*********************************************
TOPOLOGY
*********************************************
ITEM 113:
Although not new (cf Coxeter, Introduction to Geometry,
1st ed. p393), the following coloring number
(chromatic number) may be useful to have around:
page 51

N • [[(7 + {4S II + 1)/2]]
where N is the number of colors required to color any map on an
object which has H holes (note: proof not valid for H • 0).
For example:
A donut (holes. 1) requires 7 colors to color maps on it.
A 17hole frob requires 17 colors.
An IShole frob requires 18 colors.
ITEM 114 (Schroeppel):
A most regular 7coloring of the torus can be
made by tiling the plane with the following
repeating pattern of hexagons of 7 colors:
A ACe E E
A A Ace C E E E
A A F FCC A A E E
F F F A A A
B B F F D D A A F F
B B B D D D F F F
B B G G D D B B F F
G G G 888
C eGG E E 8 B G G
C C C E E EGG G
C C A A E E C C G G
A A A C C C
D D A A F FCC A A
D D D F F F A A A
U D 8 8 F F D D A A
8 B B D D D
E E 8 B G G D D B B
E E EGG G 8 B B
E E C C G GEE B B
C C C E E E
C C E E
Draw an area 7 unit cell parallelogram by connecting, say, the
center 8's in each of the four B B
B B B
B B • Finally, j oi n the
opposite sides of the parallelogram to form a torus in the
usual (Spacewar) fashion. QUESTION (Gosper): is there a
toroidal heptahedron corresponding to this?
ITEM 115 (Gosper): page S2
A spacefilling curve is a continuous map T + XCT),Y(T),
usually from the unit interval onto the unit square,
~ f t e n presented as the limit of a sequence of curves made by
iteratively quadrisecting the unit square. Each member of the
sequence is then 4 copies of its predecessor, connected in the
shape of an inverted V, with the first member being a V which
connects 0,0 to 1,0. The limiting map, X(T) and YeT), can be
computed instead by a simple, finitestate machine having 4
inputs (digits of T base 4), 4 outputs (one bit 'of X and one bit
of Yl, and 4 states (2 bits) of memory (the number modulo 2 of
a's and 3's seen in T).
Let T, X, and Y be written in binary as:
T.A B A B A B •••
1 1 2 2 3 3
ALGORITHM 5:
X.x X X X X X •••
1 234 5 6
Y.Y Y Y Y Y Y •••
1 2 3 4 5 6
c
..
0
i'
of O's Plod 4
0
C
..
0
i'
of 3' 5 mod 4
1
51: X
..
A XOR C
i
1th bit of X
I I NOT B
I
Y
..
X XOR B
i
1th bit of Y
I I I
C
..
C XOR (NOT A AND NOT B ) icount OD's
0 0 I I
C
..
C XOR (A AND B ) icount II's
1 1 I I
GO 51
OLD
C CAB
o 1 I I
N E ' ~
X Y C C
I I 0 1
page 53
o 0
o 0
o 0
o 0
o 1
o 1
o 1
o 1
1 0
1 0
1 0
1 0
1 1
1 1
1 1
1 1
o 0
o 1
1 0
1 1
o 0
o 1
1 0
1 1
o 0
o 1
1 0
1 1
o 0
o 1
1 0
1 1
o 0
o 1
1 1
1 0
1 1
o 1
o 0
1 0
o 0
1 0
1 1
o 1
1 1
1 0
o 0
o 1
1 0
o 0
o 0
o 1
1 1
o 1
o 1
o 0
o 0
1 0
I 0
1 1
o 1
1 1
1 1
1 0
This is the complete
state transition table.
To carry out either the forward or reverse map. label a set of
columns as in the table above. Fill in whichever you know of AB
or XY. with consecutive rows corresponding to consecutive I's.
Put 0 0 in the top position of the OLD CC column. Exactly one
row of the above table will match the row you have written so
far. Fill in the rest of the row. Copy the NEW CC entry to the
OLD CC column in the next row. Again. only one row of the state
table will match. and so forth. For example. the map
5/6 + (1/2.1/2) (really .11010101 ••• + (.1000 ••• ,.0111 ••• »:
OLD
C CAB
o 1 I I
NEW
X Y C C
I I 0 1
o 0
o 1
o 1
o 1
1 1
o 1
o 1
o 1
1 0
o 1
o 1
o 1
o 1
o 1
o 1
o 1
•• •
II 5/6 1/2 1/2
We note that since this is a onetoone map on bit strings, it is
not a onetoone map on real numbers. For instance. there are 2
ways to write 1/2 •• 1000 ••• and .0111 •••• and t ~ u s 4 ways to
write (1/2.1/2). giving 3 distinct inverses. 1/6. 1/2. and 5/6.
Since the algorithm is finite state. X and Yare rational iff T
is. e.g •• 898/4369 + (1/5.1/3). The parity number. (see SERIES
section) and l(parity number) are the only rea1s satisfying
X(T)IIT. Y(T)l. This is related to the fact that they have no
O's and 3's base 4. and along with O. 1/2. and 1
11
.111 •••• are the
only numbers preserved by the deletion of their even numbered bit
positions.
*********************************************
SERIES
*********************************************
ITEM 116 (Schroeppel &Gosper):
• NINI 4 2n
page 54
~   + 
N0 (2N)! 3 9 13
PROBLEM: Evaluate in closed form
• N!NIN!
~
NO (3N)!
1
J which • ! (P + Q arccos (R» dT J where
o
4*41
X
(e )/X.
ITEM 117 (llenry Cohen):
X
2
X·
y


In X +
X 

+


2*2! 3*31
\ihere ERROR is of the order of
Xit

• • •
+ ERROR
ITEM 118 (Schroeppel): Y
Uifferentiate Ye • X to get Y+YXY'XY'  O. Substitute
for Y a power series in X with coefficients to he determined.
One observes the curious identity:
N J 1 NJ N
~ (BINOMIAL N J)J (NJ)  N (0°.1)
Jl N1 N
and thus VeX) • t N X INI
Nl
'ITEM 119 (Schroeppe1):
PROBLEM: Can someone square some series for n to give
n
2
1 1 1
the series •  +  + •••  t __ ?
6 1
2
2
2
H
2

ITEM 120 (Euler):
The series accelerating transformation
(Abramowitz &Stegun, sec. 3.6.27)
K K K+l
AOAl+A2 ••• • 1: () (A AO)/2
K K KM
(where (A AO) :II L () (BINOMIAL K M) AM  Kth
MO
forward difference on AO) when applied to
Nl 2
1f 1 1 1f 2 N!
 = 1   +   ••• gives   L
page 55
4 3 5 4 (2N+ 1) !
Applied to the formula for y in Amer. Math. Monthly
T [log2 T]
(vol. 76, 13, Mar69 p273) = 1: ()
([ ] mean integer part of) we get T
00 (K+l) Kl I
I: 2 I: l/(BINOMIAL 2 +J J)
K=l JO
(Gosper) which converges fast enough for a few hundred digits.
The array of reciprocals of the terms follows, with powers of 2
f a c t o r e ~ out to the left from all members of each row.
4 1
813
16 1 5 6
32 1 9 15 10
64 1 17 45 35 15
128 1 33 153 165 70 21
256 1 65 561 969 495 126 28
N+l
The next to left diagonal is 2 ; the perpendicular one 3rd
from the right is 1, *9/1 9, *10/2 45, *11/3= 165, *12/4 495.
ITEM 121 (Gosper):
Consider the triangular array:
1
1 1
141
1 11 11 1
1 26 66 26 1
1 57 302 302 57 1
This bears an interesting relationship to Pascal's triangle.
The 302 in the 4th southeast diagonal and the 3rd southwest one
= 4*26 + 3*66. Note that· rows then sum to factorials rather
than powers of 2. If the nth row of the triangle is dotted with
any n consecutive elements of (either) n+1st diagonal of Pascal's
triangle, we get the nth Bernoulli polynomial: for n  5,
1(6,i) + 26(6,i+l) + 66(6,i+2) + 26(6,i+3) + 1(6,i+4) 
sum of 5th powers of 1 thru i+5, where (j,i) • BINOMIAL (j+i j).
ITEM 122 (Schroeppe1, Gosper):
1 co N
The "parity number" •  L (parity of N)*2
2 NO
where the parity of N is the sum of the bits of N mod 2.
The parity number's value is .4124540336401075977 ••• , or,
for hexadecimal freaks, .6996966996696996.... It can be
written (base 2) in stages by taking the previous stage,
complementing, and appending to the previous stage:
.0
.01
.0110
.01101001
.0110100110010110
.01101001100101101001 ••• radix 2
page S6
i. e. , stage 0 • 0
stage N+l • stage N +
N
2
(1 2
N
2
stage N)/2
If NUM 0
•
0, DEN 0
•
2
NUM N+l
•
((NUM N)+I)*((DEN N) 1)
N... l
2 2
DEN N+ 1
:I
(DEN N)
•
2
N
2
)*(1  2 then
NUM : ~ + 1
DEN N+l
N
2
• stage N+1 • (stage N + 2 ) .
Or, faster, by substituting in the string at any stage:
the string itself for zeros, and
the complement of the string for ones.
It is claimed (perhaps proven by Thue?)
that the parity number is transcendental.
Its regular continued fraction begins: 0 2 2 2 1 4 3 5 2 1 4 2 1
5 44 1 4 1 2 4 1 1 1 5 14 1 50 15 5 1 1 1 4 2 1 4 I 43 1 4 I 2 1
3 16 1 2 1 2 1 50 1 2 424 1 2 5 2 1 1 1 5 5 2 22 5 1 1 I 1274 3 5
2 1 1 1 4 1 1 15 154 7 2 1 2 2 1 2 1 1 50 1 4 1 2 867374 1 1 1 5
5 1 1 6 1 2 7 2 1650 23 3 1 1 1 2 5 3 84 I 1 1 1284 ••• and seems
to continue with sporadic large terms in suspicious patterns.
A nonregular fraction is
1/(3 1/(2 1/(4 3/(16 15/(256 255/(65536 65535/
N N
2 2
( ••• 2 (2 11/( ••••
This fraction converges much more rapidly than the regular one,
I+NUM N
its Nth a pproxi man t be i ng , wh i ch is," in fac t ,
I+DEN N N
an approximant of the regular fraction, roughly the 2 the
In addition, 4*(parity number) •
1 3 15 255 65535
2   *  *  *  * *
• • •
page 57
2 4 16 256 65536
This gives still another nonregular fraction per the product
conversion item in the CONTINUED FRACTION section.
For another property of the parity number, see the
spacefilling curve item in the TOPOLOGY section.
ITEM 123 (Schroeppel, Gosper, Salamin):
Consider the image of the circle Izi • 1 under the function
n
2
z
f( z) = L
•
This is physically analogous to a series of
n
2
clock hands placed end to end. The first hand rotates around the
center (0,0) at some rate. The next hand is half as long and
rotates around the end of the first hand at twice this rate.
The third hand rotates around the end of the second at four times
this rate; etc. It would seem that the end of the "last" hand
(really there are infinitely many) would sweep through space very
fast, tracing out an (infinitely) long curve in the time the
first hand rotates once. The hands shrink, however, because of
n
. ~ the 2 in the denominator. Thus it is unclear whether the speed
of the "last" hand is really infinite; or, whether the curve's
arc length is really infinite.
nl
z
Also, it is a visually interesting curve, as are fez) • t
FIB(n) nl
z
,
and fez) • L
Gosper has programmed the one mentioned
FI B(n)
first, which makes an intriguing display pattern. See following
illustrations. If you write a program to display this, be sure
to allow easy changing of:
(1) z and z on alternate terms (alternate hands rotate in
opposite directions),
(2) negation of alternate terms (alternate hands initially
point in opposite directions), and
(3) how many terms are used in the computation,
since these cause fascinating variations in the resulting curve.
Figure 6(a). Image of circles Izl • 1/2, 3/4, 7/8, 1 under the
nl
z
function fez) • t 
nl
1'"' ._"\,........, ~
'., .'",
,... ...".!' '\
r' I
,;... '', ' I
,, r .\ "',.,  .
/' .....J '0 (' .... "
(
r . '. • ...... __.•. ,
/
. , ~ ..   ~ , "
I " 1.' ............... i
\,'::;". I ;"./I )
/''i ...·r\. ._.... ... / )
i ~  . __/ /
[ /./
" ._./ ?
\ . " " _ . ~ . _ . _  , .  '" ~ .  _ / " . ., . ..
"''r  ~ .. ~ .'
~ \ \.
~ , ; ~
\. '_ f) ~     • ../
, .. j,. ~ .., .........
...._,........ //\." " _.' .' ...... __.
...._ ~ . ~ . . ;
',.••_.i", /.1
" , ..__ r
Figure 6(b). Image of circles Izi • 1/8, 2/8, ••• , 8/S under
n
2
z
the function fez) • I
•
n
2
Both plots by Salamin on the RLE PDPI.
ITEt.1 124 (S chrocppel) : paRe 60"
Consider
1 1 1 1 1 1
t  = t [ ] + t [  ] • 2  I
N
2
N1/2 N+l/2 N
2
N
2
l/4 (4N
2
_l)*N
2
Take the last sum and reapply this transformation.
This may be a winner for computing the original sum.
For example, the next iteration gives
31 9
18 N
2
(4N
2
l)(2SN'+SN
2
+9)
where the denominator also •
N
2
(2N+l)(2Nl)(SN
2
+SN+3)(SN
2
SN+3).
ITEM 125 (Polya):
CONJECTURE: If a function has a power series with integer
coefficients and radius of convergence 1, then either the
function is rational or the unit circle is a natural boundary.
Reference: Polya, Mathematics and Plausible Reasoning,
volume 2, page 46.
FLOWS AND ITERATED FUNCTIONS
*********************************************
ITEM 126 (Schroeppel):
An analytic flow for Newton's method square root:
X
2
+K
Define F(X) by

.
then ,
2X N N
2 2
(X + IK) + (X tK)
F(F(F( ••• (X»»
:a1K
[N tilDes] N N
2 2
(X + IK)

(X •
t"K)
page 61
N
which = IK (coth 2 (arccoth x/If»
ITEM 127 (Schroeppel):
P and Q are polynomials in Xi when does P(Q(X» :a Q(P(X» ?
(That is, P composed with Q III Q composed with P.)
Known solutions are:
1 Various linear things.
2 X to different powers, sometimes multiplie4 by roots of 1.
3 P and Q are each another polynomial R composed
with itself different numbers of times.
4 Solutions arising out of the flow of X
2
.2, as follows:
suppose X = Y + l/Y
N N
then Y + Y can be written as a polynomial in X
for example,
p III the expression for squares • X
2
.2 (N • 2)
and Q • the expression for cubes • X'.3X (N • 3)
5 Replace X by YA, then add A to the original constants
in both P and Q. For example, P III X
2
and Q • X
3
,
then P = 1+(Y_I)2 • y
2
_2Y+2 and Q • 1+(Y_l)3,
then P(Q) • 1+ (Yl)' III Q(P).
Similarly, X with AY+8 works.
6 There are no through degrees 3 and 4 (checked with
Mathlab); but are there any more at all?
   .",.
,.
Figure 7. ITEM 128 (Schroeppel):
A map of the process n + binary string + interpret as radix 2,
iterated. To convert a number to base 2:
(n + ••• 101010) XOR ( ••• 101010) (reversible).
)

ITEM 129 (Schroeppel): page 63
PROBLEM: Given F(X) as a power series in X
with constant term = 0, write the flow power series.
FLO\l sub ZE ItO = X
fLOW sub ONE = P(X)
FLOW sub TWO • F(F(X»
etc.
NOTE (Gosper): If we remove the restriction that F has a power
series, the functions that satisfy an equation of the form
F(F(X» = sin X can be put into onetoone correspondence with
the set of all functions.
ITEM 130 P
N N P
If F(X)=X , the Pth flow is X , which has a branch point if N
is noninteger. Unoer the hypotheses of the previous problem,
it is possible to find the power series coefficients for P
rational, but there is no guarantee the series will converge.
PROBLEM: Is the flow interpolation unique? If it is not, what
extra conditions are necessary to it unique for natural
N
cases like X ?
ITEM 131 (Schroeppel):
raking any two numbers A and B, finding their arithmetic mean and
their geometric mean, and using these means as a new A and 8,
this process, when repeated, will approach a limit which can be
expressed in terms of elliptic integrals. (See PI section.)
ITEM 132 (Gosper): LOOP DETECTOR page 64
If a function F maps a finite set into itself, then its flow must
always be cyclic. If F is one step,of a pseudorandom number
generator, or the CDR operation on a self referent list, or any
function where it is easy to supply former values as arguments,
then there are easy ways to detect looping of the flow (Knuth,
The Art of Computer Programming, volume 2, Seminumerical
Algorithms, sec. 3.1, probe 7, page 7). If, however, the process
of iterated application of the function is inexorable,
(i.e., there is no easy way to switch arguments to the function),
then the following algorithm will detect repetition before
the third occurrence of any value.
Set aside a table TAB(J), 0 ~ J ~ log2 (largest possible period).
Let C = the number of times F has been applied, initially o.
Compare each new value of F for equality with those table entries
which contain old values of F. These will he the first S
entries, where S is the number of times C can be right shifted
before becoming O. No match means F hasn't been looping very
long, so increment C and store this latest value of F into
TAB{J), where J is the number of trailing zero bits in the binary
of C. (The first .. 16 values of J are: 0, 1, 0, 2, 0, 1, 0, 3, 0,
1, 0, 2, 0, 1, 0, 4, ••• ; Eric Jensen calls this the RULER
function.) A match with entry E means the loop length is 1 more
E+I
than the low E+2 bits of C  2
I TEf., 133 ( S c hroeppel, Gos per, II e nneman & Bank s ) ( from 0 a na Scot t ?) :
The "3N+1 problem" is iteratively replacing N by N/2 if N is even
or by 3N+l if N is odd. Known loops for N to fall into are:
1 the zero loop, 0 ~ 0
2 a positive loop, 4 ~ 2 ~ 1 ~ 4
3 three negative loops
(equivalent to the 3Nl problem with positive N)
2 ~ 1 + 2
5 + 7 + 10 + 5
17 + 25 + 37 + 55 + 82 + 41 +
61 + 91 + 136 + 68 + 34 + 17
In the range _10
8
< N < 6 * 10
7
, all N fall into the above loops.
Are there any other loops? Docs N ever diverge to infinity?
ITEM 134 (Schroeppe1, Gosper):
Let N be iteratively replaced by (FLATSIZE (LONGHAND N»,
the number of letters in N written longhand
(e.g., 69 ~ SIXTY NINE ~ 9 (10 counting blanks».
The process invariably loops at 4 = FOUR.
,
ITEM 135 (Gosper): page 65
The "c" Curve
A brilliant archeologist is photographing a strange drawing on
the wall of a cave. He holds the camera upright for some shots,
moves it, and turns it 90 degrees for the rest. When he sees his
prints he is amazed to find one of them apparently taken with the
camera turned 45 degrees. After a moment's reflection, he
correctly concludes that it is merely a double exposure.
What was the drawing?
Answer: It is a cousin to both the dragon and snowflake curves
(and arose as a bug in a spacefilling curve). It can be
constructed as follows. Start with a line segment. Replace it
with the two legs of the isosceles right triangle of which it is
hypotenuse. Repeat this for the two new segments, always bUlging
outward in the same direction. We now have four segments forming
half a square, with the middle two segments collinear. Replacing
these four segments with eight and then sixteen, we find the
middle two segments superimposed. As the process continues, the
curve crosses itself more and more often, eventually taking on
the shape of a wildly curly letter C which forms the envelope of
a myriad of epicyclic octagons.
A faster way to approach the same limiting curve is to substitute
n
2
the curve itself for each of its 2 segments, starting with a 
90 degree ,,<It.
Yet another way to construct it is to iteratively connect
opposite ends of two copies at a 90 degree angle. (The
archeologist did this with his double exposure.) If we reduce
the scale by 12 each time, the distance between the endpoints
stays the same. If the initial line segment is red and there is
some other blue shape elsewhere in the picture, the iteration
will simultaneously proliferate and shrink the blue shapes, until
they are all piled up along the red "C". Thus, no matter what
you start with, you eventually get something that looks like the
"C" curve.
There are other pictures besides the C curve which are preserved
by this process, but they are of infinite size. You can get
them by starting with anything and running the iteration
backwards as well as forwards, superimposing all the results.
A backward step consists of rotating the two copies in directions
opposite those in the forward step and stretching by 12 instead
of shrinking. David Silver has sketched an arrangement of
mirrors which might do this to a real scene.
Figure 8. Two orders of the "C" curve.
****************************************
PI
****************************************
page 67
ITEM 136: GAUSSIAN INTEGERS (For use by next item.)
Reference: Hardy and \'lright, Theory of Numbers. The Gaussian
integers are x+iy where x and yare integers. Unique
factorization holds, except for powers of i, and the Gaussian
primes are (1) a+bi if a
2
+b
2
is prime and (2) integer primes
that = 3 mod 4. If N(x+iy) • X
2
+y2, then N(uv) • N(u)N(v).
If P is prime and not 3 mod 4, then ~ • a
2
+b
2
has exactly one
solution. If n • 3 mod 4, then n  a +b
2
has no solution.
To factor x+iy into Gaussian primes, first factor N(x+iy).
(A) If 2 divides N(x+iy), then l+i and li divide x+iy.
Either factor may be used since i(il) • i+1.
(8) If p=3 mod 4 divides N(x+iy), then p divides x+iy.
(C) If p=l mod 4 divides N(x+iy) and p :I a
2
+b
2
•
then a+ib or b+ia = i(aib) divides x+iy.
If both do, then p divides x+iy.
ITEM 137 (Salamin): GENERATION OF ARCTANGENT FORMULAS FOR n
nl atan(yl/xl) + n2 atan(y2/x2) + •••
g n1 a rg ( x1+i y 1) + n2 ar g ( x2+i y 2) + •••
If each x+iy is factored and the n's chosen so all prime factors
except l+i cancel out, the right hand side is a mUltiple K of
n/4. Some care is needed because of the multiple valuedness of
arg. Then, if K :I 0, we get an arctangent identity, otherwise we
get a n formula. In the special ~ a s e of atan(l/x), factorization
of x+i is needed. Then case (8) above can't occur, and in case
(e), a+ib and aib can't both divide x+i.
Example:
8
2
+1 = 13 x 5
18
2
+1 = 13 x 52
57
2
+1 = 13 x 53 x 2
From this we get the factorization
8+i :I (3+2i) (2i)
l8+i :I (32i) (2_i)2 i
57+i :I (32i) (2+i) 3 (Ii)
Since we only care about the phase, multiplication
by a positive real number may be ignored below.
abc
(8+i) (18+i) (57+i) :I
abc
(3+2i)
a2b+3c
(2+1)
c b
(Ii) i
~ i e require abc = 0 and a2b+3c = 0, which has the minimal
nontrivial solution a = 51 b = 2, c :I 3. Then we have
(8+i)5 (18+i)2 (57+i) :I (1_i)3 i
2
Taking the phase of both sides, we get
5 atan(1/8) + 2 atan(1/18) + 3 atan(1/57) :I n/4.
atan(1/3l)
II
=
atan(I/50)
=
atan(1/239) =
=
atan(1/2441)
•
•
atan(I/32) =
•
n formulas: page 68
n/4 = atan(1/2) + atan(1/3)
n/4 = 2 atan(1/3) + atan(I/7)
n/4 • 4 atan(l/S)  atan(1/239)
n/4 • 2 atan(1/4) + atan(I/7) + 2 atan(1/13)
n/4 • 3 atan(1/4) + atan(1/13)  atan(1/38)
n/4 = 4 atan(l/S)  atan(I/70) + atan(1/99)
n/4 • 5 atan(1/8) + 2 atan(1/18) + 3 atan(I/57)
n/2 • 7 atan(1/4)  5 atan(1/32) + 3 atan(1/132)  4 atan(1/378)
This last angle has been measured against the International
Standard PlatinumIridium Right Angle and certified adequate
for any purpose of the U. S. Government, when used in conjunction
with a conscientiously applied program of oral hygiene and
regular professional care.
n/4 = 7 atan(1/9) + atan(1/32)  2 atan(I/132)  2 atan(I/378)
n/4 = 7 atan(I/13) + 8 atan(I/32)  2 atan(I/132) + 5 atan(1/378)
There are many easily found arctangent identities. Some are:
atan(I/57) + atan(I/68)
atan(1/44) + atan(I/105)
atan(I/91) + atan(I/1ll)
atan(1/70)  atan(I/99)
atan(I/408) + atan(1/577)
atan(1/1164)  atan(I/2225)
atan(1/4714) + atan(I/499S)
atan(1/38) + atan(1/132)  atan(I/378)
2 atan(1/13) + atan(I/239)  atan(I/2943)
Infinite sets of arctangent identities:
atan(l/n)  atan(I/(n+l» • atan(1/(n
2
+n+l»
Let x =1, y =0, x =x +2y , y =x +y
o 0 n nl nl n nl nl
x /y are the continued fraction approximants to I!.
n n
atan(l/y ) + atan(l/x ) • atan(l/i )
2n 2n 2nl
atan(l/y )  atan(l/x ) = atan(l/x )
2n 2n 2n+l
ITEM 138 (Gosper):
n • 28 arctan (3/79) + 20 arctan (29/278)
n = 48 arctan (3/79) + 20 arctan (1457/22049)
Which isn't too interesting except that it means that
(79+3i)" (22049+1457i)20 is a negative real number.
ITEM 139 (Ramanujan):
4/n =
page 69
N
~ (1) (1123 + 21460 N) (1*3*5* ••• *(2Nl» (1*3*5* ••• *(4Nl»
E
N=O 2N+l N
(882 ) (32 ) (N 1) ,
This series gives about 6 decimal places accuracy per term.
1 ~ (1103 + 26390 N) (1*3*5* ••• *(2Nl» (1*3*S* ••• *(4Nl»
IBn
=
E
N=O
4N+2 I N
(99 ) (32 ) (N!)'
This series gives about 8 decimal places accuracy per term.
For other n series, see Ramanujan's paper "Modular Equations and
Approximations to Pi" in Quarterly Journal of Pure and Applied
Mathematics, vol. 45, page 350 (1914). For more goodies, see
"Collected Papers of Srinivasa Ramanujan", Cambridge U. Press
(1927) •
ITEM 140:
Counting the initial 3 as the zeroth, the 431st denominator in
the regular continued fraction for n is 20776. (Choong, Daykin
& Rathbone, Math. of Computation 25 (1971) p. 387).
(Gosper) In the first 26491 terms of n, the only other 5 digit
terms are the 15543rd =19055 and the 23398th 19308. (Computed from
35570 terms of the (nonregular) fraction for 4 arctan 1.)
ITEM 141:
The fraction part of 10
760
n begins: .49999998 •••
ITEM 142 (Sa1amin):
Some superfast convergents to n if one already
has a superfast computation of trig functions.
X approx n: X + X + sin X, £ + £'/6
X + X  tan X, £ + _£'/3
X approx n/2: X + X + cos X, £ + £"6
X + X + cot X, £ + £ /3
ITEM 143 (Salamin): page 70
Computation of elliptic integrals, log, and n.
RE FE REN CES :
Whittaker &Watson, Modern Analysis, chap. 22
Abramowitz &Stegun, Handbook of Mathematical Functions,
sec t. 17. 3, 1 7,. 6 1
1. ELLIPTIC INTEGRALS
Define elliptic integrals:
1
K(m) II / 1/1(1  t
2
) (1  m t
2
Y dt
o
K' (m)
:I
K(l

m)
•
If A and B are given, and
0 0
A
:I
arithmetic mean of A and B
n+l n n
8
•
geometric mean of A and 8
n+ 1 n n
then define
AGM(A ,8 )
II
lim A
•
lim 8
0 0 n n
This is called the arithmeticgeometric mean.
Quadratic convergence rate:
A
n+l
 B
n+l
• (A
n
 8 )2 ISA
n n+l
It is known that
K'(x
2
) AGM(I, x) • n/2 [lee A&Sl.
This gives a super fast method of computing elliptic integrals.
It is easy to compute AGM(I, x) for x in the complex plane cut
from zero to infinity along the negative real axis. So K'(M) can
be computed for 2n < arg(m) < 2w, which covers the complex
mplane twice. Handling the phase when taking square roots will
permit exploration of more of the Riemann surface.
2. LOGARITHMS
For small m,
K(rn) • (If/2) (1 + m/4 + O(m
2
»
If (K' (m) /K(m»
e • (m/16) (1 + m/2 + O(m
2
»
Solve for K'(m) and let m • l6/x
2
,
page 71
K'(16/x
2
) • log x + (4/x
2
) (log xI) + O(log x/x").
For x sufficiently large,
log x = K'(16/x
2
) = n/(2 AGM(I, 4/x».
Requiring a given number of bits accuracy in log x is equivalent
to requiring
I (K' (16/x
2
)  log x) flog xl < £
this becomes
I (4/ x2) (1  1/ log x) I < I 4/ x21 < £
I xl > 2/1£.
x can be complex. If Ixl is not too close to I, x can be
brought into range by reciprocating or repeated squarina.
3. PIn
Let x = e , then
n
n = 2 n AGM(I, 4 e ).
Suppose £ = 10 to the minus a billion.
Then the above equation for 1f is valid when n > 1.15 billion.
n
e is calculated by starting with lIe and squaring k times.
k
Thus n = 2. 2
30
= 1.07 billion and 2
31
• 2.15 billion,
so k = 30 gives 0.93 billion places accuracy and k • 31 gives
1.86 billion places.
ITEM 144 (Schroeppel):
n n n
In the above, instead of x = e , use x • 2 and x • e*2 •
Then s i mu1tane 0 usequat ions can be .s 0 1vedt 0 gi vc bot h nand
log 2. This avoids having to square e, but requires two AGM's,
and therefore takes longer.
•••••••••••••••••• *.* ••••••••••••••••••••••••
PROGRAMMING HACKS
••••••••••••••••••••••••••• *.*.* •••••••••••••
page 72
\
WARNING: Numbers in this section are octal
(and occasionally binary) unless followed by a decimal point.
105=69.. (And 105.=69 hexadecimal.)
ITEM 145 (Gosper):
Proving that short programs are neither trivial nor
exhausted yet, there is the following:
0/ TLeA 1,1(1)
1/ see below
2/ ROT 1,9
3/ JRST 0
This is a display hack (that is, it makes pretty patterns) with
the low 9 bits = Y and the 9 next higher a X; also, it makes
interesting, related noises with a stereo amplifier hooked to
the X and Y signals. Recommended variations include:
CHANGE: GOOD INITIAL CONTENTS OF 1:
none 377767,,377767; 757777,,757757; etc.
TLC 1,2(1) 373777,,0; 300000,,0
TLC 1,3(1) 2,,2; 5,,1; 6,,1
ROT 1,1 7,,7; AOOOOB"AOOOOB
ROTC I,ll ;Can't use TLCA over data.
AOJA 1,0
ITEM 146:
Another simple display program: ("munching squares")
It is thought that this was discovered by
Jackson Wright on the RLE PDPl circa 1962.
DATAl 2
ADDB 1,2
ROTC 2, 22
XOR 1,2
JRST .4
2=X, 3=Y. Try things like 1001002 in data switches. This also
does interesting things with operations other than XOR,
and rotations other than 22. (Try lOR; AND; TSC; FADR; FDV{!);
ROT 14, 9, 20, ••• )
ITEM 147 (Schroeppel):
Munching squares is just views of the graph Y • X XOR T
for consecutive values of T • time.
ITEM 148 (Cohen, Beeler):
A modification to munching squares which
reveals them in frozen states through
opening and closing curtains: insert FADR 2,1 before the XOR.
Try data switches =
4000,,4 1000,,2002 2000,,4 0,,1002
(Notation: <left half>,,<right half»
Also try the FADR after the XOR, switches. 1001,,1.
.
ITEM 149 (Minsky): page 73
Here is an elegant way to draw almost circles on
a pointplotting display. CIRCLE ALGORITHM:
NEW X • OLD X  £ * OLD Y
NEW Y = OLD Y + & * NEW(!) X
This makes a very round ellipse centered at the origin with its
size determined by the initial point. £ determines the
angular velocity of the circulating point, and slightly affects
the eccentricity. If £ is a power of 2, then we don't even
need multiplication, let alone square roots, sines, and cosines!
The "circle" will be perfectly stable because the points soon
become periodic.
The circle algorithm was invented by mistake when I tried to
save one register in a display hack! Ben Gurley had an amazing
display hack using only about six or seven instructions, and it
was a great wonder. But it was basically lineoriented.
It occurred to me that it would be exciting to have curves, and I
was trying to get a curve display hack with minimal instructions.
ITEM ISO (Schroeppel):
PROBLEM: Although the reason for the circle algorithm's
stability is unclear, what is the number of distinct sets
of radii? (Note: algorithm is invertible, so all points
have predecessors.)
ITEM 151 (Gosper):
Separating X from Y in the above recurrence,
X(N+l) : (2_£2)*X(N)  X(NI)
Y(N+l) : (2_£2)*Y(N)  Y(Nl).
These are just the Chebychev recurrence with cos e (the
angular increment) • 1_£2/ 2• Thus X(N) and YeN) are expressible
in the form R cos(N e + .). The .'s and R for XeN) and YeN)
can be found from N:O,l. The .'s will differ by less than n/2
so that the curve is not really a circle. The algorithm is
useful nevertheless, because it needs no sine or square root
function, even to get started.
X(N) and YeN) are also expressible in closed form in the
algebra of ordered pairs described under linear recurrences,
but they lack the remarkable numerical stability of the
"simultaneous" form of the recurrence.
ITEM 152 (Salamin):
With exact arithmetic, the circle algorithm is stable iff
1£1 < 2. In this case! all points lie on the ellipse
X
2
 £ X Y + Y = constant,
where the constant is determined by the initial point.
This ellipse has its major axis at 45 degrees (if c > 0)
or 135 degrees (if & < 0) and has eccentricity
{E/(l + E/2).
ITEM 153 (Minsky): page 74
To portray a 3dimensional solid on a 2dimensional display,
we can use a single circle algorithm to compute orbits for the
corners to follow. The (positive or negative) radius of each
orbit is determined by the distance (forward or backward) from
some origin to that corner. The solid will appear to wobble
rigidly about the origin, instead of simply rotating.
ITEM 154 (Gosper):
The myth that any given programming language is machine
independent is easily exploded by computing the sum of
powers of 2.
If the result loops with period • 1 with sign +,
you a ~ e on a signmagnitude machine.
If the result loops with period = I at I,
you are on a twoscomplement machine.
If the result loops with period> 1, including the beginning,
you are on a onescomplement machine.
If the result loops with period> 1, not including the beginning,
your machine isn't binary the pattern should tell you
the base.
If you run out of memory, you are on a string or Bignum system.
If arithmetic overflow is a fatal error, some fascist pig with a
readonly mind is t r y i n ~ to enforce machine independence.
But the very ability to trap overflOW is machine
dependent.
By this strategy, consider the universe, or, more precisely,
algebra:
let X • the sum of many powers of two • ••• 111111
now add X to itself; X + X • ••• 111110
thus, 2X = XI so X = 1
therefore algebra is run on a machine (the universe)
which is twoscomplement.
ITEM 155 (Liknaitzky):
To subtract the right half of an accumulator from the left
(as in restarting an AOBJN counter): IMUL A,[377777,,1]
ITEM 156 (Mitchell):
To make an AOBJN pointer when the origin is fixed
and the length is a variable in A:
IIRLOI A,l(A)
EQVI A,ORIGIN
ITEM 157 (Freiberg):
If instead, A is a pointer to the last word
HRLOI A,ORIGIN(A)
EQVI A,ORIGIN
Slightly faster: change the HRLOIs to MOVSIs and the
EQVI addresses to ORIGINI. These two routines are
clearly adjustable for BLKOs and other fenceposts.
ITEM 158 (Gosper, Salamin, Schroeppel): page 7S
A miniature (recursive) sine and cosine routine follows.
COS: FADR A,[1.S7079632679] jw/2
SIN: MOVM B,A in A
CAMG 8,[.00017] r3 I 2
13
POPJ P, jsin X • X, within 27. bits
FUVRI A,(3.0)
PUSHJ P,SIN ;sin X/3
FMPR B,B
FSC B,2
FADRI 8,(3.0)
FMPRB A,B ;sin X • 4(sin X/3)'3(sin X/3)
POPJ P, ;sin in A, sin or Isinl in B
;Isinl in D occurs when angle is smaller than end test
Changing both 3.0's to +3.0's gives sinh:
sinh X = 3 sinh X/3 + 4 (sinh X/3)'.
Changing the first 3.0 to a +9.0, then inserting PUSHJ P,.+l
after PUSHJ P.SIN gains about 20\ in speed and uses
half the pushdown space « 5 levels in the first 4 quadrants).
PUSlfJ P,.+l is a nice way to have something happen twice.
Other useful angle mUltiplying formulas are
tanh X • (2 tanh X/2)/(1 + (tanh X/2)2)
tan X = (2 tan X/2)/(1  (tan X/2)2), if infinity is
handled correctly. For cos and cosh, one can use
cos X = 1  2 (sin X/2)2, cosh X s 1 + 2 (sinh X/2)2.
X
In general, to compute functions like e , cos X, elliptic
functions, etc. by iterated application of double and triple
argument formulas, it is necessary to subtract out the constant
in the Taylor series and transform the range reduction formula
accordingly. Thus:
F(X) = cos(X)l F(2X). 2F*(F+2) F(E) • _£2
/
2
X
G(X) = e 1 G(2X) • G*CG+2) G(E) • E
This is to prevent the destruction of the information in the
rangereduced argument by the addition of a quantity near I upon
the success of the £ test. The addition of such a quantity
in the actual recurrences is OK since the information is restored
by the multiply. In fact, a cheap and dirty test for F(E)
sufficiently small is to see if the addition step has no effect.
People lucky enough to have a square root instruction can get
natural log by iterating X + X/(IT+X + 1) until l+X • 1.
(number of iterations)
Then mUltiply by 2 Here, a LSH or FSC
would work.
ITEM 159 (Gosper, Schroeppel): page 76
herein are decimal.)
The correct epsilon test in such functions as the foregoing
SIN are generally the largest argument for which addition of
the second term has no effect on the first. In SIN, the
first term is x and the second is _x
3
/6, so the answer is
roughly the x which makes the ratio of those terms 1/2
27
;
so x = 13 1 2
13
• But this is not exact, since the precise
cutoff is where the neglected term is the power of 2 whose 1 bit
coincides with the first neglected (28th) bit of the fraction.
Thus, x
3
/6 = 112
27
* 1/2
13
, so X = 13 1 2
13
•
ITEM 160 (Gosper):
Here is a way to get log base 2. A and B are consecutive.
Call by PUSHJ P,LOG2 with a floating point argument in A.
LOG2: LSHC A, 33
VSIC,  201 (A)
TLC C,2ll000
1·10 VEI A, 20 0
LOGL: LSH B,9
REPEAT 7, FMPR B,B
LSH B,2
LSIIC A,7
SOJG A,LOGL
LSH A,l
FADR A,C
POPJ P,
;Spcciner's bum
;exponent and sign sentinel
;moby flunderflo
;fails on 4th try
;answer in A
Basically, you just square seven times and use the low seven
bits of the exponent as the next seven bits of the log.
ITEM 161 (Gosper):
To swap the contents of two locations in memory:
EXCII A,LOCI
EXCH A,LOC2
EXCH A,LOCI
Note: LOCI must not equal LOC21 If this can happen,
use MOVEEXClIMOVEM, clobbering A.
ITEM 162 (Gosper):
To swap two bits in an accumulator:
TRCE A,BITS
TRCE A,BITS
TRCE A,BITS
Note (Nelson): last TRCE never skips, and used to be
a TRC, but TRCE is less forgettable. Also, use TLCE
or TUCE if the bits are not in the right half.
page 77
ITEM 163 (Sussman):
To exchange two variables in LISP without using a third variable:
(SETQ X (PROG2 0 Y (SETQ Y X»)
ITEM 164 (Samson):
To take MAX in A of two byte pointers
(where A and B are consecutive accumulators):
ROTC A,6
CAMG A,B
EXCH A,B
ROTC A,6
ITEM 165 (Freiberg):
A byte pointer can be converted to a character address < 2
18
by
MULl A,<# bytes/word> followed by SUBI B,l<' b/w>(A).
To get full word character address, use SUB into a magic table.
ITEM 166 (Gosper, Liknaitzky):
To rotate three consecutive accumulators N < 37. places:
ROTC A,N
ROT B,N
ROTC B,N
Thus MAC's can be ROTC'cd in 2M3 instructions.
(Stallman): For 73. > N > 35.:
ROTC A,N36.
EXCH A,C
ROT B,36.N
ROTC A, N 72.
ITEM 167 (Gasper, Freiberg):
;B gets 7 bit character in A
IMUL A,[2010040201]
ANU A,[21042104377]
IUIVI A,17+7
page 78
with even parity
i5 adjacent copies
ievery 4th bit of left 4 copies + right copy
;casting out 15.'s in hexadecimal shifted 7
jodd parity on 7 bits (Schroeppel)
IMUL A,[10040201] i4 adjacent copies
lOR A,[7555555400] ;leaves every 3rd bit+offset+right copy
IDIVI A,9+7 iPowcrs of 2
3
are ±l mod 9
ichanging 7555555400 to 27555555400 gives even parity
;if A is a 9 bit quantity, B gets number of l's (Schroeppel)
IMUL A,[IOOlOOlOOl] i4 copies
AND A,[421042l0421] ievery 4th bit
IDIVI A,17 ;casting out 15.'s in hexadecimal
iif A is 6 bit quantity, B gets 6 bits reversed (Schroeppel)
IMUL A,[2020202] i4 copies shifted
AND A,[1044220l0] iwhere bits coincide with reverse repeated base 2
8
IDIVI A,377 jcasting out 2
8
_1'5
jreverse 7 bits (Schroeppel)
IMUL A,[1000400200l]
AND A,[2102l02l00l0]
IDIVI A,377
jreverse 8 bits (Schroeppel)
MUL A,[10020040l002]
AND B,[20420420020]
ANDI A,4l
DIVI A,1777
;4 copies sep by OOO's base 2 (may set arith. o'flow)
;where bits coincide with reverse repeated base 2
8
jcasting out 377's
;5 copies in A and B
;where bits coincide with reverse repeated base 2
10
.n
,
icasting out 2
10
.l's
)
ITEM 168 (PDPl hackers): page 79
foo, lat IDATAI switches
adm a IADDB
and (707070
adm b
iot 14 loutput AC sign bit to a music flipflop
jmp foo
Makes startling chords, arpeggios, and slides, with just the
sign of the AC. This translates to the PDP6 (roughly) as:
FOO: DATAl 2
ADDB 1,2
AND 2,[707070707070] jor 171717171717, 363636363636, 454545454545, •••
ADDB 2,3
LDB 0,(360600,,2]
JRST FOO
Listen to the square waves from the low bits of O.
ITEM 169 (in order of oneupsmanship: Gosper, Mann, Lenard, [Root and Mann]):
To count the ones in a PDP6/10 word:
LDB B,[014300"A] jor MOVE B,A then LSH B,l
AND B,[333333,,333333]
SUB A,B
LSII B,I
AND B,[333333,,333333]
SUBB A,B ;cach octal digit is replaced by number of lis in it
LSJI B,  3
ADD A,B
AND A,[070707,,070707)
IDIVI A,77 jcasting out 63.'5
These ten instructions, with constants extenaed, would work
on word lengths up to 62.; cleven suffice up to 254 ••
ITEM 170 (Jensen): page 80
Useful strings of nondigits and zeros can arise when
carefully chosen negative numbers are fed to unsuspecting
decimal print routines. Different sets arise from
different methods of charactertodigit conversion.
Example (Gosper):
UPT: IOIVI F,12
HRLM G,(P) ;tuck remainder on pushdown list
SKIPE F
PUSHJ P,OPT
LUB G,[220600,,(P)] jretrieve low 6 bits of remainder
TRCE G,"O jconvert digit to character
SETOM CCT jthat was no digit!
TYO: • lOT TYOCHN, G
AOS G,CCT
POPJ P,
jor OATAO or IOPB •••
This is the standard recursive decimal print of the positive
number in F, but with a LOB instead of a HLRZ. It falls into
the typeout routine which returns in G the number of characters
since the last carriage return. When called with a 36., DPT
types carriage return, line feed, and resets CCT, the character
position counter.
ITEM 171 (Gosper):
Since integer division can never produce a larger quotient than
dividend, doubling the dividend and divisor beforehand will
distinguish division by zero from division by I or anything
else, in situations where division by zero does nothing.
ITEM 172 (Gosper):
The fundamental operation for building list structure, called
CONS, is defined to: find a free cell in memory, store the
argument in it, remove it from the set of free cells, return
a pointer to it, and call the garbage collector when the set
is empty. This can be done in two instructions:
CONS: EXCH A,[EXCH A,[ ••• [PUSHJ P,GC] ••• ]]
EXCH A,CONS
Of course, the addresslinked chain of EXCH's indicated by
the nested brackets is concocted by the garbage collector.
This method has the additional advantage of not constraining
an accumulator for the free storage pointer.
UNCONS: IIRLI A, (BXCH A,)
EXCH A,CONS
EXCH A, @CONS
Returns cell addressed by A to free storage listj
returns former cell contents in A.
ITEM 173 (Gosper): page 81
The incantation to fix a floating number is usually
MULl A,400 iexponent to A, fraction to A+1
TSC A,A ;l's complement magnitude of excess 200 exponent
ASH A+l,20027.8(A) ianswer in A+l
If number is known positive, you can omit the TSC.
On the PDPlO
UFA A,[±233000,,) inot in PDP6 repertoire
TLC A+1,233000 iif those bits really bother you
When you know the sign of A, and IAI < 2
26
, you can
FAD A,(±233400,,] ior FADR for rounded fix!
TLC A,233400 iif those bits are relevant
where the sign of the constant must match A's.
This works on both machines and doesn't involve A+l.
On the 10, FADRI saves a cycle and a constant, and rounds.
ITEM 174 (Gosper, Nelson):
21963283741. = 243507216435 is a fixed point of the float
function on the PDP6/l0, i.c., it is the only positive
number whose floating point representation equals its fixed.
ITEM 175 (Gosper):
To iet the next higher number (in A) with the same number
of 1 bits: (A, B, C, D do not have to be consecutive)
MOVE B,A
MOVN e,B
,_ AND C,B
ADD A,e
MOVE D,A
XOR D,B
LSII D,2
IDIVM D,C
lOR A,C
*********************************************
PROGRAMMING ALGORITHMS, HEURISTICS
*********************************************
pag e 82
ITEM 176 (Gosper):
The "banana phenomenon" was encountered when processing a
character string by taking the last 3 letters typed out,
searching for a random occurrence of that sequence in the text,
taking the letter following that occurrence, typing it out, and
iterating. This ensures that every 4letter string output occurs
in the original. The program typed BANANANANANANANA••••
\ ~ e note an ambigui ty in the phrase, "the Nth occurrence of."
In one sense, there are five OO's in 0000000000; in another,
there are nine. The editing program TECO finds five. Thus it
finds only the first ANA in BANANA, and is thus obligated to type
N next. By Murphy's Law, there is but one NAN, thus forcing A,
and thus a loop. An option to find overlapped instances would he
useful, although it would require backing up NI characters
before seeking the next N character string.
ITEM 177 (Gosper): DRAWING CURVES INCREMENTALLY
Certain plotters and displays are constrained to
approximate curves by a sequence of kingmoves hetween points
on a lattice.
Many curves and contours are definable by FeX,Y) = 0 with
F changing sign on opposite sides of the curve. The following
algorithm will draw most such curves more accurately than
polygonal approximations and more easily than techniques which
search for a "next" X and Y just one move away.
We observe that a good choice of lattice points is just
those for which F, when evaluated on one of them, has opposite
sign and smaller magnitude than on one or more of its four
immediate neighbors.t This tends to choose the nearer endpoint
of each graph paper line segment which the curve crosses, if near
the curve F is monotone with distance from the curve.
First, divide the curve into arcs within which the
curve's tangent lies within one 45 degree semiquadrant. 11e can
show that for reasonable F, only two different increments (say
north and northwest) are needed to visit the desired points.
Thus, we will be changing one coordinate (incrementing Y)
every step, and we have only to check whether changing the other
(decrementing X) will reduce the magnitude of F. (If F increases
with Y, F(X,Y+I) > FeXI,Y+I) means decrement X.) F can often
be manipulated so that the inequality simplifies and so that F is
easily computed incrementally from X and Y.
As an example, page 83
the following computes the first semiquadrant of the circle
co: F + 0, Y + 0, X + R
Cl: F + F+2Y+l, Y + Y+l
C2: ift F > X, F + F2X+l, X + XI

C3: if Y < XI, go to Cl
C4: (Link to next arc) if Y
•
XI, Y + Y+l, X + XI
This can be bummed by maintaining Z • 2Y+l instead of Y.
Symmetry may be used to compute all eight semiquadrants at once,
or the loop may be closed at C2 and C3 with two PUSHJ's to
provide the palindrome of decisions for the first quadrant.
There is an expression for the number of steps per quadrant,
but it has a threeway conditional dependent upon the midpoint
geometry. Knowing this value, however, we can replace C3 and C4
with a simple loop count and an oddeven test for C4.
The loop must be toptested (C3 before Cl) if the
"circle" R I: 1, with four diagonal segments, is possible.
All this suggests that displays might be designed with an
increment mode which accepts bit strings along with declarations
of the form: "0 means north, 1 means northwest". 1100 (or 0011)
will not occur with a curve of limited curvature: thus, it could
be used as an escape code, but this would be an annoying
restriction.
See the following illustration of circles drawn this way.
t In case of a tie, i.e., F has equal magnitudes with opposite
signs on adjacent points, do not choose both points but rather
have some arbitrary yet consistent preference for, say, the outer
one. The problem can't arise for C2 in the example because the
inequality F ~ X is really F > (F2X+l) or F > X.S.
ITEM 178 (Schroeppel, Salamin): page 85
Suppose Y satisfies a differential equation of the form
P(X)Y(Nth derivative) + ••••• + Q(X) • R(X)
where P, ••••• Q, and R are polynomials in X
(for example, Bessel's equation, X
2
Y"+XY'+(X
2
_N
2
)y • 0)
and A is an algebraic number. Then YeA) can be evaluated to
N places in time proportional to N(ln N)3.
X
Further, e and In X or any elementary function can be evaluated
to N places in N(ln N)2 for X a real number. If F(X) can be
evaluated in such time, so can 'the inverse of F(X) (by Newton's
method), and the first derivative of F(X). Also, t(3) and y
can be done in N(ln N)3.
ITEM 179 (Gosper):
A program which searches a character string for a given
substring can always be written by iterating the sequence
fetchcomparetransfer (ILDBCAIEJRST on the PDP6/l0) once
for each character in the sought string. The destinations
of the transfers (address fields of the JRST's) must, however,
be computed as functions of the sought string.
Let
o 1 2 3 4
S ASS Y
o 1 022
stand for the program
TO: ILDB C,A ;C gets next char from pointer in A
Tl: CAIE C,"S jskip if it's an S
JRST TO ilooP
back on failure
ILDB C,A jnext
T2: CAIE C,"A ;skip if A
JRST Tl ;could be an S
ILDB C,A
T3: CAIE C,"S
JRST TO is, A, non S, so start over
ILDB C,A ;next
T4: CAIE C,"S
JRST T2 ;could be SAS.ASSY
ILDB C,A
CAIE C,"Y
JRST T2 jcould be SASS.ASSY
jfound SASSY
In other words, a number> 0 in the top row is a location
in the program where the corresponding letter of the
middle row is compared with a character of the input string.
If it differs, the number in the bottom row indicates the
location where comparison is to resume. If it matches,
the next character of the middle row is compared with the
next character of the input string.
page 86
Let J be a number in the top row and K be the number
below J, so that TK is the address field of the Jth JRST.
For each J ~ 1, 2, ••• we compute K(J) as follows:
K(l) = O. Let P be a counter, initially O.
For each succeeding J, increment P. If the Pth letter = the Jth,
K(J) • K(P). Otherwise, K(J) = P, and P is reset to O. (P(J)
is the largest number such that the first P characters match
the last P characters in the first J characters of the sought
string.)
J= 0 1 0 I 2 3 4 5
M I S S I S S I P P I I S S I S S I P P I
K(J)= 0 1 1 1 1 I 1 I 1 I 1 0 1 1 0 I I 0 5 1 0
0 1 2 3 0 1 2 3
C 0 C A C 0 L A S A S S A F R A S
0 I 0 2 0 I 3 1 0 1 0 2 I 3 1 I 0
To generalize this method to search for N strings at once, we
produce a program of ILDBCAIEJRST's for each of the sought
strings, omitting the initial ILDB from all but the first. We
must compute the destination of the Jth JRST in the Ith program,
TKM(I,J), which is the location of the Kth compare in the Mth
program.
It might be reasonable to compile such an instruction sequence
whenever a search is initiated, since alternative schemes usually
require saving or backing up the character pointer.
ITEM 180 (Gosper):
A problem which may arise in machine processing of visual
information is the identification of corners on a noisy boundary
of a polygon. Assume you have a broken line. If it is a closed
loop, find the vertex furthest from the centroid (or any place).
Open the loop by making this place both endpoints and calling it
a corner. We define the corner of a broken line segment to be
the point the sum of whose distances from the endpoints is
maximal. This will uivide the segment in two, allowing us to
proceed recursively, until our corner isn't much cornerier than
the others along the line.
The perpendicular distance which the vector C lies
from the line connecting vectors A and 8 is just
(C  A) x (8  A)
2 fA  81
but maximizing this can lose on very pointy V's.
The distance sum hack can lose on very squashed Z's.
*********************************************
I l A R D ' ~ A R c
*********************************************
page 87
ITEM 181 (Gosper):
A bug you might try to avoid when designing floating
point hardware, relating to excess200, l's complement exponent,
2's complement fraction convention:
1) An advantage is that negation and numerical comparison can
be accomplished with the same instructions for both fixed and
floating point numbers.
2) A disadvantage is that the termination of the
normalization process is ambiguous. Normally, when
the sign bit unequals the highest bit of fraction,
the number is normalized. A special case arises with
n n
negated powers of two. (That is, (2 ), not (2) .)
Then the fraction is 400,,0 and the sign is  also.
This means it is necessary to check whether shifting left
one more bit will bring in a one:
if it brings in a zero, you will overnormalize
if it brings in a one, you should do it
If you should but don't, rounding will unnormalize, and when you
then renormalize, the normalizing amount will be doubled, so you
will be off by 2 smidgens (thati is, the next to low order bit).
Note that rounding can overnormalize as well as unnormalize,
so you can't just stop normalization after rounding.
You might check this in your PDP6/10. For example,
combine 201400,,0+0 with minus 200777,,777777+20. For
o ~ 0 ~ 7777, the correct FMP result is minus 200777,,777776,
and the correct FMPR result is minus 200777,,777777.
Overnormalized negative powers of 2 work in compares and
most floating arithmetic. They lose with MOVN and as dividends.
Unnormalized floating operands win completely on the PDPIO,
except as divisors and dividends, the latter suffering truncation
error.
ITEM 182 (Roc): VOLTAGE REGULATORS
Fairchild is now supplying positive voltage
regulators costing about 2 dollars in lots
of I (for example, the uA7805 for +5 volts).
paRe 88
ITEM 183 (Roe): CURRENT MIRRORS
The CA3083 (and CA3084) transistor arrays can be used to make
neat current mirrors. (A current mirror supplies a current on
one wire equal to that drawn from a second wire.)
ITEM 184 (Roc): ONESHOT
A dual MUS Utype flipflop (such as the CD4013AE)
can be used to make a oneshot as follows:
c
rCLOCK
tJ 1
,
•• ! 5"0 1\$ <t 5 v
t
50 "5 @ 'OV
\
I
CLOCK
ITEM (Roc): OSCILLATORS
Evryone has their own favorite oscillator circuits;
here are some we like.
I crystal, overtone, transistor
II crystal, fundamental, transistor (drives at least I TTL load)
III crystal, fundamental, CMOS, low frequency (drives I TTL load;
at 5.4 volts and no load, draws 330 microamperes; with a 165 KHz,
32 pf crystal, varies about 10 liz per volt of Vee)
IV crystal, fundamental, Ie (a favorite of Nelson's, but be
careful and lucky or it may oscillate at a frequency determined
by the crystal holder capacitance and not by the crystal; note
similarity to noncrystal oscillator V)
V not crystal controlled; for comparison with IV
VI The following blocking oscillator is quite uncritical of
component values, with the exception that the turns ratio be
such that Vb (see graph) not exceed BVebo (about 5 volts for
silicon transistors).
I
.
o = ~ CbJf001AE,e
te
.
tS

.
page 89
1I.
v
page 90
+'1
'V OV

.
+v


...'
,
'\J +.7
't' "'" . 5 RC
ITEM 186 (Roe): FM RADIO LINK
In work on education at our lab, we built a motorized "turtle"
controlled by computer commands in the childoriented language
"Logo." The following is a transmitter designed as a radio link
between the computer and turtle. Input (modulation) is either
o or +12 volts; output is about Use a commercial FM tuner
as receiver. Note: this transmitter is ILLEGAL no matter what;
part 15 low power rule only allows if duty is less than about
1 second per 15 minutes. Uon't worry about it unless you
interfere with broadcast stations.
15K
II  18
%J)IA Y.. LONG.
_4+.,jruuD..... +'
I,COI
r
Ho1e: or't io".'
4ntennCl, to t.stt!.
ITEM 187 (Roe): PHONE LINE XHTR, RCVR page 91
When the chess program written at our lab is playing in a chess
tournament, a human attendant at the tournament moves the pieces,
punches the clock, and communicates with the program via a
portable terminal coupled to a telephone line. It is desirable
that the program know when its chess clock is running, even
though the attendant may not notice immediately that the opponent
has made his move and punched the clock. Therefore we built a
clock holder with a microswitch to sense the clock state.
The following is a 10 mw whose input is the
microswitch and whose output goes onto the phone line.
It switches between two frequencies, about 320 and 470 liz.
Also shown is the receiver. Input should be at least 100 mv rms
(threshold is 20 mv and overload is above 68 volts) with peak to
peak signal to noise ratio greater than 4:1. As we all know,
connections to phone lines are illegal unless made through a data
coupler supplied by TPC (The Phone Company).
.

__+__rt
.1
+, '" '320 Hz
t'l 1.170 Hz.
ITEM 188 (Roe): UC MOTOR VELOCITY SERVO page 92
une version of the "turtle" mentioned above (see RADIO LINK) uses
a UC motor to drive each of its two powered wheels. Since its
path is to be as straight as possible, a triangular pulse is
generated (to represent one "step" of the motor) and the motor's
velocity servoed to this analog command. An additional digital
command enables foreward or reverse motion. Diagram I shows a
simplified velocity servoing circuit. It has the disadvantage
that only half the maximum voltage available (V to +V) can be
applied across the motor at anyone time. Diagram II shows the
actual circuit used in the turtle.
K.2,. (ttlj '"'sts
mec.hQt\ical
+
""ore
I


1N36'f5
1NS1'O
«.no.l0'3
control
J[
ITEM 189 (Roe): OPTICAL COUPLER page 93
When two circuits are at potentials differing by a few hundred
volts but wish to communicate with each other, one solution is
to use an optical coupler. These employ a lightemitting device
placed close to a lightsensitive device. Diodes make very
fastresponding sensors, hut the signal from a lightsensitive
transistor is much stronger. Shown is a compromise, using a
transistor as a diode, with associated cleverness to get the
oelay (from input to output) down from 10 microseconds to 1.
MCTl + 5
+, de1q.y
~ t L O 'trtm
IJ
/.f70
de,l<lY
 'JA
sec
'17
I'M'
I T E ~ 1 190 (Roc): PHOTOCATHODE CURRENT aSCI LLATOR
In our fourth computerinterfaced image sensing device, TVD
(really a vidissector, not a TV), the photocathode sits at
several thousand volts negative. Nevertheless, one wishes to
sense the current it draws, since overcurrent should shut down
the photocathode voltage to avoid damage to the photocathode.
The following circuit draws no more than 400 microamperes at
10 volts (at 20 KHz out; about 200 microamperes at 10 KHz) and
couples the current information out as the frequency sent to T2,
whose coils are wound on opposite sides of a ceramic ferrite.
ITEf·1 191 (Roe): UEFLECTION AMPLI FIER page 94
TVU, mentioned above, uses a very carefully designed printed
circuit amplifier to supply current to its magnetic deflection
coils. Except for the notes with the diagram, we submit it
without further explanation or cautions.
Notes:
1 Except where noted, resistors 10%, 1/4 watt.
2 Capacitances in microfarads/volts; electrolytics aluminum.
3 Uiodes IN4727, lN4l54,lN4009 etc.; stored charge no more than
80 picocoulombs at 1 milliampere foreward current.
4 lUl03 = GE thermistor mounted at center of main heat sink.
S 220J = Analog Uevices chopper amplifier.
6 * = temperature protection circuit (overtemperature cutout).
7 Q2, Q3, Q4, Q5, Q6, Q12, Q13, Ql4, Q15, Ql6 mounted
on one 1 Centigrade degree per watt heat sink (e.g.
Wakefield 621K 1/2 inch in front of Rotron Muffin fan).
Case temperature about 70 degrees C max.
Ground heat sink and insulate transistors.
8 All transistors Motorola.
9 All zeners 1 watt.
10 VE48X = Varo; could be two 2 A SO PIV fast recovery.
11 Output capacitance about 800 pf; damping R about ISO ohms
for critical damping.
12 Slews from + (or ) 2 A to  (or +) 2 A in 4 microseconds;
dE/dt at hot side of deflection coil is about a billion v/sec.
13 Layout is critical, as with most fast highgain circuits.
A Bypassing and lead inductance: Short wide strips (or,
better, a ground plane) should be used for ground bus,
and ceramic capacitors with leads as short as practicable
used for bypassing. Best bypass capacitor is
AllenBradley CL series.
B loops: reference ground (triangles) and power ground
must be interconnected only at the cold side of the sense
resistor; take care to avoid stray current through the cold
side of the signal input.
C In general, the device should be constructed like
a 144 transmitter to avoid its becomming one.
14 The 100 pf stabilizing capacitor may want to be higher to
decrease hunting and ringing, which could improve settling time
than the reduced gainbandwidth would increase it.
Ql, Q12, '113 HPSUOI
QIl, Q2, Q3 ttPS  USI
Q4, Q5, Q6 2N 5194
Q14, Q15, Ql6 2N 5191
Q7 MPSU02
Q17 MPSU52
QH, Q19 2N 3906
Q9, Q18 2N 3904
+15
•
so
so +.::I:..
."0
~
~
~
V1
{cross reference}
INDEX
(explanation)
Compiled by Rich Schroeppe1 and Hi1arie Orman.
o {zero} 43 68
.8453 45
1 {one} 22 57 107
125 158 159 167
169 171 173 175
177 181
1st 49 60 62 115 132
159
1st order 6 15
1:2 80
2 {two} 14 23 31 32
35 43 45 47 48 57
60 63 97 120123
137 144 149 152
154 159 160
2dimensiona1 153
2NOTS 19
n
2 20 24 64
3 {three} 35 49 68
97 107 116 127
3rd 123 132 163
3dimensiona1 112
153
3space 77
3N+1 133
4 47 50 89 92 115
127 134 136
fourinarow 112
4th power 6 14 63
4letter 176
4space 107
4vector 107
4.86\ 29
5 47 51 57 61 78
81 90 103
fiveinarow 91
5th power 63 121
6 73 83 141
7 31 82 97 113 114
160
7co1oring 114
9 72 141
14 105
18 83
20omino 77
23 63
28 61
30 12
34 68
40 47
63 51
72 bits 25 104
120 60
130 50
220 62
239 63
256 82
284 62
292 101
355 101
672 60
1093 45
3511 45
7094 112
23000 41
2
18
41
2
8
' 57
Abramowitz 120 143
acce1eraiing 120 124
accumulator 155 162
164 166 172
Adams, Clifford 49
add 18 40 43 50
addl 64
addition 101 158 159
chain 12
additional 172
address 151 165 172
179
adjacent 68 167 111
advantage 101 172
181
AGM 131 143 144
alephtwo 129
algebra 13 151 154
algebraic
functions 101
number 32 101 178
algorithm 17 101 115
132 149153
176180 f1g9
alternating series
120
amazing 149
ambiguity 116 181
American Math.
Honth1y 48 120
amicable number 61
62
analysis 25 143
analytic function 11
126
analyze game 68 74
81 88 94
AND 1119 22 23 43
115
angle 45 101 131 158
angular velocity 149
151
annoying 111
answer 45 57 105
AOBJN 155 156
appear 39 153
append 101 122
Applied
Combinatorial
Math. 77 86
approximant,
continued
fraction 63 101
122 137
approximation 101
arbitrary 19 III 177
arc 123 177
arccos 14 IS 116
arccoth 126
arcerf 45
archaeologist 135
arcsin 10
arctan 16 63 101 137
138 140
area 114
arg, complex number
137
argument 132 158160
172
arithmetic 101
expression 101
geometric mean
{AGM}
mean 131 143
series 14 35 99
101
arpeggios 168
array 18 38 120 121
Art of Computer
Programming
{Knuth}
aspect ratio 80 112
associative 12
asymptotic 77 86
automatic 101
axis 3 107 143 152
backing up 176 179
banananana 176
Banks. Roger 20 133
base {radix}
basis vector 13 14
Ber1ekamp, Elwyn 69
Bernoulli 12 121
Bessel functons 99
101 178
best 17 72
bignum 101 154
billion 143
binary 12 22 60 63
115 122 128 fig7
132 145 154
binomial 38 42 43
116 118 120 121
bisector 3
bishop 70 78
bit 22 25 37 55
fig1a fig1b fig2
101 104 115 122
128 fig7 132 143
145 159 160 162
167 168 170 173
175 177 181
black 70 84 88 89
black box 19
blackout 68
board 68 76 78 84
9092 94 112
Boolean 1724
boundary 20 125 180
bounded 45 47 77
box 112
bracket 30
branch point 130 143
bridge 46
Brillhart, John 28
65
broken line 180
Brown, Steve 75
bug 45 135 181
bum 160 177
byte 164 165
C curVe 135 fig8
calculate 26 68 143
carriage return 170
carry 43 115
casting out 167 169
CDR 132
center 51 68 76 112
114 123 149
symmetrically 74
centroid 180
certified 137
chanaing 123 158 167
character 21 134 165
167 170 176 179
cheap 158
Chebychev 14 15 151
checkerboard 84 112
checkers 93
chess 70 78 87 88 95
Chess. for Fun and
. Chess for Blood
70
Chinese remainder
theorem 48
Choong 140
chord 168
chromatic number 113
circle 20 32 83 123
fig6a fig6b 125
149153 177 fig9
circumscribing 20
claim 65 122
Clements, Robert 112
clever 71
clock 123 fig6a
fig6b
closed form 10 14
116 118 131 151
177 180
closest 3 15
closure 105
clue 19 101
cluster point 32
code 25
coefficient 13 14 43
44 101 118 125
130
Cohen, Joe 117 148
coin 67
color 71 73 110114
common divisor 53
Communications of
the ACM 112
commutative 101 127
comparison 101 181
compile 179
complement 75 105
122 173 181
complex number 14 55
fig1a fig1b fig2
123 f i ~ 6 a fia6b
136138 143
complicate 101
composition of
functions 101 107
127
computation 1214 65
68 83 101 115 123
140 142 153 154
158 177 179
Computers in Number
Theory 77
concurrences 2
condition 11 101 III
130
conformal map 11
conjecture {problem}
33 35 S6 101 112
125
conjugate 32 107 123
conjunction 137
connected SO 73 114
115 180
CONS 172
consecutive 25 121
160 164 166 175
constant 14 SO 51
127 129 152 158
169 173
constrain 101 172
177
construct 39 4$ 80
135
continued fraction
97101 122 137
140
arithmetic 101
continuous 107 115
contours 177
converge 3 12 120
122 124 125 130
142 143
convergent 101
convex 20 24
coordinate 48 52 107
177
copy 24 35 115 122
167
corner 48 SO 68 112
153 180
corollary 51
correct 159
correction 101
cosh 158
cosine 14 15 26 107
i42 149 151 158
cotangent 142
coth 126
count 18 29 77 81 82
108 112 115 169
177
counter 64 155 170
179
counter (token) 90
counterexample 12
counterintuitive 75
cover 21 50 72 86
110 III
Coxeter 113
cross product 107
180
cube (box) 71 112
(power) 6 45 58 63
magic 50 51
root 8 159
cubic equation 8 10
partition 18
polynomial 127
curious 59 77 118
curtains 148
curve 55 fig1a fii1b
fig2 66 115 122
123 135 fig8 149
151 177 fig9
cycle 47 132 173
data 29 75 77
Daykin 140
decimal 33 36 37 56
57 101 139 145
159 170
decomposable 112
decrease 19 S6
degree (polynomial)
5 13 IS 127
(angle) 152 177
delta 120 181
denominator 12 45 54
101 122124 140
dense set 3
density 35
dependent 13
derivative 178
determinant 5 101
determine 39 42 47
118 149 152 153
deuce rule 42
diagonal 2 50 68 90
120 121 177
diamonds 112
dice 67 72
difference 14
forward 37 38 120
differential
equation 178
differentiate 118
digit 33 37 39 43 56
57 72 101 115 120
140 141 169 170
dimension
two 48 107 153
three 18 107 112
153
four 107
n 77 83
of vector space 1
direction 45 123
dirty 158
disadvantage 181
discover 18 49 64 71
146 149
discriminant 4 5
disordered 46
display 123 145 146
149 153 177
dissection 85 fig4
distance 153 117 180
distinct 22 56 68 71
103 112 lIS 150
171
distribution 26 32
40 46 107
diverge 133
divide into parts
177 180
division 101 181
by zero 3 171
divisor 43 53 60 101
110 136
domino 86 III 112
don't care 17
dot product 107 121
dots 69 73
double 14 45 78 158
171 181
dragon curve 135
draw (game) 73 94
(picture) 55 fi,l.
fil1b fil2 114
149 177 fig9
dual 7S
e 12 37 101 117 118
143 144 158 178
edle 50 112
egest 101
elea.nt 14g
element 82 102 121
elementary function
178
ellipse 149 152
elliptic function 10
131 143 158
empirically 101
empty S2 78 101 172
endpoint 101 177 180
energy 46
epsilon 149 152 159
equal 132 161 174
equation 3 8 9 178
equilateral 112
equivalence class 75
error 3 45 101 117
154 181
bounds 101
escalation 88
escape code 177
estimates 82 93 101
Euler 107 120
evaluate 13 14 68
116 177 178
even 54 115 133 167
177
exact {closed form}
10 26 41 159
arithmetic 3 152
example 61 68 76 85
86 101 102 110
113 124 127 137
170 177 178 181
exception 32 45 47
138 181
excess200 173 181
exchange 163
exciting 149
Execuport 21
exist 11 14 18 39 48
76 97 102 107
expected value 29
107
exponent 43 160 173
181
express 1 13 34 47
63 131
expression 14 36 43
57 127 177
extend 77
extra move 94
factor 28 29 45 47
52 61 63 120 136
137
factorial 1 31 34 43
98 103 116 117
121 123 139
fascinating 123
fascist 154
fast 120 142 143
fatal error 154
favorite 25
feedback 17 101
fencepost 157
Fermat 106
fetch 179
Fibonacci 12 14 47
123
field 13 107
find 21 22 31 68 80
86 III
fine structure
constant 101
finite 33 39 132
finitestate 115
fit 83
fixed point
number 173 174 181
of a function 174
f1atsize 134
flipflop 168
floating point 3 101
160 173 174 181
flow 25 126 127 129
130 132
FMP 181
foo 168
forced win 94
form {closed} 38 47
56 73 112 114 178
formula 1 12 14 18
77 86 120 137 158
forward difference
37 38 120
found 49 61 112 137
179
fraction {continued}
32 122 159 173
181
fractional fibonacci
12
fractional part S5
fig2 141
Fredkin, Edward 38
58
free 172
Freiberg, Jerry 157
165 167
frob 113
FSC 158
function 57 1012
15 1719 25 68 83
98 99 118 123
fig6a fig6b 125
129 131 132 142
143 151 158 159
174 178 179
future 25
game 42 46 6776 78
84 8796 112
gamma 117 120 178
gaps 83
garbage collector
172
Gardner, Martin 49
80 fig3a 112
gates 17
Gaussian
distribution 26
27 40
Gaussian integer 55
fig1a fig1b 136
137
GCD 52 101
generalize 14 18 21
47
generate 11 26 27 64
101 137
generating function
7 15 18
geometric
dissections 85
geometric mean 131
143
geometric series 38
geometry 2 177
Geometry,
Introduction to
113
gigantic 101
giveaway chess 87
Go 96
golden ratio 12 32
goodies 139
government 137
graph 147 177
greater 175
greatest integer .34
101 120
group S6 82 102104
107
grow 101
gruesome 73
guidance 107
Gurley, Ben 149
hack 145 149 180
hackers 168
hairy 67 97
half 32 123
halfline 18
ha1fword 148 155 162
Hamiltonian path 103
hand 46 94 123 fie6a
fig6b
Handbook of Math.
Functions 143
handicap 42
hardware 181191
Hardy, G. H. 136
hemisphere 107
Henneman, Bill 133
heptahedron 114
heptomino 109
heuristic 75 176180

"

hex 94
hexadecimal 122 145
167
hexafrobs 112
hexagon 49 85 fig4
112 114
hexiamond 112 figS
hexomino 109
HiQ 76
high order bit 181
hole 77 112 113
homographic 101
how many? 39 57 77
how much? 42
Hurwitz numbers 101
iamonds 112 figS
identify 101
identity (equation)
42 101 118 137
identity (group) 12
101 102 107
illustration 55
fig1a figlb fig2
80 fig3a fig3b 85
fig4 112 fig5 123
fig6a fig6b 128
fig7 135 fig8 177
fig9
image 19 123 fig6a
fig6b
imaginary axis 3
impossible 49 50 64
72 112
imprecise 101
increase 18 56 68 99
increment 132 151
177 fig9 179
independent
variables 26 29
40 101
independent vectors
14
independently 64 71
77
indicator 68
induction 32 75
inexorable 132
infinite 35 39 91
101 123 135
infinity 83 133
information 158 180
input 17 64 101 115
170 179
Instant Insanity 71
instruction 64 104
149 158 166 169
172 179 181
integer 18 32 34 40
47 52 60 83 101
120 125 130 136
171
integral 116 143
interesting '112 121
123 138 145 146
interexpressib1e 1
international 137
interpolation 130
interval 15 101 115
intriguing 123
Introduction to
Geometry 113
invariant 101
inverse 1214 25 112
115 118 150 178
invisible 48
iridium 137
irrational 45 101
irreducible 13
isomorphic 107
isosceles triangle
135
iterate 12 14 25 56
61 72 115 124
132135 158 176
179
itself 122 132
Jensen, Eric 132 170
joys 63
jump 64 76
king 70 78 87 88 89
kingmoves 177
knight 38 70 78
known 39 45 61 63 64
80 fig3a 85 86
127 133 143 173
Knuth, Donald 29 55
fig2 101 132
Kok, Jan 2
Komo1goroff 105
L 68
language 80 fii3b
154
large 32 94 122
larger 62 171
largest 14 29 43 72
132 159 179
Lasker, Edward 70
last 106 123 157 176
179
last digit 57
last move 68 84
lattice 48 52 68 177
least common
multiple 47
left 112 181
Legendre 29
lemma 19 50
Lenard, Jud 169
length 27 39 47 49
56 57 61 68 123
132 156 169
lexicographic 75
Liknaitzky, Rici 64
155 166
limit 35 77 115 131
142 143
Lindgreen, Harry 85
line 18 38 68 73 93
170 177 180
lineoriented 149
linear 101
linear combination
13 127 151
linked 172 177
Lisp 163
list 68 82 132 170
172
listen 168
location, memory 161
172 179
locus 45
log 1214 26 29 35
117 143 144 158
160 178
10g2 120 132 160
logic 1724
long 68 123 132
longest 33
longhand 134
loop 3 25 57 61 62
101 132134 154
176 177 179 180
lose 180 181
low 22 25 145 160
168 170 181
lowest 5 46
lowest terms 101
LSH 25 158
machine 25 64 66 101
115 180
machine independent
154
magic 4951 81 165
magnitude 123 154
173 177 1.80
majority 17
Mann, Bill 169
map 11 18 107 113
115 128 fig7 132
mask 22
match 101 115 132
173 179
Math. and Plausible
Reasoning 125
Math. of Computation
140
Math1ab 4 127
matrix 14 107
maximum 35 39 56 63
67 68 164 180
mean 131 143
measure 45 107 137
member 47 61 62 115
120
memory 115 154 161
172
Mersenne 28 63
method 3 12 21 26 29
42 126 143 170
172 178 179
metric 101
midpoint 177
minichess 78
minimal 12 21 22 85
137 149
minimal
representation
101
minimum 17 21 62 73
98
Minsky, Marvin 64
149 153
mirror 135
mistake 149
Mitchell, George 156
mode 177
modern analysis 143
modular function,
elliptic 10 139
modulus 12 13 43 45
47 86 101 122 136
167
monotonic 18 101 177
Montro11, E. W. 86
more 37 112 122
most 46 fif3b 95 114
move {aame 25
MOVN 181
Mozart, Wolfgang 63
multinomial
coefficient 43 44
mUltiple 45 57
mUltiple valued 137
mUltiplication 12
101 107 137 149
mUltiplication
formula 1 14 158
mUltiply perfect
number 60
mu1tiprecison
{bianum}
munching squares
146148
Murphy 176
music 168
myth 154
nspace 11 27
nsphere 11 107
narrowness 101
natural boundary 125
130
nearer 177
nearest inteaer 101
necessary III 130
negation 101 123 181
negative 133 138 143
153 170
negative radix 128
fig7
neglected term 159
neighborhood 107 177
Nelson, Stuart 162
174
never 94 162 171
new 149
Newton's method 3 12
126 178
next 120 123·160
Nim 68 74
no 18 SO 51 63 76
107 112 127 132
noise 145 180
noncommutative1y
107
nondigits 170
nonexponential 68
noninteger 130
nonregular
continued
fraction 122 140
nontrivial 28 137
145
nonuniform
distribution 32
nonlinear recurrence
15
nonzero 13 57 107
norm 136
normalize 27 181
not 17 19 68 113 115
161 172
noted 56
nth 5 7 14 IS 37 38
43 57 101 115 120
121 130 176
numerators 101
numerical 22 151 181
representations
101
n
n 118
occurrence 62
octagons 135
octal 145 169
octant 18
odd 45 68 133 167
oddeven 177
offset 167
omino {po1yomino}
one {I} 67 101 122
169 181
onedigit 56
onetoone 11 101
115
oneupsmanship 169
onescomplement 154
only 45 47 57 63 64
71 76 174
onto mapping 11 115
opening 148
operand 101 181
operation 11 34 101
132 146 172
opponent 78 88
optimal 67 72
option 176
OR 18 19 23 25
orbit 153
orchestras 63
order 12 14 15 50 51
77 81 94 108 112
117 169 181
ordered pairs 12 151
ordering, partial 18
origin 52 149 153
156
original 22 124
orthogonal matrix
107
outer 177
output 25 101 115
168 176
overflow 154 167
overlap 84 176
packed 71
pair 12 61 62 101
103 151
palindrome 177
parallel 50
parallelogram 112
114
parameter 107
parity 115 122 167
partition 18
Pascal's triangle
121
Paterson, Mike 71
path 19 103
pattern 114 122 123
145 154
pawn 70 78 87 89
PDP1 74 75 123
fig6a fig6b 146
168
PDP6/10 104 168
169 173 174 179
181
peg SOlitaire 75 76
pentagon 85
pentomino 84
perfect number 6062
period 68 101 132
154
periodic 45 101 149
permutation 22 56 75
103 104
perpendicular 3 107
120 180
Perron 100
phase 137 143
phenomenon 176
phi function 45
phrase 176
physically 123
pi 45 52 55 63 101
107 116 119 120
124 137139 143
pi(x) 65
pingpong 42
pitch 107
PL(n) 18
place 139 166 178
180
placing 68 84 90
planar partition 18
plane 52 109 III 114
143
platinum 137
player 42 6769
7274 84 87 88 90
92 94 I
plotter 123 fig6a
fig6b 149 177
Plumer, Dave 71
plus 23 75
point 32 42 48 52
107' 123 130 145
149 150 152 160
174 177 180 181
pointer 156 \157 164
165 172 179
poker dice 67
polar 107
pole 101
Po1ya, Georgie 125
polygon 2 20 180
polygonal 17.7
polyiamond 112 fia5
polynomial {x
2
} 5 12
14 15 101. 121 127
178 I
po1yomino 77'1 108110
112
pos i tion 22 168 76 93
95 96 10 3' 11 5 170
positive 34 98 133
137 153 170 173
174
possible 68 72 130
132
power 12 14 32 37 38
43 47 53 57 63
101 118 120 121
125 127 129 130
149 154 159 167
181
power, large 32
precision 101
predecessor 115 150
prediction 25 29 47
preempt 101
preserve 22 115
previous 122 130
prime 17 29 30 33 35
41 43 45 47 48 52
62 65 136 137
primitive root 57
print, decimal 170
probability 29 37 42
5254 57 107
probable, most 46
probably 32 35 83 85
problem 1 2 11 17 19
21 22 27 31 32 34
36 39 42 47 49 68
70 73 101 103 107
110 III 116 119
123 127 129 130
133 150 177 180
procedurally 101
procedure 13
product 13 45 47 S6
107 122
PROG2 163
program 57 61 64 75
7796 101 103 123
137 145180
progression 35 99
project 11
projective 107
promoted pawn 87
proof 13 18 32 50 S2
94 97 106 113
propoganda 101
prove 89
proved 31 3S 47 64
85 122
pseudorandom 132
pushdown 158 170
PUSHJ 158 177
puzzle (games) 56 71
79 112
pUZZle (question) 18
Pythagoras, Joe 58
quadrant 18 158 177
quadratic 3 143
quadrillion 30
quadrisecting 115
Quarterly Journal of
Pure and Applied
Math. 139
quartic equation 4 9
quaternary 37
quaternion 107
queens 87
question 57 114
quintic equation 10
quotient 99 171
radius 83 125 150
153
radix {binary,
ternary,
quarternary,
octal, decimal,
hexadecimal,
negative,
complex} 33 37 43
55 figla figlb
fig2 63 101 115
122 128 fig7 154
Ramanujan 31 139
random number
generator 25 132
random number 2527
29 32 37 52 54 57
random variable 40
random vector 27
range 40 83 101 133
158
rangereduced 143
158
rapidly 14 122
raster 21
rate 14 143
Rathbone 140
ratio 38 80 101 159
rational function 12
101 125
rational number 38
45 54 101 130
Rayfield, Malcolm
135
renormalize 181
reactionary 101
readonly 154
real number 3 32 45
105 115 137 138
143 178
recant 101
reciprocal 101 120
recognize 101
rectangle 68 80
fig3b 86 110 112
recurrence 1216 44
151 158
recursive 158 170
rediscovered 64
redouble 45
reduce 101
references 48 49 56
70 77 79 80 85 86
100 105 112 113
120 125 136 139
140 143
reflection 1 81
region 2 20 24
register 25 149
regular 101
Rektorys 12
related 45 63 145
relation 13 14 121
relatively prime 48
52
relevant 173
remarkable 151
remove digits 33
repeated 12 67 131
132 143 167
repeating pattern
114
replace 127 133 134
169 177
representation 107
representing 20
reqUired 37 113
restored 158
reverse bits 167
reverse paths 103
Riemann surface 143
right angle 137
rightmost dieit 14
33
rigid rotation 107
roll 72 107
rook 78
root 3 5 8 9 12 14
34 57 77 101 126
127 143 149 151
158
Root, Steve 61 169
ROT 104
rotate 11 103 107
123 135 153 166
rotation 81 107 146
roundoff 3 101 173
181
row 50 78 90 91 112
115 120 121 179
rule 12 42 67 84 102
ruler function 132
salvaged 45
Samson, Peter fig3h
164
satisfying 9 45 115
129 178
scalar 12 107
scale {stretch}
Scarne, John 90
Schutzenberger,
Marco 39
Scientific American
49 79 80 85 fig4
112
Scientific American
Book of Puzzles
80 fig3a
score 42 67 72
Scott, Dana 133
search 31 61 176 177
179
seems 47 68
segment 39 177 180
self, map into 132
selfreferent list
132
semiaroups 82
semiquadrant 177
sentinel 160
separating 151
separation, minimal
62
sequence 14 38 39
115 176 177 179
series 12 47 115125
129 130 139 158
set 3 17 35 4S 48 52
84 105 107 115
132 137 ISO 170
172
SETQ 163
Shanks, Daniel 65
shape 20 48 III 112
115
shift 25 132 167 181
short program 101
145
show 42 72 107 110
112
shrink 20 101 123
135
side 20 49 68 76 78
80 fia3b 86 94 95
110 112 114 137
177
sigma 116 118 120
123 124
sign 154 160 168 173
177 181
sianmagnitude 154
signals 145
Silver, David 135
Silver, Rollo 25
Sim 73
similar 51 6897
similarity 127
simple 18 97 115 146
simplify 177
simultaneous 68 144
lSI
sine 10 26 101 107
129 142 149 151
158 159
single 153
sinh 158
size 29 149
skip 83 162 179
sliding block puzzle
79
slope 38
small 80 101 106 158
s m a l l ~ r 62 158
smallest 48 68 80
fig3a
smidgen 45 181
snowflake curve 135
solid 153
solitaire 76
solution 810 21 27
31 35 49 71 112
fia5 127 136 137
solve 10 21 68 71 78
79 84 9096 143
144
Soma 112
somalike 77 112
space 11 19 27 77
107 123 158
spacecraft 107
spacefilling curve
66 115 122 135
spacewar 114
special 64 137 181
Speciner, Michael 18
62 160
speed 123 158
speed of light 101
sphere 11 27 107
sporadic 122
square (rectangle)
48 68 69 80 fig3a
fig3b 85 fig4 86
90 112 115
square root 9 34 97
101 126 137 143
152 158 159
sqrt (2) 32
sqrt(3) 116
square (exponent) 5
6 12 14 31 36 45
47 59 63 80 119
124 127 144 169
square, magic SO 147
square, munching 146
148
square waves 168
squashed 180
stability 150 151
stable'149 152
stalemate 73
Stallman, Richard
166
standard form 101
starting 76
state 25 46 115 148
Stegun 120 143
step 135
step function 83
step (walk) 45
step (number
required) 12 14
stereo 145
stereographically 11
stop 1 19
stopped 57
store 132 172
straight 38
strategy 67 72 73
154
stretch '11 52 135
127
string 18 37 39 122
128 fig7 154 170
176 177 179
String fig3b
subcycles 47
subproblem 39
subexpression 101
subgroup 107
subroutine 101
substitute 101 122
substring 179
subtract 64 101 155
158
succesive
appoximations 101
successor 68
suit 46
sum 29 43 SO 60 61
72 76 121124
fia6a fig6b 154
180
superfast 142 143
superimposing 20 135
surface 143
Survey of Applicable
Math. 12
susceptibility 25
suspicious 32 122
Sussman, Gera14 163
swap 103 161 162
sweep 123
switch 132 146 148
168
symbolic functions
101
symmetric function
57
symmetry fil1b 101
synthesize 17 19
system 107 154
table 115 132 165
tabulated 72
Tactix 74
takeaway laaes 68
tanlent 16 107 142
158 177
tanh 101 158
Taylor seriel 158
TechnololY Review 56
Teco 176
Teeko 90
term 14 34 101 120
122 123 129 139
140 159
term, lalt 101
terminate 101
termination 181
ternary 36 37
tessellatina 109
tesseract 51
test 47 158 159 177
text 176
theorem 29 38 48 85
106
theory 68 77
Theory of Numbers
136
thermodynamic 46
three {3} 60 70 166
Thue 122
tictactoe 91 92
112
Tiger Puzzle 79
time 28 65 68 93 123
144 147 160 178
toptested 177
toroidal space 101
114
total 25 72
tracing 123
trailing 132
transcendent'al
functi,ons '101
transcendental
number 101 122
transfer {jump} 179
transform 12 158
transformation 120
124
translate 11 107 127
168
trap 154
trapezoid 112
TReE. 162
tree search 75
triangle 73 75 85
1·12
triangle, Pascal's
121
trick 101
trillion 29 30
trinomial
coefficient 116
triple 14 88 158
truncation error 101
181
twice 39 50 86 123
158
twin primes 30
two {2} S2 57 61 62
68 72 73 84 89 90
162 163 172 177
180 181
two counter 64
twodimensional 18
twomember 61 62
twoscomplement 154
181
typeout 170
typical 77
typo 10 101
unclear 123 150
underflow 160
unequal 46 52 80 181
unfeasible 93
. uniform 26 27 32
uniformly 32 40 107
union 52 101
unique 13 49 55
fig1a figlb fi&2
101 102 130 136
unit {sphere,
interval, circle,
quaternion, cell,
square} 27 32 83
107 114 115 123
universal 64
universe 154
unknown 101
unnormalized 181
unproven 92
unstable 3
upward 19
useful 151 176
valid 113 143
value 13 17 25 29 SO
99 107 122 132
147 177
variable 6 7 1720
40 156 163
variance 40
variations 112 123
145
vector 12 13 27 107
180
velocity 149
Venn diagram 20 24
verboten 88
verified 77 107 112
verify 28 85
vertex 180
views 147
visible 48
visual information
180
volume 107
Waltz, Dave 21
Watson 143
waves 168
white {chess,
checkers} 70 84
88 89
Whittaker 12 143
win 42 6769 7275
84 87 89 90 92 94
windowdice 72
wobble 153
wonder, great 149
word (computer) 25
157 165 169
Wright, E. M. 136
Wright, Jackson 146
x
2
_2 127
x
2
x1 12
XOR 17 23 ~ 5 68 115
147
Yao, F.ranc es 64
yaw 107
year 93
zero digit 18 36 57
122 132 170 181
zero element 13 47
107
zero loop 133
zero of polynomial 5
zero (number) 32 35
45 64 101 143
zero, division by 3
171
zeroless 57
zeta function 53 119
124 178
.>
•
Compiled with the hope that a record of the random things people do around here can save some duplication of effort  except for fun. page 1
Here is some little known data which may be of interest to computer hackers. The items and examples are so sketchy that to ~ecipher them may require more sincerity and curiosity than a nonhacker can muster. Doubtless, little of this is new, but nowadays it's hard to tell. So we must be content to give you an insiaht, or save you some cycles, and to welcome further contributions of items, new or used. The classification of items into sections is even more illogical than necessary. This is because later elaborations tend to shift perspective on many items, and this elaboration will (hopefully) continue after pUblication, since this text is retained in "machinable" form. '~e foraive in advance anyone deterred by this wretched typography. People referred to are from the A. I. Lab: Marvin Minsky Bill Gosper Michael Beeler John Roe Richard Stallman Jerry Freiberg
Rich Schroeppel Michael Speciner Gerald Sussman Joe Cohen David '~al tz David Silver
once at the A. I. Lab but now elsewhere: William Henneman Jan Kok Rici Liknaitzky George Mitchell Peter Samson Stuart Nelson Rollo Silver Roger Banks Mike Paterson at Digital Equipment Corporation: Jud Lenard Dave Plumer Ben Gurley (deceased) Steve Root elsewhere at M.I.T.: Gene Salamin Eric Jensen Edward Fredkin PDPI hackers Frances Yao
once at M.I.T., but now elsewhere: Jackson Wright Steve Brown Malcolm Rayfield in France: Marco Schutzenberger Henry Cohen Bill Mann
at Computer Corporation of America: at BBN: Robert Clements
CAVEATS: Some of this material is very inside excuse cryptic references.
page 2 many readers will have to
The label "PROBLEM" ~oes not always mean exercise; if no solution is given, it means we couldn't solve it. If you solve a problem in here, let us know. Unless otherwise stated, all computer programs are in PDP6/l0 assembly language. CONTENTS, HAKMEM 140
3 6
10 12 13 2S
26
30
36
45 45
46
48 51
54
61 67 72
82
87
GEOMETRY, ALGEBRA, CALCULUS RECURRENCE RELATIONS BOOLEAN ALGEBRA RANDOM NUMBERS NUMBER THEORY, PRIMES, PROBABILITY AUTOMATA THEORY GAMES PROPOSED COMPUTER PROGRAMS CONTINUED FRACTIONS GROUP THEORY SET THEORY QUATE RN IONS POLYOMINOS, ETC. TOPOLOGY SERIES FLOWS AND ITERATED FUNCTIONS PI PROGRAMMING HACKS PROGRAMMING ALGORITHMS, HEURISTICS HARDWARE Figure la, Ib
2
3a, 3b
4
Page
19, 20 21 31, 32
34
50 58,
5
59
6a, 6b
7 8
9
62 66
84
Binary integers radix iI, i+l. Radix iI fraction parts (Knuth). Squared square, rectangle. Square, hexagon dissection. Hexiamond solutions. "clock hands" series. Binary numbers radix 2. "C" curves. Incremental curve drawing.
(1/12)! and (2/l2)! are sufficient to express (N/12) I for all N. Thus the three cases above are of dimensionality two. On the line: 1 they do not converge 2 there is a tiense set of points which involve division by zero 3 there is a dense set of points which loop. you may be doing exact computation of the imaginary part (0). Example: X2 + 1 = 0. hence stay on the line. but roundoff error propagates so all loops are unstable 4 being on the line is also unstable (if the roots are imaginary and you are on the real axis.) . The reflection and multiplication formulas: Z!(Z)! = nZ/sin nZ (NI)/2 ( 2n) N NZl/2 (NZ)! = Z! (Zl/N) I (Z2/N) 1 ••• (Z. PROBLEM: Find some order to this dimensionality business. how many regions are there? In particular. XO = random real floating point number." ********************************************* GEOMETRY.(NI) /N) I ITEM 2 (Jan Kok): PROBLEM: Given a regular ngon with all diagonals drawn. CALCULUS ********************************************* page 3 ITEM 1 (Schroeppel): (1/3)! and (2/3)! are interexpressible. Thus these two pairs are of dimensionality one. Points on either side converge to the closest root. ALGeBRA. (1/4)! and (3/4) 1 are interexpressible. (1/3)! and (1/4) I are sufficient to express (N/12) 1 for all N. how many triple (or Ntuple) concurrences of diagonals are there? ITEM 3 (Schroeppel): Regarding convergence of Newton's method for quadratic equations: Draw the perpendicular bisector of the line connecting the two roots. (1/10)! and (2/l0)! are sufficient to express (N/lO)! for all N.
4AC): (as the discriminant ofAX .Z.i element i<i i i iI is ROOT (The discriminant is the lowest degree symmetric function of the roots which is 0 when any two are equal.4 G3 H2 + F 2 G2H2 + 1 * [144 GH 2 .4 F'H 3 . if I > N I if I • 0 X*f(ll. i o f(liX. the discriminant of Xlt FX 3 + GX2 + IIX + 1 is 2 + 8X + C is 8 2 .Y. the discriminant of an nth degree polynomial is n (ROOT .4D.Y.ITEM 4 (Schroeppel): page 4 + »y Mathlab.28.192 Fli .) ITEM 6 (Schroeppel): If A is the first symmetric function of N variables ~ X + Y + Z + ••• and 8 is the second symmetric function of N variables = XY + XZ + ••• + YZ + ••• (8 = sum of pairs).128 G2 + 144 F 2 G .Y •••• ) is the Ith symmetric function on N variables. ••• )*S • .ROOT )2 ~ square of determinant whose i. ITEM 7 (Gosper): If f(liX.4 p 2 G3 ] 2 * . Xlt + ylt + Zit + •••• Ait _ 4A 2 8 + 28 2 + 4AC . ••• ) + f(ljy..6 F 211 2 . X3 + y 3 + Z3 + •••• A3 _ 3AB + 3C.27 Hit + 18 FGII' .27 Fit] + 1 256 I ITEM 5: In general.Y.Z •••• ) (NI variables) The 2enerating function is simply N 1=0 I (I+XS)(I+YS)(l+ZS) ••• 1: f(liX.Z. ••• ) . then X2 + y2 + Z2 + ••• = A2 .80 FG 2H + 18 F 3 GH + 16 Git .
since his eqs. ( . Show that for N>2. 3) Stereographically project Nspace onto an Nsphere. I I IF(B) + 2 I 1[_]2 + [ IF(B) 2 F' (D) 3 ]3 where K is one of the three cuberoots of 1: 1. there exists ~ 1 typo. to Nonlinear Differential and Integral Equations (Dover). Z3 are roots of Z3 + 2BZ 2 + (B 2 • 4D)Z . ITEM 11 (Salamin): The following operations generate onetoone conformal mappings of Euclidean Nspace onto itself.\ ITEM 8 (Schroeppel): Solutions to F(X) = X3 . then 2X = I!f + I!! + I!! Zl.K * r I I IF(B) + 1[_]2 + ( IF(B) 2 F' (B) 3 ]3 2 I _ K2 * . The choices of square roots must satisfy (IZT) em) (1Z3) • c. Unfortunately. (7) and (13) are inconsistent. the general quintic can be solved exactly by use of the elliptic modular function and its inverse. p. 1) Translate Nspace. rotate the sphere. conformal maps can be obtained by analytic functions. ITEM 10 (Salamin): An easy solution of _4X 3 + 3X . In a similar manner. then project back onto Nspace. then for N=2.1 I:J) I 2 • ITEM 9 (Schroeppel & Salamin): If X~ + BX 2 + CX + D • 0. If the onetoone and onto conditions are removed. See Davis: Intro.1 + 1=3) I 2 .C2 • o. . 172. Z2.3BX 2 page 5 + CX + 0 • 0 are B . (. no new conformal maps exist.a • 0 is X = sin((arcsin a)/3). PROBLEMS: Show that all such conformal maps are generated by these operations for any N. 2) Expand Nspace about one of its points.
1) = the (multiplicative) identity. This is just (AX+B)*(CX+D) mod X2 Xl. 1 Inverse: (A. thus pushing the minimal binary addition chain counterexample to 30 (Liknaitzky). (See Knuth vol. This method generalizes for other polynomial roots. Define addition and scalar multiplication as with ordinary vectors.0) and square iteratively. we have the multiplication rule: (A.************************************************** page 6 RECURRENCE RELATIONS ************************************************** ITEM 12 (Gosper & Salamin): "the Fast Fibonacci Transform" (motivation for next item) Define mUltiplication on ordered pairs (A.. which can be computed in log N steps by repeated squaring. (A. Observing that (1.B)(C. and even e and 10g(X. and so is associative. being an improvement of the method of Bernoulli and Whittaker (Rektorys. p 1172). we can (X.O) • (F(N+I). 1 (1. equate it with scalar 1.AC+BD).D) = (AD+BC+XAC. F{N+l) • XF(N) + YF(Nl). the ratio will converge to the larger root of x 2 _x_l (.B){1. by using power series and Newton's method. If we start with (1.BD+YAC).0) = (FIB(N). N 1 Two for the price of one: (F(l). which.D)=(AC+AD+8C. For the general second order recurrence. .0) • (FIB(1). backs up one Fibonacci step (further complicating the addition chain question).A+B)/(B 2 +ABA 2 ) . (1.XA+B)/(B 2 +XABYA 2 ) .1). etc.FIB(2» = (1.Y). p 398.YF(N».YF(O»(l. so we can compute rational functions when the denominator isn't zero. FIB(lS) is best computed using N = 16.) By the last formUla.A).B) • (A. the golden ratio) about as rapidly as with Newton's method. We note (A.FIB(l» • (0. Now. for instance. which is the Fibonacci N iteration.Y) compute fractional Fibonaccis.0) 0 • (FIB(O) .0)=(A+8.FI8(Nl». as a mUltiplier. Survey of Applicable Math. Thus.B) = (A. 2.B){C.
page 7 (1) XO. j. o nl Consider the algebra with basis vectors nl A . so we get A • L n Ln k Suppose the procedure works for k < L. PROOF: If  k < n. Xl. \'1 are vectors and W • U V. C = (X nl 1 0 the unique vector which when multiplied by X yields XO • C A + ••• + C m A • A •  . then componentwise W (2) (3) = i 1: T U V. V. C A + ••• + C A k nl kl 0 kn ITEM 13 (Salamin wi th A gi ven as ini tial values. nl 0 Thus if U.. ••• . X • X X nl Ln X + ••• +C) X • (C nl o Ll Ln + ••• + C X =C X o nl m L The procedure evaluates each X to A . ••• . is already a basis vector.\ & Gosper): LINEAR RECURRENCE RELATIONS Recurrence relation: A.k ijk j k procedure yields A : k combination of the basis k • A (0 < m Computation of X can be done by kn+l applications of (2) or by computing the T's in (3) and then applying (3) O(log k) times.  (4) .. X QED 0 Ln L nl Ll The same procedure will work for negative k using nl 1 n2 X X C )/C . X2 . X n nl and the identification X • C X + ••• + C Xo.. so X evaluates to 0 < k m < n).
Then V is a field iff F(X) is irreducible in the field of the coefficients of V.page 8 Let (2) be F{X)~O and V be the algebra constructed above. (This is true even if coefficients are not constant. If G(X) H(X) ~F(X). 69. Since P has an inverse. then GCD(P. 9..37 have a common difference of 2. (I) is independent of I and J.cos (K arccos X) If A(I). we form 1.(X3+3XY)*F(N) + y3*F(N3). e.X/I=4Y) where T(KiX) is the Kth Chebychev polynomial . DEG G. This rate doubling formula can be applied iteratively to compute the Nth term in about log N steps. This is sufficient to guarantee that some term further left will differ from the left one by that same (halved) power of 2.Y*Q(K) pel) • X Q(l) 1C . since any two independent sequences form a basis. PROOF: Note that an element P of V is zero iff P(X)=O mod F(X). to get the 69th term given terms 1 and 2.II < DEG F.V *F(N2). (X 2 +2V) *F(N) . 2. DEG{GCD(P. provided the inverse exists. 13.) . Let P be an arbitrary nonzero element of V. Then Q(X) peX)l mod F{X). so there exist Q{X). then the product of two nonzero elements is zero and so V can't be a field. The rate tripling formula is F(N+3) .21. 5. ••• . BCI).2(Y) *T(K. e. and C(I) obey the same second order recurrence.  Y P(O)  2 Q(O) • 1 Q(K) • (Y) 1/2 pel) .in): Yet another way to rapidly evaluate recurrences is to observe that if F(N+l) = X*F(N) + V*F(Nll.. R(X) such that Q{X) P(X) + R(X) F(X) • 1. 3. 21.F» < DEG P < DEG F.g. then F(N+2). V is a field. If F(X) is irreducible. ITEM 14 (Gosper & Sala. For the Ktupling formula: F(N+K) ~ P(K)*F(N) + Q(K)*F(NK) P(K+l) • X*P(K) + Y*P(Kl) (the same recurrence as F) Q(K+l) .F)=l. 37. so that term 37 can be found from term 5 and term 21 using the fourth application of the rate doubling formula. This sequence is computed from right to left by iteratively sUbtracting half the largest possible power of 2.g. 5.
whose degree is N2. ITEM IS (Chebychev): The Nth Chebychev polynomial T(N) = T(N. ITEM 16: tan (n arctan x) n N N = * i I ( 1+ i x) n ( 1+i x)  n (1. we get FIB(N) = (2P(N+I)P(N»/S. which is a complex but otherwise square root free closed form. the invariance (I) implies: A~+J J A A Q+I+K A A Q+J+K Q+J+L 1 A R+K A • R+L A PQ+R Q+I+L These matrix relations generalize directly for Nth order recurrences.page 9 Plugging in F and P as defined above.. ("P'!'N)2y. we get an expression for the Nth term of the general second order recurrence in terms of peN) and P{N+I): [peN) P{N+I)] [P{O) P (I) P(I) ] I [F(O) ] P(2) F(I) = F (N) • Setting X = Y = I. N is the polynomial of degree < N which stays closest to x in the IN interval (1.T(O» (1.i x) n + (Iix) . Generating function: E T(N)*S = (lxS)/(12xS+S 2 )..BUAC).. where (A.T(NI). First order (nonlinear) recurrence: T(N+I) = xT(N) . T{O) = I.2 T(N). (~.B)(C. (T(N+I) .D) = (AD+BC+2xAC.I. deviating by at most 2 at the N+l places where x = cos(K*n/N). T{ I) = x.1).T(N» = (T(I) . ••• N. N IN T(N. K=O..0) .T(M» clearly • T(NM)... )"'!""(I_t. T(N+I) • 2x T(N) .{(I_x 2. x . 2i) With constant coefficients.x) = cos (N arccos x).
Camp. MAJORITY(P. . Sometimes an infinite string of zeros is extended to the right.354 • 2 * 359 * 10903 7 6 431 Zeros fill out the unused portion of the quadrant. The given functions are allowed to have X (don't care) entries for some values of the variables. The number of partitions of N. Feedback is not allowed. but nO one has been able to discover the generating function.828. P{N). Q. A related puzzle: A partition of N is a finite string of nonincreasing integers that add up to N. is not a very well understood function. find the number of maps from one to the other that are compatible with the ordering. F. one can define cubic partitions with entries in the first octant. P) (T. Similarly. Some counts for cubic partitions and a discussion appear in Knuth.********************************************* page 10 BOOLEAN ALGEBRA ********************************************* ITEM 17 (Schroeppel): Problem: Synthesize a given lo&ic function or set of functions using the minimum number of twoinput AND gates.R) requires 4 AND gates. F. but the entries are in a twodimensional array (the first quadrant) instead of a string. m n m k The generating function is t Pen) x a 1 I n (Ix) • nO kl A planar partition is like a partition. P 0 R Q) N (Ouchl) from 0 to 4 sugeest that a formula should exist. P AN D Q. ITEM 18 (Speciner): number of monotonic increasing Boolean N functions of N variables o 1 2 3 2 (T. A planar partition of 34 would be: 1 3 1 322 1 4 5 6 168 • 8 * 3 * 7 7581 • 3 * 7 * 19 2 7. The hope is that the best Boolean networks for functions might lead to the best algorithms. 1970 or so. P XOR Q requires three AND gates. P. A difficult generalization: Given two partial orderings. F) 3 6 20 (T. Thus 7 3 3 2 1 1 1 is a partition of 18. NOT gates are assumed free. but 5 and 6 are discouraging. PL(n). "PQRS is a prime number" seems to need seven gates. The number of planar partitions of n. filling a halfline.Q. m n m k k The generating function is t PL(n) x • 1 I n (Ix) • nO k=l No simple proof of the generating function is known. Entries must be nonincreasing in both the x and y directions. is a fairly well understood function. Math.
Using capital letters only. Clue: (Stopl Perhaps you would like to work on this awhile. H. If you object to superimposed boundaries. the five characters B. ITEM 22 (Gasper): PROBLEM: Given several binary numbers. and C. ••• ). ITEM 20 (Roger Banks): A Venn diagram for N variables where the shape representing each variable is convex can be made by superimposing successive Mgons (M = 2. 8. The three characters I. n for any n. which when ANDed with each of the original numbers preserves their distinctness from each other? What about permuting bit positions for m~nimum numerical spread. . ITEM 21 (Schroeppel & Waltz): PROBLEM: Cover the Execuport character raster completely with the minimum number of characters. then taking the low several bits? ITEM 23 (Schroeppel): (A ANU B) + (A OR B) = A + B • (A XOR B) + 2(A AND B). Find a general method of solving such problems. ITEM 24 (Minsky): There exists a convex figure n congruent copies of which. every other side of which has been pushed out to the circumscribing circle.) Lemma: Functions synthesizable with one NOT are those where the image of any upward path (through variable space) has at most one decrease (that is. using an arbitrary number of ANUs and ORs. 4. how can one find a mask with a minimal number of I bits. form a Venn diagram of 2 regions. B. V and X is a minimal solution. Hand' works. you may shrink the nested Mgons a very slight amount which depends on N. and NOTC from A.ITEM 19 (Schroeppel): page 11 The 2NOTs problem: Synthesize a black box which computes NOTA. NOTB. I. but only 2 NOTs. from T to F).
For example.HI ibitwise exclusiveor of A and HI replaces both This suggests a susceptibility to analysis of mechanical code machines.HI iregister A gets loaded with "high" word MOVE B. Calculate r • Ilog x. See LOOP DETECTOR item in FLOWS AND ITERATED FUNCTIONS section.3S. ITEM 27 (Salamin): PROBLEM: Generate random unit vectors in'Nspace uniform on the unit sphere.LO iregister B gets loaded with "low" word MOVEN A.1] and y uniform on [O. ishift the 72bit register AB left 3S XORB A. can be inverted.2W].********************************************* page 12 RANDOM NUMBERS ********************************************* ITEM 2S (Schroeppel): Random number generators. and give as values only some part of their internal state. which use SHIFTs and XORs. such as Rollo Silver's favorite. the outputs may often be used to obtain their total internal state. Rollo's is: RANUOM: MOVE A. Also.LO iregister A gets stored in "low" word LSHC A. 2 consecutive values from Rollo's suffice to allow prediction of its entire future. Then r cos y and r sin yare two independent Gaussian distributed random numbers. . ITEM 26 (1 via Salamin): A mathematically exact method of generating a Gaussian distribution from a uniform distribution: let x be uniform on [0. SOLUTION: Generate N Gaussian random numbers and normalize to unit length. x and y independent.
333. (2) less than rx is about 4. . ITEM 29 (Schroeppel): For a random number X.667 • (10 12 + 2)/6 166.86\. the probability that the largest prime factor of X is less than 2tx may be a fraction independent of the size of X.666. 351354. 2 . using T ::I 10 1 . was factored on Tuesdf~' January 5. but 166.I. SOOT .669 is not.4 10 3 TO 252 40 48 :252 ::I 10 252 TO 100 7 8 1.666.666.••••••••••••••••••••••••••••••••••••••••••••• NUMBER THEORY.y.5T + 1. M137 was factored on Frid.333. 11.1 ::I 32032 21559 64964 35569 • 54 39042 18360 02042 90159. 1971.667 is prime. are: 40T + 1.3. The number of primes in 10 1 + 1 to 10 12 + 10018 is 335. Various primes. RELEVANT DATA: ([ ] denote the expected value of adjacent entries.333 is ~rime. SOOT . 2. the 125th Mcrsenne 125 number.666.  11.666.1. 1971 in about 50 hours of computer ~ime: 2 11 . the prime number theorem predicts 363 in this range. This is relevant to Knuth's discussion of Legendre's factoring method. 62.666. vol. The primes which bracket 10 12 are 10 12 + 39 and 10 12 The primes which bracket 10 15 are 10 15 + 37 and 10 15 The number 23. p. This suggests that similar probabilities are independent of X: for instance. the probability of its largest prime factor being (!) greater than If is In 2. John Brillhart at the University of Arizona had already done this.7 100 TO 52 1 1 :52 ::I 10 51 TO 1 o o where: "COUNT" is the number of numbers between 10 12 + 1 and 10 12 + 10018 whose largest ~rime factor is in "RANGE".) COUNT CUMULATIVE SUM OF COUNT RANGE 12 10018 10 TO 10' 7198 [6944] 10' TO 10" 2466 2820 10" TO 10 3 354 402 [487] 2.666. July 9.666.666. ITEM 30 (Schroeppe1): Twin primes: 166.7. PRIMES. 200T . in 371 seconds run time as follows: 21 1 • 31 • 601 • 1801 • 26 90898 06001 • 4710 88316 88795 06001.669 The number 166.666. PROBABILITY page 13 ••••••••••••••••••••••••••••••••• * ••••••••••• ITEM 28 (Schroeppel): After about 40 minutes of run time t~ verify the absence of any nontrivial factors less than 2 3 .
(In 2)/(ln 3) since primes are much more common than N ITEM 36 (Schroeppel): PROBLEM: How many squares have no zeros in their decimal expression? Ternary? . 5.979.333 and 1. P2.XX just keeps getting copied. 7" 15) were found.XX is a known solution for N • 5 XX. P3 in arithmetic progression.11) • integer (by induction).339. the (In 2)/(ln 3) uensity of such sets approaches zero.ITEM 31 (Schrocppel): N page 14 2 Ramanujan's problem of solutions to 2 . N the (1 .979. and seems to have a cluster point at zero.339. PROBLEM: Is it nonuniform? ITEM 33 (Schroeppel): Numbers whose right digit can be repeatedly removed and they are still prime: CONJECTURE: There are a finite number of them in any radix. other half are probably uniformly distributed) 1 + 12 . 3 + I! is suspicious.g.I!) goes to zero. we expect the fraction part to be uniformly distributed. probably like N XX.similar to 1 + I! 6 any algebraic number whose conjugates are all inside the unit circle Now. ITEM 35 (Schroeppel): Take as many numbers as possible from 1 to N such that no 3 are in arithmetic progression.XX •••• XX. CONJECTURE: As N + ~. 4. only his solutions (N • 3..XX is a known solution for N • 14 Conjecture that XX. the longest being 1.339. It has recently been proven that these are the only ones. 5 • 11"31T. If the (In 2)/(ln 3) N can be proved.Proof: N N (1 + I!) + (1 . Some exceptions: 2 3 1 . ITEM 34 (Schroeppel): PROBLEM: Can every positive integer be expressed in terms of 3 and the operations factorial and / integer square root? E. it follows that there are infinitely many primes PI. 5 2 + I~ . Another Ramanujan problem: Find all solutions of nJ + 1 I: x 2 • ITEM 32 (Schroeppel): Take a random real number and raise it to large powers. In decimal there arc 51.7 • X was searched to about N I: lO~o.~ I: (1 + 1!)/2 4 all 1 < X < 1 12 (half are integers. it looks nonuniform.
. with 50 digits the likelihood is 95%. 1. any straight line with rational slope through such an array will always go through a geometric sequence with common a b b ratio of the form n (n·l). east by southeast knight's moves give the powers of 12: 1.• . for n • 4: 1 4 16 64 256 3 12 48 192 9 36 144 27 108 81 In fact. 1. construct a string of digits which at no time has any segment appearing consecutively twice. ••• powers of n is (nl) • E.g. 12..ITEM 37 (Gosper): page 15 The number of n digit strings base B in which all 8 digits occur at least once is just the Bth forward difference at o of the nth powers of 0. "'~. ITEM 38 (Fredkin): By the binomial theorem. for n a 4: o 1 16 81 256 625 1 15 65 175 369 14 50 110 194 36 60 84 24 24 o so there are 14 (a 2~2) such 4bit strings. N = 2 + finite maximum string N = 10 + known infinite Uetermine maximum string length for N • 3. 27 (= 10e?) random decimal digits are required before it is more likely than not that every digit has occurred. the bth forward difference at 0 of the 0. is T((N . 2. uniformly distributed random inteier variables which range from 0 to N1. •••• ITEM 39 (Schutzenbcrger): PROBLEM: Using N digits.g.. 24 (a 41) such quaternary. inclusive. 36 such 4digit ternary strings.1)/12). •••• E. In the above. SUBPROBLEM: How many sequences exist of any particular length? ITEM 40 (Gosper): The variance of a pseudoGaussian distributed random variable made by adding T independent. and 0 for all higher bases. 144.
Bl. Ii71 ARCERF(1/4) • . L • los~r's score. 'This product • . P 2 .B. C.C.155 = the fraction of rationals with denominators containing odd primes squared • 1 . be salvaged by quantities like 171. ITEM 44 (Gosper): Recurrences for mUltinomial coefficients: (A. PROBLEM: If somehow you determine A should spot B 6 points for their probabilities of winning to be equal.C ••• ) be the mUltinomial coefficient (A+ B+C••• ) ! / A I B 1C I ••• This is equal modulo the prime p to (AO. Redouble.84533064 ± a smidgen.B. ••• )(A. and is not even salvaged by the hypothesis that all primes> a million satisfy the congruence.BO. Gosper): When the initial angle is a rational mUltiple of n. The exponent of the largest power of p which divides (A.CO ••• )(Al. This errs by 16 times the correction factor one expects for 1093 and 3511. (This is related to the fact that 1093 and 3511 are the only known primes satisfying 2 = 2 mod P ). however. eventually periodic) iff the denominator contains as a factor the square of an odd prime other than 1093 and 3511.B. step. ••• ) • (A+B.B) • (A+B+C. it seems that your locus is bounded (in fact.B. step again.155? About .C2 ••• ) ••• where AJ is the Jth from the right digit of A base p.Cl ••• )(A2. Can someone construct an irrational mUltiple of n with a bounded lOCUS? 00 such angles form a set of measure zero in the reals. Uouble the angle. alas. how much should A aive C? ITEM 43 (Schroeppel): Let (A. which must occur at least cubed. probably because 9 divides ~(19).C ••• ) is equal to the sum of all the carries when the base p expressions for A. try more conventional methods.C) •••• PROBLEM 45 (Gosper): Take a unit step at some heading (angle). deuce rUle irrelevant.) If this seems silly.IT over odd primes of 1 . etc. It might. For what initial heading angles is your locus bounded? PARTIAL ANSWER (Schroeppel.84534756.l/P(P + 1).ITEM 41 (Salamin): There are exactly 23000 primes less than 2 18 page • 16 ITEM 42 (Gosper): To show that N N+l L N+l L E (BINOMIAL N+L L)*(X (IX) + (IX) X) • 1 LO set N to 20 and observe that it is the probability that one or the other player wins at pingpong. ••• )(A. (X = probability of first player gaining one point. and is not. B. and B should spot C 9 points. But a denominator of 171 = 9 * 19 never loops. Similarly for 9009 and 2525.C.B2. ••• are added up. Thus (BINOMIAL A+B A) mod 2 is 0 iff (AND A B) is not. even though the "measure" in the rationals is about .
can a general test be made which will predict exact length for any number? ITEM 48 (Gosper. p487. (10 X ± 1)2 + 400 y2 seems to express those which are 1 mod 40. 2 or 4 subcycles in the cycle of a prime. 23. the primes have been separated mod 40. which usually determines their number of sUbcycles: PRIME mod 40 SUBCYCLES 1. There can be only 1. 3. The length of powers of primes seems to be powerl L = (length of prime) * prime The length of products of powers of primes seems to be L • least common mUltiple of lengths of powers of primes which are factors. and (15. Primes with 2 subcycles seem to have lengths M L • (prime . Monthly.l)/N. 29 1 or 4 (about equally) 2 (only 2) 1 5 (only 5) 4 Attention was directed to primes which are 1 or 9 mod 40 but have 1 or 4 subcycles. but in the state of lowest disordered energy.20). R covering all integers ~f form 10 K + 1. Primes with 1 subcycle seem to have lengths L a (prime . 31. ITEM 47 (Beeler): The Fibonacci series modulo P has been studied.) The corresponding 3 by 3 is at (104. 25 X2 + 16 y 2 seems to express those which are 9 mod 40. 27 2 11. 37 4 21. 17.ITEM 46 (Schroeppel): page 17 The most probable suit distribution in bridge hands is 4432..6200).21) are all invisible. The invisible 2 by 2 square with smallest X has its near corner on (14. and seem to have lengths L • 2 (prime + l)/R or (prime . 9 usually 2. as compared to 4333.l)/S. A point of the 2 dimensional lattice is called visible iff its coordinates are relatively prime. This series has a cycle length L and within this cycle has subcycles which are bounded by zero members. which is the most evenly distributed.e.21). Math. (14.20). (15. May '71. 19. (I. I . Excellent reference: Amer. 33. 7. 39 1 13. By the Chinese remainder theorem.20). occasionally 1 or 4 (about equally) 3.(1) )/M. This is because the world likes to have unequal numbers: a thermodynamic effect saying things will not be in the state of lowest energy. Schroeppel): . there exist invisible sets of every finite shape. N covering all integers. (14. Primes with 4 subcycles seem to always be of form 4 K + 1. At Schroeppel's suggestion. S covering all integers. M covering all integers except of form 10 K + S. 7 or 9. PROBLEM: Can some of the "seems" above be proved? Also.
Am. Adams. and union of all S(O) is the entire lattice. Math. Let c.) 8 14 12 4 Other length sides are impossible. ITEM 54 (Salamin & Gasper): The probability that a random rational number has an even denominator is 1/3. Lemma 1: In a magic square of order four. So S(D) occupies a fraction X/v 2 of the lattice. ITEM 5S (Schroeppel): GAUSSIAN INTEGERS See following illustrations. then 5(0) intersect S(Dt) is empt{.. a. ITEM 52 (Salamin): The 2 probability that two random integers are relatively prime is 6/n • PSEUDOPROOF: Let X be the probability. This adds to 6K. 7 1 11 19 9 In 1957.page 18 ITEM 49: There is a unique "magic hexagon" of side 3: First discovered hy Clifford W. abef. the sum of the corners is K. S(O) is S expanded by a factor of D from the origin. Therefore X*(l/1 +1/2 2 +1/3 2 +••• ) • I. Proof of magic cube impossibility: Consider a corner x. f be the corners of any two edges of the cube parallel to abe Then abcu. d and e. Proof: Call the corners a and b. or the probability that two random integers have a GCD of D is X/0 2 • If D unequals D'. so X • 6/w 2 • This argument is not rigorous. a+b • K/2. 3 17 18 who worked on the problem from 1910. Proof: Add together each edge of the square and the two diagonals. Let S be the set of points in the integer lattice whose. also PI section. QED ITEM 51 (Schroeppel): By similar reasoning. This covers the square entirely. So a+b+c+d + a+b+e+f + c+d+e+f m 3K. Let S(U) be the set of points whose coordinates have a GCD of D. and each corner twice again. Proof: Let K em 130) be the sum of a row. 10 13 15 ITEM 50 (Schroeppel): There is no magic cube of order 4. and cdef are all the corners of magic squares. but can be made so.x.b+c+d+e+f m 3K/2. the sum of any two corners connected by an edge of the cube is K/2. There are three corners connected by an edge to x. so twice the corner sum is 2K. coordinates are relatively prime. the center of an order 5 magic cube must be 63 = K/5. Games. Lemma 2: In a magic cube of order 4. . COROLLARY: There is no magic tesseract of order 5. ITEM 53 (Salamin): The probability that N numbers will lack a Pth power common divisor is l/t(NP). he found a solution. so that S occupies a fraction X of the lattice points. 6 5 2 16 (Sec Aug. 1963 Sci. Each must have value K/2 .
. l{unning through bit combinations 0. the dot is at the 127th combination (1111111 = 2 + Si).11.1. radix iI.10.Figure lea). ••• . which is merely the last point drawn. the uiagram is a map of values. This diagram is to substantiate the claim that every Gaussian integer has a unique bit combination. The origin is circled.
..0 ..' : .· · . ! "··7 t .. iJashes indicate continuity of curve at confusing places..__...J /' 1 l i ...... ....~ • ..•.. /' . • . : ~ r··a.... . Large circle is origin. As lea).. · : ..·~ ~:.. __L . . a ..........J ._..... •• .1 ~ ..:.... ..... ~.. .. .. ..... The solid and dotted curves are symmetrical about the point marked with a small circle. ... "r~ · . Figure l{b).• ...•. i r· ' ...... &::~~' f. .. I • ... • ".. i I L_.. .. but radix i+l..I • I · : • · • • I f . '...1 ..' ••' '.I'•<116::....1.'.. ' :.' I i • • • • • • ..& A ... Uotted curve is with an infinity of ones to the left (big dot = ••• 1111 = i).... ..
Seminumerical Algorithms. Reading. Similar to lea). Mass. Volume 2. but showing fraction parts as well. The Art of com~uter Programming. Reprinted by special permission from Knuth.+1 +i 1 +1 li i +li Figure 2. . AddisonWesley. 196 .
Gosper): There is at least one zero in the decimal expression of each power of 2 between 2 86 • 77.371. n b) After the nth. 5 3 4 ITEM 57 (Beeler.001 6 7 5. CONJECTURE (Schroeppel): No L > 10. a tendency for there to be many fewer numbers of "length" • 7 is noted. through N • 12. In particular.619 10 10 92. we will see the one composed entirely of l's and 2's.959 12 10 293. decreases with increasing "length". the following shows the maximum "length". December 1969 and April 1970).) nl n But there are only 4 * 5 multiples of 2 which don't end with n zero and are < 10 . we see: a) None end in zero. they are all mUltiples of 2 • nl c) They get into a loop of length 4 * 5 • (Because 2 is a primitive root of'powers of 5. as well as how many distinct numbers (permutation groups of N digits) there are: N MAX L DISTINCT 2 4 54 219 6 714 5 7 2.004 7 8 11.264 and 23073901~.195.309 9 9 48. Assuming there aren't any then raises the question: How many final nonzero digits can a power of two have? ANSWER (Schroeppel): Arbitrarily many. .267. If diaits of such powers were random. which ends ••• 11112111211111212122112.455.252. If we look at the last n digits of consecutive powers of 2.439 8 9 24. where the program was stopped. 11 and 12.336.377 11 10 167.ITEM 56 (Beeler): page 22 The "length" of an Ndigit decimal number is defined as the number of times one must iteratively form the product of its digits until one obtains a onedigit product (see Technology Review Puzzle Corner. Other than this.181. so we will see them all. for N • 10.929 Also. the probabilit~ that there is another zeroless power would be about 1/10~1181. the frequency of numbers of any given N. For various N.
128.700 • 2 2 * 52 * 47 * 9.632 • 2 3 * 13 * 19 * 41.722.776 = 2' * 3 * 11 * 31 = 1111111111000000000 base 2 ITEM 61 (Root): Consider iteratively forming the sum of the factors (including 1 but not N) of a number N.215.524. but also 13 loops of 4 members (lowest member is given): 2 1.277.179 498.460 • 2 * 5 2 * 17 * 3.264. N • 28 = 1 + 2 + 4 + 7 + 14.048. including 1 and N. the first three numbers which are S • 3 N are: 120 • 2 3 * 3 * 5 = 1111000 base 2 672 = 2 5 * 3 * 7 = 1010100000 base 2 523.003.976 = 2' * 11 * 102. N.820 • 2 2 * 5 * 29 * 487 * 617 209. For example. all of whose.801 4.136 • 2 3 * 7 * 109 * 809 7.819 46. "perfect numbers" are those whose loop is one member.324 • 2 2 * 3 * 67 * 877 2.357 18.380 • 2 2 * 5 * 932.739 .938.057 174.000 found the known loops of length 5 (lowest member is 12496) and 28 (lowest member is 14316).580 • 2 2 * 5 * 29 * 4. then "perfect numbers" are S • 2 N." A program to search for loops of length> 2.000.600.ITEM 58 (Fredkin): 3 3 + 4 3 + 53 • page 23 63• ITEM S9 (Schroeppe1): 91038 90995 89338 00226 07743 74008 17871 09376 2 • 82880 83126 51085 58711 66119 71699 91017 17324 91038 90995 89338 00226 07743 74008 17871 09376 ITEM 60 (Beeler): If S • the sum of all integers which exactly divide N.115.416 = 2 3 * 19 * 47 * 69.104 • 2' * 17 * 26.169. members are < 6.580 • 2 2 * 5 * 16.941 81.784.656.500. An example of a twomember loop is: sum of factors of 220 • 284 sum of factors of 284 • 220 Twomember loops are called "amicable pairs. This process may loop.719 2.210 • 2 * 5 * 7 * 19 * 263 * 599 330.551 18.
The 33Sth prime decade is N • 2342770.1.4 arctan (1/239). The first occurrence of two prime decades wi th the 'theoretical minimum separation is N • 1006300 and N • 1006330. 239 • 11101111 base 2. of course. K239 is Mozart s only work for 2 orchestras. which is related to the fact that 2 * 13~ • 1 • 239 2 . N+3. The 239th Mersenne number.) 1/239 • • 00418410041841 •••• which is related to the fact that 1. 239 needs 9 cubes (the maximum. ITEM 63 (Schroeppe1. is known composite.): The joys of 239 are as follows: n • 16 arctan (1/5) . . And 239 is prime. (Although 239 doesn't need the maximum number of fifth powers. N+7 and N+9 are all prime. 2 23 ' . There are 172400 primes < 2342770. 239 needs 19 fourth powers (the maximum) to express it.649. 239 • 3233 base 4.111 • 239 * 4. 28. Guess what memo this is. There are 239 frimes < 1500. arctan (1/239) • arctan (1/70) . etc.arctan (1/99) • arctan (1/408) + arctan (1/577) 239 needs 4 squares (the maximum) to express it. Twomember loops (amicable pairs) are: 220 ++ 284 1184 ++ 1210 2620 ++ 2924 5020 ++ 5564 6232 ++ 6368 10744 ++ 10856 12285 ++ 14595 17296 ++ 18416 63020 ++ 76084 66928 ++ 66992 67095 ++ 71145 69615 ++ 87633 79750 ++ 88730 100485 ++ 124155 122265 ++ 139815 122368 ++ 123152 141644 ++ 153176 142310 ++ 168730 171856 ++ 176336 176272 ++ 180848 185368 ++ 203432 196724 ++ 202444 (Exhaustive to smaller member ~ 196724 and larger member < 2 35 . 8128. 239 • 22212 base 3. ) A prime decade is where N+1. but no factors are known.ITEM 62 (Speciner): page 24 The first four perfect numbers are 6. which is why 239/169 is an approximant (the 7th) of 12. 496. shared only with 23) to express it.111.
"JUMP IF NOT ZERO". given N in one of the counters. Sept. . 26._. given N N 2 2 . finite program containing only the instructions "ADD 1". *********~*********************************** page 2S AUTOMAT A THE ORY ********************************************* ITEM 64 (Schroeppel): A 2counter machine. 1970. (Independently rediscovered by Frances Yao). But (Minsky.7 the number of primes < X1 Shanks and Brillhart claim about X ITEM 66 (Gosper): See spacefilling curve machine item in TOPOLOGY section. but (due to the above) they must have specially encoded inputs. Such machines are known universal. . cannot N generate 2 • Proven Saturday. which refer to either of two unlimited counters.) ITEM 6S (Schroeppel): What effort is required to compute n(X). it can generate 2 (A 2counter machine has a fixed. Liknaitzky). "SUBTRACT 1".
ITEM 69: Berlekamp of Bell Labs has done the 9 squares (16 dots) Dots game. side" center. For lines. a period of 34 is entered after the line is about 80 long. The second player wins iff the indicator is o. the indicator Cas a function of the other leg) seems to become periodic with period 34. On a 6 x 6 board. the 2nd player wins. the 1st player wins. PROBLEM: Find some nonexponential way to compute the indicator of a given position. Playing in the center leaves the null position. For Ls: if one leg is held fixed. indicator 2. On a 4 x N board. the 2nd player wins. throw the zero if 1 < Z < N. he then puts one or more aside and rethrows the rest 2 this throwing is repeated until he no longer has any to throw 3 highest score (dice) or maximum number of heads (coins) wins For poker coins. the 1st player wins by playing at the center of one quarter. Playing on the side leaves a 1 x 3 line. a game as follows: Two players alternate placing X's on a rectangular grid. The smallest number not appearing in our list is 1. Playing in the corner leaves a 3 x 3 L. For two boards (not touching) played simultaneously. indicator 3. For any position. the optimal strategy. This indicator analysis is similar for many other takeaway games" such as Nim. ITEM 68 (Schroeppel): PROBLEM: Solve Blackout.********************************************* page 26 GAMES ********************************************* ITEM 67 (Schroeppel): Regarding "poker coins" game" whose rules are: 1 a player throws N coins. with N coins thrown" is: Z • number of zeros (tails) if Z • 0. Evaluate the indicator of each of these successor positions. save one one" throw the other Nl coins if Z • N" save a zero" throw the other Nl coins The optimal strategy for poker dice is hairier. On an odd x odd board. The last X wins. Example of calculating an indicator for the 3 x 3 board: There are 3 distinct moves possible . The time to enter the period becomes greater as the fixed leg increases. the indicator is the XOR of the indicators for the separate boards. Some theory: The "indicator" for a position is: make all possible moves from the given position. The indicator of the null position is o. quit if Z • 1. indicator o. No two X's may appear adjacent along a side or across the diagonal at a corner.corner. so the indicator of a 3 x 3 square is 1. . the indicator is ~ the maximum game length. The indicator of the first position is the smallest number which is not the indicator of a successor position.
ITEM 73 (8eeler): Sim is a game where two players alternately draw lines connecting six dots.9. 2 Roll two dice. 3 Cover up any digits whose sum is the sum on the dice. also known as Tactix. ITEM 71 (Beeler): There is only one distinct solution to the commercial "Instant Insanity" coloredfaces cubes puzzle. Usually it is best to take the largest digits possible. 4 Iterate throwing and closing windows until the equality of sums is impossible. king at Q82. but not always. is a win for the second player. 5 Your score is the total of closed windows (highest wins). which is how it comes packed. from there on. the strategy branches to a relatively gruesome degree. swiped from "Chess for Fun and Chess for 8lood". however. ¥ . and whether his first move connects with the first player's first move doesn't matter. who on his first move can reply centersymmetrically unless the first player's first move was Bl and B2 (analyzed on RLE PDPI). it also depends critically on the remaining numbers. The second player can always win. by Edward Lasker: white: pawns at QN3 and KN7. knight at QN4.) Mike Paterson has discovered a clever way to solve the puzzle. how many dots are required with 3 players? ITEM 74 (Beeler): The 4 x 4 game of Nim. PROBLEM: 6 dots is minimum to ensure no stalemate with 2 players. bishop at K87. king at QR6. ITEM 72 (Beeler): A windowdice game is as follows: 1 The player starts with each of nine windows open.. black: pawn at QN3. The first person to form a triangle in his color loses. (Independently discovered by Dave Plumer. showing the digits 1 . An optimum strategy has been tabulated. White mates in three moves. . ITEM 70: page 27 A neat chess problem..
A B C G H I N P Q V W X 3 D E J • Y F K L M 5 T U Z I 2 4 S 6 7 8 From the starting position. This is the ending position. you can win from the complement of any position you can reach. . (T Q 4 R 1 L J II \'1 Y M J) leaves: A 0 C 0 E F G H • L • U N • • V W • • • 1 2 5 3 6 7 8 ··. then complement the board. This debunks the heuristic of emptying the arms of the plus first and then cleaning up the middle. because there are just as many dual games which empty out the middle first and then the arms! The program found one counterintuitive win which at one point left the center nine empty but had ten in the arms. Rayfield): page 28 A 1963 PDPl computer proaram gave us some interesting data on the traditional game of peg sOlitaire (33 holes in a plus shape). Brown. complement the board. · then (8 V A C/O 2 6 G M F/K 5 8 I Y V 3 Q A II E). By induction. • • • • • • • • P • • • • • T U V W • • 4 • 7 • By dualizing and permuting a solution from the folklore. This is a position one move from a win.ITEM 7S (Gosper. we found a similar winning position with 20. Now from the starting position. • B • DE. Thus every successful game has a dual game whose positions are the complements of the original ones. make one move.
15 5 13 Removing only one. 13. • • • • • K Q • • • • • • X Y Z 1 2 345 678 ITEM 76 (Beeler): Triangular HiQ (or peg solitaire) is IS pegs in a triangle. in which it found two basically different wins. the program simply scanned lexicographically (left to right in the inner loop. a c a b a c d c a b a c a b a d c b a b a c d c b a b a d c b a . Thus the four pegs which can reach the center on the first move are the only ones that ever can. 7/4. 11.. 9. 1. 10. 4. 11. 3. Similarly. 2. then jump as follows: 6. At one point. 13 2 2. 13. and thereafter pegs jump others. there is a peg which can move two ways. etc. An example is: remove peg 1. 6. it chose west. The program's main heuristic was to reduce the larger classes first.page 29 Another useful observation is that the pegs and their orieinal hole positions fall into four equivalence classes in which they stay throughout the game. With its heuristics disabled. 12/13. Starting with peg 1 removed. (Try it yourself. 14 4 3 a 12. With pegs numbered 1 at the top.016 positions are attainable (not turning board). leaving p~g 1. 2 and 3 in the next row. then top to bottom) for a peg which could move. 4. . no way exists to get to either 1 + 11 + 15 (tips) or 4 + 6 + 13 (centers of sides). the peg jumped over on the last move must be in one of the two classes of eight members which get reduced on the first move. REMOVE CAN END WITH ONLY THE PEG 1 1. 7 = 10. which are removed. 6.. Twelve moves from the end it stopped and went into an exhaustive tree search.306. • • ·. 15.) ·. One peg is removed. 14/13. the sum of ways to get to each of these is 10.
PROBLEM 79: Solve the tiger puzzle. which has not been independently checked. a curious thought is into how many dimensions does the average.72 < limit as N goes to infinity of Nth root of number of po1yominos of order N (including those enclosing holes) < 4. IN ORDER OF INCREASING RUNNING TIME (Schroeppel) **********************. page 30 PROPOSED COMPUTER PROGRAMS. someone constructed a squared rectangle with sides in the ratio 1:2. knight.* •••••••••• ****** •••• **. Smallest known has 24 small squares (Martin Gardner's Scientific American Book. pages 122 .* •••••• *•••••••••••••• PROBLEM 71: Count the polyominos up to. unequal squares).**. Atkin & Birch. pages 201 and 213: ORUER E.. say. It also gives bounds 3. Polyominos may he constructed in 3space (Somalike pieces) or higher dimensions.5. Academic Press. See also the following two illustrations. ed. a sliding block puzzle mentioned in Scientific American February 1964. From Applied Combinatorial Mathematics.06 • (N ) * constant.130. 2. . It contains 1353 squares. order 20.*.02 4. no double pawn moves). PROBLEM 80: Find smallest squared square (a square composed entirely of smaller. and 3 pawns. II. Recently. and the opponents are shoved closer together (1 empty row intervening.*****. 1971. chess played on :1 5 x 5 board where each side has lost the king's rook. 20omino extend? PROBLEM 78: Solve "minichess". NOT ENCLOSING HOLES I I I 211 322 455 5 12 12 6 35 35 7 108 107 8 369 363 9 1285 1248 10 4655 4271 11 17073 12 63600 13 238591 14 901971 15 3426576 16 13079255 17 50107911 18 192622052 The order 13 through 18 data is from Computers in Number Theory.*******. vol.*.98±. bishop. say. Also an asymptotic formula for the number of polyominos: N . page 206).
The smallest known '(in 1961. .39 55 16 44~5 3 1 20 18 ~ 81 14 56 38 30 51 31 64 33 2 29 8 43 35 Figure 3(a). New York. Simon and Schuster. 1961. New York. The Second Scientific American Book of Mathematical Puzzles and Uiversions. Reprinted by special permission from Martin Gardner. and yet today as far as we know) squared square.
. . N \n 0 .. semiperimeter is 1637033 = 419 * 3907........."a string processing language written by Samson..'" ~ \n tt\ ~'" ~$ ... 11ft ~  ~ ~. ~......~ ~ er flO M :r........ . This has 28 squares... ~J ...... " ~ ~ ~ . '" ". .. ~  tf' 0 c( ~ r ~ .. \6:l... \)0 tP 0 \0 .. •~ ~ ..t' S ~ 00 ~ () () N N 0" N 0 '6 ~r ~ . ....I ~ ~~ " .... ~ . which is more than most published squared rectangles. $ .... lP ~ 0 ~ ... N \n ..'ll 0 cr ~ fP I( ..... " 0 ~ \on fI\ I'" 0'eIO ~ \n " . A squared rectangle found by Schroeppel using "String Handling Interpretive Translator... "' '" I 0 :t .D \. . tl :r .. cr ~ ~~ " ::to ~ ~ . ... ... ~ 0 ~ ~  ~ Figure 3(b). ...... Sides are 884808 = 2 3 * 3 2 * 12289 and 752225 = 52 * 30089.... fllC .... 0 ~ r.. \C\ ~ tf) e..
2 The two players may each have a full complement of 12 pentominos. 4 pieces (proven minimal). F skips the value 6. PR08LEM 83 (Gosper): Compute the integervalued step function F(R). ("Geometric Uissections" by Harry Lindgreen. 4 The last player to place a pentomino wins. or they may "choose up" their half of one set. the following are known: a triangle into a square. and probably 18. O<R<l. Pentominos must not overlap. not counting rotations and reflections. Rules: 1 The checkerboard is for aid in orienting only. the groups of 256 clements (estimated: 11000). How many and how big are the gaps in the range of F? What happens in n dimensions (including n = infinity)? PROBLEM 84: Solve pentominos on an 8 x 8 checkerboard game(s). PROBLEM 85: With regard to dissection theorems. 3 Players alternate placing pentominos on the board. A program can probably check th~ known dissections for minimalityl See following illustration. count) the semigroups of 7 clements. also. the number of circles of radius R which fit into a unit circle. There are about 320 million. for example. ~ .page 33 PROBLEM 81: Count the magic squares of order 5. PROBLEM 82: List (that is. Scientific American November 1961). 6 pieces (best known) etc. a pentagon into a square. black and white are the same.
adapted from page 164 of the November. A surprising square ++ hexagon dissection.Figure 4. . 1961 issue of Scientific American. which see for further diagrams and discussion.
but you can pile up triple checks. Taking your opponent's king is verboten. although you can choose which capture to make 2 pawns Blust be promoted to queens 3 king is just another piece 4 player to give away all pieces first wins PROBLEM 88: Analyze "escalation chess". also. lie may not move into check. black 2. p.44. coverings appears to be twice a square. white 3. he must get out of check on his first move. one side is hopelessly lost. Prove the pawns win.page 35 PROBLEM 86: Find the number of domino coverings for various objects. There are about 10~o possible positions. etc. in most of them. W. Article by E. chap. if side ~od 4 D 2. About 10 170 positions. "Tecko. See Applied Comb. the first player can always win. where white gets 1 move. one at a ti~e. Programs below this line are considered unfeasible. a king.6. and two moves to white's one. The consensus is a win for the first player. PROBLEM 89: In the game "4 pawns". Math.121. There are about 10 12 positions. A player is checkmated if he can't get his king out of check on his first move. The first player wins on 4 x 4 x 4 x 4. their 4 counters each. through order 7 have been analyzed by hand. on a square board. Montroll. PROBLEM 92: Solve TicTacToe on a 4 x 4 x 4 board. the worst the first player can be forced to do is draw. etc. in which there is no draw. after which the counters are moved around (including diagonally). (Computing time currently estimated (Schroeppel) at 1 year). PROBLEM 90: Solve Scarne's game. Black is allowed to move through check. with lIex. PROBLEM 96: Solve Go. coverings appears to be a square. PROBLEM 87: Analyze giveaway chess. PROBLEM 94: Solve Hex on large boards (11 to 23 on a side). if side mod 4 • 0. 105 . PROBLEM 91: Solve "fiveinarow" on an infinite board. which is as follows: 1 captures must be made. 4 in a row or square wins. black has 4 pawns. . PR08LEM 95: Solve chess. The object in this game is to capture the king.. For example. PROBLEM 93: Solve checkers. Thus. but it's unproven. There is a proof that in games where having an extra move can never (repeat: never) hurt you. 4." which is played on a 5 x 5 board by two players who alternate placing. an asymptotic formula is known for rectangles. If a player is in check. on a square board.
1.********************************************* page 36 CONTINUED FRACTIONS ********************************************* ITEM 97 (Schroeppel): Simple proofs that certain continued fractions are 12. 2. 2. A+20. (Xl)(X+l) • [0. 1. ••• IJ. 2.1 • 1 l Proof for X • I! V • [1. 2. 2. ••• l * [2. 135. ••• l.1 • 2 I: Similar proofs exist for IS and 16. 4. 2. 2.46) is [0. 1. A+3D. 6. 1. 2. 2. 43. 2. Proof for 12: X • (1. ••• l * [0. 2. 2. 2. 1. I. ••• l • 1 X2 . A special case is [1. 1. but 11 is hairy. ITEM 99 (Schroeppe1): The value of a continued fraction with partial quotients increasing in arithmetic progression is I (2/D) A/D I IJ [A+D. 2. 4. ••• l • 2 VI . ••• l • (2/0) l+(A/D) I (2) (2) where the I's are Bessel functions. 63. 1. 2. ITEM 98 (Schroeppe1): The continued fraction expansion of the positive minimum of the factorial function (about 0. 2. 2. 3. 2. 1. 1. etc. 1. 2. ••• l (V + 1)(Y .1) :I [2. 2. 2. 1. I. 1. ••• l • 2 * [I. ••• l • I o 1 ITEM 100 (Perron): kl 1 n 11 (1 + 1/Ak) • (AI + l)Al (A2 + 1)A2 A2+A3+ 1 ••• (A(nl) + l)A(nl) A(nl)+An+l 1 + Al  Al+A2+1  . ••• l V I!: * [0. 1.
3) If 'ie define a rational approximation to be "best" if it comes closer than any other rational with such a small denominator. That is. in order of increasing denominators (or numerators). probably because of their unfamiliarity. the approximants to 11' = 3 7 15 1 292 ••• are: . are generally unrecognizable in decimal.ITEM lOlA (Gosper): page 37 On the theory that continued fractions are underused. since nonregular representations aren't unique. but even Schroeppel might not notice 2/3 2/3 that 6. but these are generally not regular and cannot be reconstructed from numerical values by a simple algorithm. (But if our data are ALL rational.3700787 ••• has period 42. are periodic. 0/2. You might recognize 5. volume 2. (In what follows. on the other hand. •••• So the regular continued fraction for 11' is written 3 7 15 1 292 1 1 ••• • 1) The continued fractions for rational numbers always come out even. Nth roots of e 2 . more like 3 + 1/7. and ratios of linear functions of these all have regular continued fractions formed by interleaving one or more arithmetic sequences. then continued fractions give the complete set of best rational approximations to the value which they represent. making it almost impossible to tell if the number is rational.2)/(e . But not really IS. Their continued fractions. 11'. page 316.) 2) Quadratic surds. I offer the following propaganda session on the relative merits ~f continued fractions versus other numerical representations. which are of course inexpressible as rationals. Furthermore. sin . if you truncate a (regUlar) continued fraction. The corresponding decimal fraction 39. But not really 3. The point is. however. and any radix can be read in place of decimal. For exa~ple. this remains true if the last term of this approximation is replaced by any smaller positive integer other than 1.1102966796 ••• was (4 e . then the reSUlting rational number is a best approximation. and rather quickly. Thus. These special properties will show up regardless of number base.436563 ••• as 2e. at any point. "regular" means that all numerators are 1. etc. the ordered pair 5000/127 is even more concise.5. 17 arctan 17. more like 7 + 1/15. But not really 7. For a good cram course in continued fractions.) 0) 11' is 3.1) until he wrote it as 6 9 15 21 27 33 •••• The familiar transcendental functions of rational arguments also have simple continued fractions. can be expressed to unlimited precision by simple programs which produce the terms on demand. ratios of Bessel functions. All best approximations can be generated in this manner. the number of inches per meter is exactly 100/2. that numbers like e. see Knuth.54 or 39 2 1 2 2 1 4.
namely. . add (or if possible. so that the total number of digits (numerator and denominator) is usually slightly smaller than with equally accurate decimal fractions. Contrast this with the problem of comparing the rationals 113/36 and 355/113. 19/6. To negate. The approximations are low if the number of terms is odd. Even infinity has a continued fraction. delete) an initial 0 term. the empty one! (Minus and plus infinity are the same in continued fraction notation.) 6) Each representation favors certain operations. 2/1. 1/1. To reciprocate a regular continued fraction. 1. 69/22. 10/3. Thus. c. In the above.5 places instead of 5. ••• 311/99. add in the next term iff it is ±l.5 = . to "round off" a continued fraction after a certain term. one term at a time. negate all the terms. unlike decimal (. decimal or floating) representation for nonintegers is that arithmetic is easy. Rationals favor reciprocation. Rational number arithmetic often loses because numerators and denominators grow so large as to require icky multiprecision. high if it's even.. as do continued fractions. 4) Numerical comparison of continued fractions is slightly harder than in decimal. optionally observing that a. c. 333/106 355/113 . 5) Regular continued fractions are in I to 1 correspondence with the real numbers.3: 7: IS: 1: . 4/1 and 25/8 correspond to termination with a 1 and are not "best". it should be added in to the previous term.. 16 • ?).5. 47/15. The size of a Jenominator is greater than the product of the terms involved and less than the product of the numbers I greater than the terms. bel. . 16/5. b. due to the unusually large term (292) which follows. Algorithms for arithmetic on continued fractions seem generally unknown.. 22/7 (25/8).) The error is smaller than lover the product of the denominator squared and the first neglected term.just invert the decision as to which is larger whenever the first discrepant terms are evennumbered. 355/113 is "best" because the corresponding term really should be I. 7) . Note that they are all automatically in lowest terms. but much easier than with rationals . 3/1 page 38 (4/1).g. 7/2.49999 ••• ) or rationals (2/3 • 6/9. 91/29. 355/113 is good to 7. (Note that if a I ends a continued fraction. The next items describe how to arithmetically combine continued fractions to produce new ones. <1 • • • • aI. d •••• The strongest argument for positional (e. 13/4. uecimal favors mUltiplication by powers of 10. 113/36.
Imprecise quantities can also be programs which deliver terms until they run out of confidence. no unnecessary computations. a subexpression which happened to be multiplied by zero would never be evaluated. All this is possible because each operation (+. and obviate most forms of successive approximation. By then. these rewards will be seen to be: unlimited significance arithmetic without multiprecision multiplication or diVision. immorally easy computation of algebraic functions. the effort required to perform these operations manually is several times that for decimal.and consequently produces terms of its own value as soon as possible. and the terms of the answer start to come out right away and continue to do so until shut off.e I (tanh IS . As if this weren't enough. t) in the arithmetic expression requests terms from the continued fractions of its operands only when necessary. if we should be so reactionary). the calculation can prOVide error bounds on the answer as well as identify the quantity that limited the significance. whereupon they initiate special action. ITEM 1018 (Gosper): Continued Fraction Arithmetic Continued fractions let us perform numerical calculations a little at a time without ever introducing any error. and truncation). the calculations provide automatic error analysis. Numbers like nand e and functions like sin and tanh have continued fraction terms in simple sequences which can be produced by short programs. an operation detecting a deficiency in two or more of its operands prOVides a natural mechanism for allocating mUltiprocessor resorces. We see then that no calculation is performed unnecessarily. built in error analysis. such as roundoff or truncation. Specifically.sin 69) and immediately begin to produce the value as a sequence of continued fraction terms (or even decimal digits. limited only by time and storage. This means we can start with an arithmetic expression like 137i2 .page 39 Unfortunately. so that. If there are quantities in the expression which are known only approximately. . AlSO. the last guaranteeable term of the overall expression will have already been produced. I. . should you have some. reversibility of computations. for example. no discarding of information (as with roundoff. but the rewards for machine implementation arc considerable (which can also be said of floating point).
Let x be a continued fraction p + q /(p 001 page 40 + q lx' 0 0 + q /( ••• • p I where x' is again a continued fraction and the p's and q's are integers.y). I) . and x/y. xy. We shall call a (p q) pair a "term" of the continued fraction for x. and x is called a "regular" continued fraction. let y be another procedurally represented continued fraction r + slY'. Our problem will be solved if we can write such subroutines for z(x. xy. in which case the q's are implicitly alii.Here are the algorithms for the elementary arithmetic operations on continued fractions. When z inputs a term of x. change o 0 itself into x'. the process of inputting terms of x and y and output tina terms of z will reduce to replacing the eight integers a through h with linear combinations of each other. Various choices express ad\lition: subtraction: mUltiplication: division: x+y = (0 xy • (0 xy • (1 xly • (0 1 1 I 1 0 0 I 0 0)/(0 0)/(0 0 0 0 0 I) . let x be a computer subroutine which produces its next p and q each time it is called. in effect. Similarly. z becomes a ne~ function of x'. the subroutine might in turn call for (or "input") terms from x and y until it is satisfied that the unread portions of x and y cannot affect the pending term of z. our expressions quickly complicate. only the p's are mentioned. and 0) • As we shall see. Let us preempt this complication by computing instead the more general function z(x. Thus on its first usage x will "output" p and q and. when we try to do this. 0)/(0 0)/(0 0 0 0 1 I) . Unfortunately. . Often.y) o 0 = (axy+bx+cy+d)/(exy+fx+gy+h) (or (a b c d)/(e f g h) for short) where a through h are integer variables whose initial values we are free to choose.y) = x+y. so that it could produce the next term next time. Then it would output this term and change itself into z'. Instead of a list of p's and q's.Y) • (pa+c pb+d qa qb)/(pc+g pf+h qe qf). substitute p + q/x' for every occurrence of x in the expression for zex. To see how this happens. then multiply numerator and denominator through by x': z(x'. When called upon to output a term of z.
Now hold y fixed and examine the behavior of z with x.If x was.u/z' must = [z]. For simplicity. so that z • t + u/z' (i. let us assume that z will output in standard form. Symmetrically. Thus if z is in standard form. along with a bit indicating Inside or Outside. which can be performed in any order since they represent independent substitutions. This means that ~.e. z would be (Outside 2 2). when x is (Outside a b) then z is (Outside zeal z(b» unless the signs of the denominators of zeal and z(b) differ.y') = (ra+b sa rc+d sc)/(re+f se rg+h sg). although they would probably vary in sign. In this case. that is. rational and has run out of terms. the greatest integer ~ z.e. will always exceed 1 and thus 0 ~ u/z' < 1. then none of the terms after the first would be 1. every u = 1 (regular) and every output term t ~ 1 except perhaps the first.. This argument still holds with x and y interchanged.oo) = (0 a 0 c)/(O e 0 g) To output the term (t u). Since z generally varies with x and y. If Y runs out of terms: Z(X. z has its pole in this interval). whereupon z is (Inside zeal z(b». We can easily compute the range of z given the ranges of x and y if we represent each range by the endpoints of an interval (in either order). Thus this basic eight variable form is preserved by all three operations. If x is (Inside a b) then z is (Inside zeal z(b» unless the denominator of z changes sign between a and b (i.. it should not output unless [z] is constant for the range of possible x and y. we can say that z will always be (Inside 1 00) (or (Outside _00 1) after the first term. z· = u/(zt»: z'(x. it has in effect become infinite: z(oo. so that the integer t = z .  .y) = (ue uf ug uh)/(ate btf ctg dth). whereupon z is (Outside zeal z(b».y) page 41 = (0 0 a b)/(O 0 e f) If instead we input a term of y by substituting r + slY' for every occurrence of y: z(x. If z were to always output its nearest integer instead of its greatest.
997930 ±. and its violation will very probably cause further retractions among the functions dependent upon z. it will simply recant with 0 1 S and continue with the correction 1 9. If it is (Inside zl z2) and [zl] =. In order to undo these computations. whichever was associated with the widest of the four ranges of z. The sequence 7 5 1 0 1 S 1 9 is equivalent to 6 9 because b 0 c is the same as b+c.) Due to the basically monotonic behavior of z.page 42 Now suppose that with y fixed at one of its endpoints. (Outside 0 2) is the widest. zex) is (Outside 0 3). meaning between 2 1 481 and 2 1 483. we have 2 1 4Hl 0 2.0373 ±. z can output the term t • [zl]. and at y's other extreme. 137 26 0 1 replaces 137.) z can produce its value as decimal digits by mUltiplying by 10 instead of reciprocating. (Outside narrowness) is wider than (Outside wideness) is wider than (Inside wideness) is wider than (Inside narrowness). it is not serious if z for some reason outputs the terms 7 S 1 when it should have produced 6 9. z(y) is (Inside 1 3) and (Outside 0 2). and that this range will be Inside or Outside some interval. Even if z doesn't produce a term. (Topology hackers should recognize this InsideOutside nonsense as ordinary intervals in toroidal space. The clue is that both plus and minus infinity are denoted by the empty continued fraction. z violates the condition (Outside 1 1) when it is 0 1 S •••• This condition is obeyed by nearly all convergent continued fractions after their first term.y) =. Strange to say. whereupon z would egest a gigantic term. z must input a term from x or y. Suppose further that at the two extremes of x. after outputting t • [z): z' (x. x constrains z (Inside 1 2). we can guarantee that the actual range of z will be the union of these four ranges. the union of the four ranges. (There is no way to guarantee that x or y won't eventually deviate. . indicating that z will probably get more information from a term of y than a term of x.[z2]. As soon as permitted. Evaluating z on these endpoints may be facilitated by keeping estimates for the integer variables in floating point. Otherwise. narrowing the range of possible z will still help in computing the range of a function of z.(IO(ate) ·IO(btf) lOCctg) 10(dth»/(e f g h).0006. especially if z gets stuck trying to output the last term of a rational number resulting from irrational x and y. Then z(x. Instead of 2. This computation reversal trick is also handy for mechanizing and denoting imprecise quantities.y) is (Outside 0 1). Similarly.000003.
the que s t ion c al:n bee om pi i cat e d by allowing higher powers of x and y. even though this form is also preserved. which must know when two variables. we get the correct answer directly! (69\ of the credit for this goes to Schroeppel. Since the production of these terms cannot be aided by reading incorrect terms.) The basic eight variable form exemplified above by z(x. it is essential for the success of the Newton's method feedback trick. to get a function of the same form. it should be possible to rewrite arithmet~c expressions as compositions of considerably fewer of the~e forms than one for each +.x. Consider Newton's method for algebraic roots. This form is not only more economical than z(x. This is not true of z(x) • (ax 2 +bx+c) l(dx 2 +ex+f). k. but it hardly ever errs. instead of being numbers. We need only four variables and a single interval check to compute z(x) = (ax+b)/(cx+d). By choosing the eight coefficients a thro~gh h properly. the additional correct terms must be produced before the bad ones of the previous approximation are used. z. . the homographic function of one argument. The problem is that you may need any number of continued fraction (or series) terms which. it would quickly correct itself anyway. for example. whereupon it replaces itself with a full fledged term subroutine which in turn refers to x and a new dummy. This form is not guaranteed monotone. with this next term really a dummy until actually called upon for output. and I. *. z(w. y. Depending on the met ric for min i mal i t y. But this means that there is no need to read in the bad ones at all. are symbolic functions of x. By feeding back the output terms in place of the approximation. I f the' highest powers of x. On the other hand. ••• in an invariant form are i.y) (linear in all three arguments) requires sixteen variables and a twelve way interval check. Each of these forms can be solved for x in terms of z etc. are really the same one. ••• .y) is not the only form preserved by continued fraction term transactions.x). The reader is invit~d to investigate the problem of trying to find minimal represe~tations.page 43 Successive approximations methods benefit considerably from not requesting terms until needed. jl. . We expect successive approximations to have about twice as many correct terms each time. thus theoretically invalidating the interval check algorithm. then the number of integer variables required for t~e coefficients (mostly because of all of the cross terms) is 2(i+'1) (j+l) (k+l) •••• r I It is awkward in this system to evaluate transcendental functions of irrational arguments. Even if it did. My suggestion is to represent each symbolic term of the function by a subroutine which is a function of x and the next term. some infinite continued fraction.
Discard the terms to the right. c. and e are Hurwitz numbers whose polynomials are linear or constant.e. 0. Periodicity will also occur when x is a Hurwitz number. (If one fraction terminates but matches the other as far as '1 t goes. the operations for input and output only require (besides addition) multiplication by terms which are almost invariably small. Fortunately. the integer variables in these algorithms do not usually shrink on outputs as much as they grow on inputs. that first piece of the term will probably satisfy its recipient for quite some time.) .. e+11'. :and yare all regular. ITEM 10lC (Gosper): Problem: Given an interval. Although this is just thinly disguised rnultiprecision mUltiplication. note that the term 20776 is equivalent to the terms 20000 0 700 0 70 0 6. when the terms af x are the values of one or more polynomials evaluated on consecutive integers and then interleaved. then it generally won't be possible to reduce z by finding a GCD of a through h which is > 1.) It is fairly safe! then. find in it the rational number with smallest numerator and denominator. append an infini ty and proceed as above. a very large term can be transmitted piecewise. . What's left is the continued fraction for the "smallest" rational in the interval.e.. In some special cases. Hurwitzness is preserved by homographic functions. ~. This reduction is almost always by a divisor of an input or output term numerator (or 10 if output is decimal digits) and can be facilitated by keeping cetain of the integer variables around modulo these quantities. d will eventually become 1. Better still.page 44 Sad to say. x. If one can show that 11' is not a Hurwitz number. However. (I have not seen a term exceed 20776 except in specially constructed numbers. Find the first term where they differ and add 1 to the lesser term. Solution: Express the endpoints as continued fractions. Then. thus terminating its continued fraction. are all irrational • If z. etc. we have the form z(x) • (ax+b)/(cx+d). to declare any function which has gotten (Outside _2 35 2 5) to be infinite. especially when all but one of the arguments to a function have terminated. it has been determined empirically that much reduction is often possible in oth~r cases. Coth 1/69. i. whereupon z will output the terms of x unmodified. e/11'. i. one confirms the long standing conjectuTes that e*11'. the integer variables will become periodic rather than large. b. 0. then a. If adbe is ±l. unless it's last. known as a homographic function. 1.
results. 8 and C. but not necessarily a group. namely: S. If instead you are given A * I • A and A * A • I. R 3 2 + 1. (A * B) * C • 3 for each A there exists an A such of a group. and that A * X • X * A = I. and A * (8 * C).********************************************* page 45 GROUP THEORY ********************************************* ITEM 102 (Schroeppel): As opposed to the usual formulation where you are given 1 there exists an I such that A * I 2 for all A. then something very much like a group. then the above rules can be derived. But if you are given A * I • A and A * A = I. every clement is duplicated. how many sets can you get using only closure and complement? Answer: 14. and 4 sometimes you are given that I and'X are unique. namely: SRRSR. • I * A • A. ITEM 103 (Gosper): The Hamiltonian paths through the N! permutations of N objects using only SWAP (swap any specific pair) and ROTATE (1 position) are as follows: N PATHS + DISTINCT REVERSES 2 2 + 0. is this so? ITEM 104 (Schroeppel): Any permutation on 72 bits can be coded with a routine containing only the PDP6/10 instructions "ROT" and "ROTC". For example. ********************************************* SET THEORY ********************************************* ITEM 105 (Komolgoroff. maybe?): Given a set of real numbers. . RRSRR 4 3 + 3. namely: SRR RSR SRR RSR RRS RSR RSR RR RSR SRR RSR RRS RSR RRS RSR RR SRR RSR RRS RRS RSR RRS RRR SR PROBLEM: A questionable program said there are none for N • 5.
. The nonzero quaternions form a group under multiplication with (1. xcross product.N . Then Ql. The unit quaternions. V = (Ql.Q • O.This can be verified by expressing PQ as a 4 X 4 matrix times the 4vector Q.(NQ) • N. PROBLEM: For which Nspheres does a continuous unit tangent vector field exist? .a iff Ql is perpendicular to Q2. and then noting that the matrix is orthogonal. attach the quaternion NQ . We can define a dot product of quaternions as the dot product of 4vectors.Q3). it has no fixed point.Ql.I and (NQ).Q2. F(Q) restricted to the unit quaternions is a rigid rotation of the 3sphere.1 as identity and l/Q = Q*/(Q* Q). The mapping F(Q) • PQ (P a unit quat.************************************** QUATERN IONS ************************************** page 46 ITEM 107 (Salamin): A quaternion is a 4tuple which can be regarded as a scalar plus a vector. which lie on a 3sphere embedded in 4space.QO. No such tangent vector field exists for the ordinary 2sphere.Q2 . Clearly the Isphere has such a vector field. then S .V2 + 51 V2 + VI 52 + VI x V2 where Sscalar part.N. Geometrically this means that NQ is a continuous unit 4vector field tangent to the 3sphere. Let N be a unit vector.Q2.Q3). and because this mapping is a group translation. Quaternions add linearly and multiply (noncommutatively) by (Sl+Vl){S2+V2) • 51 52 . Vvector part.V + N S + N x V. If Q = 5+V • (QO. To each unit quaternion Q .dot product. Define conjugation by (5+V)* • SV.VI.5+V.0) . form a subgroup.0.0. . The (absolute value)2 of a quaternion is Q02 + Ql2 + Q2 2 + Q3 2 • Q Q* = Q* Q.ernion) is a rigid rotation in 4space. Then it is seen that (NQ).
Then Q W Q* • (cos 6)W + (sin 6)(N x W) + (Icos 6)N(N. In particular.V)W + 2 5 V x W + 2 V(V. since composition of rotations is done by quaterni~n multiplication. so Ul and UI' have equal volume. In space guidance systems under development at UIab. yaw) require trigonometry for composition. . pitch. Then Q W Q* • (5 + V. 3parameter representations like Euler angles or (roll. we choose points uniformly on the 3sphere (or hemisphere since it is really projective). the llaar measure is the Lebesgue measure on the 3sphere. This shows that in the quaternion representation of the rotation group. If rotations are chosen "uniformly". one finds pea) = (2/11') (sin 8/2)2. what is the probability distribution of 6' By the above. Every rotation is a rotation by some angle 6 about some axis. Let U be a neighborhood of the identity in the rotation group (ordinary 3 dimensional rotations) and Ul the corresponding set of unit quaternions in the neighborhood of 1. then a quaternion corresponding to R carries Ul into Ul'.W). If Q thus induces rotation R. the expected value of 0 is 11'/2+2/11'.W). Let N be a unit vector and Q the unit quaternion Q = ±(cos(6/2) + N sin(6/2». and orthogonal matrices ~re 9parameter. But quaternion multiplication is a rigid rotation of the 3sphere. 0 < 6 < 11'.page 47 Let W be a vector (~uaternion with zero scalar part) and Q = S+V. In contrast. Quaternions form a convenient 4parameter representation of rotations. then QI Q2 induces rotation RI R2. If a rotation R carries U into U'. which is W rotated thru angle 6 about N. the attitude of the spacecraft is stored in the iuidance computer as a quaternion. 50 the projective 3sphere (+Q and Q identified) is isomorphic to the rotation group (3 X 3 orthogonal matrices). Going into polar coordinates. Projectiveness is unavoidable since a 211' rotation about any axis changes Q • I continuously into Q :I: 1.
can be shown by coloring to cover only rectangles having at leaat one side divisible by four.* ••• * ••••• ITEM 108: See the PROPOSED COMPUTER PROGRAMS section for counts of polyominos of orders < 19.. then M must be even. December 1964. YYYY ITEM III (Schroeppel): PROBLEM: Find a necessary and sufficient condition for an arbitrary shape in the plane to be domino coverable. again without beini flipped over. All but the four heptominos below can tessellate the plane. Am.** •••• **. "Somalike" pieces are made of cubes. like dominos.•••••••••••••••••••• **** •• ******. (There are 108 heptominos).**. xx X can cover rectangles which are 3N x M. ETC. "Hexafrobs" are made of hexagons. ORDER IAMONOS OMINOS HEXA'S SOMALIKE 1 1 1 1 1 2 S 6 7 8 9 1 4 1 12 1 22 1 29 31232 4 3 S 7 8 12 24 66 160 3S 10 448 . Games. "(Poly)ominos" are made of squares. See also "Polyiamonds. ** ••••••••••••••••••• *. except if N • I. ITEM 109 (Schroeppel): Tessellating the plane with polyominos: Through all hexominos. like diamonds. ITEM 112 (Beeler): "Iamonus" are made of equilateral triangles. page 48 POLYOMINOS.* ••••••••• *. II II HIlHIlII IIHH II If fiB II IUIHH II II II IIHBH H H ITEM 110 (Schroeppel): PROBLEM: What rectangles are coverable by various polyominos? For example. Left and right 3dimensional forms are counted as distinct. Thus. the plane can be tessellated with each piece (withou~ even flipping any over). Sci." Math. flipping does not buy you anything through order 7.
156 distinct solutions parallelogram.37 distinct solutions parallelogram. October 1965): BOARD DISTINCT SOLUTIONS 3 x 20 2 4 x 15 368 5 x 12 1010 6 x 10 2339 (verified) two 5 x 6 . base 3. A A A ABC C DEB B C F C DEE B F G G o 0 E F F G G Order6 iamond boards and solution counts (see illustration): side 9 triangle with inverted side 3 triangle in center removed ~. 320 solutions are due to variations of ten distinct solutions decomposable into two 2 x 2 x 4 boxes. the booklet which comes with it says this was found years ago on a 7094. 2 and 3 do not have interesting boxes. . side 4. base 6.g.no SOlutions trapezoid.no solutions two triangles of side 6 . 1124 of these have the fourinarow on an edge.. orders I.no solutions triangle of side 9 with triangles of side 1.9 distinct solutions e. side 9 . Order 4 has 1390 distinct solutions for a 2 x 4 x 4 box. the remaining 266 have that piece internal. bases 3 and 3+6 . base 4. side 4 . Verified by both Beeler and Clements. Order 5 has several boards and its solutions are documented (Communications of the ACM. 2 and 3 cannot form a rectangle. base 7. 2 and 2 removed from its corners (a commercial puzzle) .5885 distinct solutions With Somalike pieces.page 49 Polyominos of order 1.76 distinct solutions parallelogram.65 CONJECTURE (Schroeppel): If the ominos of a given order form rectangles of different shapes.2 8 x 8 with 2 x 2 hole in center . Orders 4 and 6 can be shown to form no rectangles by a checkerboard coloring.no solutions parallelogram. A Somalike 2 x 4 x 4 solution: AAAA BBIIH BCCC SIIHC DODE FGGE FDGE FFGE The commercial Soma has 240 distinct solutions. side 6 . bases 7 and 7+4 . side 12 .no solutions trapezoid. the rectangle which is more nearly square will have more solutions. side 6. Order4 hexafrob boards and solution counts: side 7 triangle .
Figure S. . Some hexiamond solutions.
*********************************************
page 51
TOPOLOGY
*********************************************
ITEM 113: Although not new (cf Coxeter, Introduction to Geometry, 1st ed. p393), the following coloring number (chromatic number) may be useful to have around:
N • [[(7 + {4S II + 1)/2]] where N is the number of colors required to color any map on an object which has H holes (note: proof not valid for H • 0). For example: A donut (holes. 1) requires 7 colors to color maps on it. A 17hole frob requires 17 colors. An IShole frob requires 18 colors.
ITEM 114 (Schroeppel): A most regular 7coloring of the torus can be made by tiling the plane with the following repeating pattern of hexagons of 7 colors: A ACe E E E E E A A Ace C A A F FCC A A E E F F F A A A B B F F D D A A F F B B B D D D F F F B B G G D D B B F F 888 G G G C eGG E E 8 B G G C C C E E EGG G C C A A E E C C G G A A A C C C D D A A F FCC A A D D D F F F A A A U D 8 8 F F D D A A
8 B B D D D

E E 8 B G G D D B B E E EGG G 8 B B E E C C G GEE B B C C C E E E
C C E E
Draw an area 7 unit cell parallelogram by connecting, say, the center 8's in each of the four B B B B B B B • Finally, j oi n the opposite sides of the parallelogram to form a torus in the usual (Spacewar) fashion. QUESTION (Gosper): is there a toroidal heptahedron corresponding to this?
ITEM 115 (Gosper): page S2 A spacefilling curve is a continuous map T + XCT),Y(T), usually from the unit interval onto the unit square, ~ften presented as the limit of a sequence of curves made by iteratively quadrisecting the unit square. Each member of the sequence is then 4 copies of its predecessor, connected in the shape of an inverted V, with the first member being a V which connects 0,0 to 1,0. The limiting map, X(T) and YeT), can be computed instead by a simple, finitestate machine having 4 inputs (digits of T base 4), 4 outputs (one bit 'of X and one bit of Yl, and 4 states (2 bits) of memory (the number modulo 2 of a's and 3's seen in T). Let T, X, and Y be written in binary as:
T.A B A B A B •••
1 1 2 2 3 3
X.x X X X X X ••• 1 234 5 6
Y.Y Y Y Y Y Y •••
1 2 3 4 5 6
ALGORITHM 5:
c ..0
0
i' of O's Plod 4 i' of 3' 5 mod 4
C
..1
0
51:
X
I
.. A
I I
XOR C NOT B
I
i 1th bit of X
Y .. X
I
XOR B
I
i 1th bit of Y
C
0
....1
C
0
XOR (NOT A
I
AND NOT
B )
icount OD's
I
I
C
C
XOR (A 1
I
AND B ) icount II's
GO 51
OLD C CAB
NE'~
page 53
1
o
X
Y
C
C
1
I
I
I
I
0
o o o o o o o o
1
0 0 0 0
1 1 1 1
o o o o
1
1
0
1
o o
1 1
1 1
0 1
0 1 1
0
1
o o o o o o o o
1 1 1
1 I 1
1
0
0 0
1 1 1 1
0
1 0
1 1
o o
o
1
1
1
1
1
1 0
0
This is the complete state transition table.
0
1
1
0
0
o
1 1
o 0
0 0
1
0 0
0 0 1 1 1 1 0
1
1
1 1
0
1
1 1
o o
1 1
0 1 0
1
o
o o
1 1
1 1 0
1
1
0 1
0
1
To carry out either the forward or reverse map. label a set of columns as in the table above. Fill in whichever you know of AB or XY. with consecutive rows corresponding to consecutive I's. Put 0 0 in the top position of the OLD CC column. Exactly one row of the above table will match the row you have written so far. Fill in the rest of the row. Copy the NEW CC entry to the OLD CC column in the next row. Again. only one row of the state table will match. and so forth. For example. the map 5/6 + (1/2.1/2) (really .11010101 ••• + (.1000 ••• ,.0111 ••• »:
OLD C CAB
NEW
X Y C C
o
1
I
I 1 1
1 1
I
I
0
1 1 1 1 1 •
o o o o
0
1
1 1
o o o
II 5/6
1
o o
1/2
0 1 1 o 1 ••
1
o o o o
1/2
We note that since this is a onetoone map on bit strings, it is not a onetoone map on real numbers. For instance. there are 2 ways to write 1/2 •• 1000 ••• and .0111 •••• and t~us 4 ways to write (1/2.1/2). giving 3 distinct inverses. 1/6. 1/2. and 5/6. Since the algorithm is finite state. X and Yare rational iff T is. e.g •• 898/4369 + (1/5.1/3). The parity number. (see SERIES section) and l(parity number) are the only rea1s satisfying X(T)IIT. Y(T)l. This is related to the fact that they have no O's and 3's base 4. and along with O. 1/2. and 1 .111 •••• are the only numbers preserved by the deletion of their even numbered bit positions.
11
N (0°.O.+ . Substitute for Y a power series in X with coefficients to he determined.1) 'ITEM 119 (Schroeppe1): PROBLEM: Can someone square some series for n to give n2 1 1 1 the series • .+ 3 9 13 PROBLEM: Evaluate in closed form 1 which • ! (P + Q arccos (R» NO (3N)! o dT J where ITEM 117 (llenry Cohen): y N In X + X   X2 + 2*2!  X· 3*31 4*41 X Xit • • • + ERROR )/X.+ ••• .********************************************* SERIES ********************************************* page 54 ITEM 116 (Schroeppel & Gosper): • N0 • ~ NINI (2N)! N!NIN! J ~  4 2n .t __ ? 6 12 22 H2 . \ihere ERROR is of the order of (e ITEM 118 (Schroeppel): Y Uifferentiate Ye • X to get Y+YXY'XY' . One observes the curious identity: ~ (BINOMIAL N J)J Jl J 1 NJ N and thus VeX) • t Nl (NJ) N1 N N X INI .
L 3 5 4 (2N + 1) ! Applied to the formula for y in Amer. 13.i+l) + 66(6.. ITEM 121 (Gosper): Consider the triangular array: 1 1 1 141 1 11 11 1 1 26 66 26 1 1 57 302 302 57 1 This bears an interesting relationship to Pascal's triangle. sec.495.Kth MO forward difference on AO) when applied to Nl 2 1f 4 . 3. *12/4. *11/3= 165. 4 1 813 16 1 5 6 32 1 9 15 10 64 1 17 45 35 15 128 1 33 153 165 70 21 256 1 65 561 969 495 126 28 N+l The next to left diagonal is 2 . The 302 in the 4th southeast diagonal and the 3rd southwest one = 4*26 + 3*66.i+2) + 26(6.=1 1 1 1f 2 N! . .45. ITEM 120 (Euler): The series accelerating transformation (Abramowitz & Stegun. the perpendicular one 3rd from the right is 1. The array of reciprocals of the terms follows.27) K K K+l page 55 AOAl+A2.i) + 26(6.••• • 1: () (A AO)/2 K (where (A AO) :II K KM L () (BINOMIAL K M) AM .. where (j.••• gives . Mar69 p273) = 1: () ([ ] mean integer part of) we get T 00 (K+l) Kl I I: 2 I: l/(BINOMIAL 2 +J J) K=l JO (Gosper) which converges fast enough for a few hundred digits.i+3) + 1(6. 1(6. Math. we get the nth Bernoulli polynomial: for n .i+4) sum of 5th powers of 1 thru i+5. If the nth row of the triangle is dotted with any n consecutive elements of (either) n+1st diagonal of Pascal's triangle. with powers of 2 factore~ out to the left from all members of each row..9. *10/2.i) • BINOMIAL (j+i j).+ . *9/1.6. Monthly T [log2 T] (vol. 76.5. Note that· rows then sum to factorials rather than powers of 2.
01 . wh i ch is.2 NUM 0 • 0. and the complement of the string for ones.01101001100101101001 ••• radix 2 N N i.L (parity of N)*2 2 NO where the parity of N is the sum of the bits of N mod 2. for hexadecimal freaks.. It can be written (base 2) in stages by taking the previous stage. and appending to the previous stage: . Its regular continued fraction begins: 0 2 2 2 1 4 3 5 2 1 4 2 1 5 44 1 4 1 2 4 1 1 1 5 14 1 50 15 5 1 1 1 4 2 1 4 I 43 1 4 I 2 1 3 16 1 2 1 2 1 50 1 2 424 1 2 5 2 1 1 1 5 5 2 22 5 1 1 I 1274 3 5 2 1 1 1 4 1 1 15 154 7 2 1 2 2 1 2 1 1 50 1 4 1 2 867374 1 1 1 5 5 1 1 6 1 2 7 2 1650 23 3 1 1 1 2 5 3 84 I 1 1 1284 ••• and seems to continue with sporadic large terms in suspicious patterns. . or. e. l 2 2 DEN N+ 1 :I (DEN N) • 2 N If N NUM then :~+1 2 2 )*(1 .0110100110010110 . complementing.2 • stage N+1 • (stage N + 2 ) DEN N+l Or. roughly the 2 the .4124540336401075977 ••• . 2 2 stage 0 • 0 stage N)/2 stage N+l • stage N + (1.ITEM 122 (Schroeppe1. A nonregular fraction is 1/(3 1/(2 1/(4 3/(16 15/(256 255/(65536 65535/ N 2 ( ••• 2 (2 N 2 11/( •••• This fraction converges much more rapidly than the regular one. Gosper): 1 co page S6 N The "parity number" • .." in fa c t .6996966996696996. It is claimed (perhaps proven by Thue?) that the parity number is transcendental. . . The parity number's value is . I+NUM N its Nth a ppro xi man t b e i n g . faster.0110 ... by substituting in the string at any stage: the string itself for zeros. DEN 0 • 2 NUM N+l • ((NUM N)+I)*((DEN N) 1) N.0 ..01101001 . I+DEN N N an approximant of the regular fraction.
4*(parity number) • page 57 1 3 15 255 65535 2 . and (3) how many terms are used in the computation. If you write a program to display this. which makes an intriguing display pattern. however. be sure to allow easy changing of: (1) z and z on alternate terms (alternate hands rotate in opposite directions). and fez) • Gosper has programmed the one mentioned FI B(n) first. The third hand rotates around the end of the second at four times this rate. It would seem that the end of the "last" hand (really there are infinitely many) would sweep through space very fast. tracing out an (infinitely) long curve in the time the first hand rotates once. The next hand is half as long and rotates around the end of the first hand at twice this rate. For another property of the parity number. ITEM 123 (Schroeppel. Thus it is unclear whether the speed of the "last" hand is really infinite.* * ••• 2 4 16 256 65536 This gives still another nonregular fraction per the product conversion item in the CONTINUED FRACTION section.* .In addition. Salamin): Consider the image of the circle Izi • 1 under the function n 2 z f( z) =. or. Gosper. The first hand rotates around the center (0. it is a visually interesting curve. as are fez) • t FIB(n) nl z .* . (2) negation of alternate terms (alternate hands initially point in opposite directions)..* . The hands shrink.L n • This is physically analogous to a series of 2 clock hands placed end to end. because of n .~ the 2 in the denominator. See following illustrations. etc. see the spacefilling curve item in the TOPOLOGY section.0) at some rate. L . nl z Also. whether the curve's arc length is really infinite. since these cause fascinating variations in the resulting curve.
7/8. 3/4. 1 under the z nl function fez) • t nl .Figure 6(a). Image of circles Izl • 1/2.
~ ) ? / .\ \. .._"\.\' ...... . r' . '0 "'... __/ '" / ~. ._..•."... f) ~ ~... . . . /' ... ~\.. .'.../ ./I ) ....••_.. " _........ " ~.~ ""_.. '. . "''r ~ ~ \.' ..... 8/S under the function fez) • I n 2 Both plots by Salamin on the RLE PDPI... Image of circles n 2 z • Izi • 1/8.. __..' • . ... I ~ .1 Figure 6(b)." '_.... " ... 1'"' ... ... _. (' . ..~ 1.. '.. J " / .'"._... j..'\ I I ._.... / / \../ ..."...._~. .__ r /. ••• .''...~. • . ......'.. ./ .... / .. .. .!' '. __.. .... ~ \ .i"."..._/"... 2/8.~ ..'::.r ( I r ....._. . ·r\.... " i i [ " /''i...
" ] + t N2  = 1 1 t [ t 1 [.. the next iteration gives 31 18 2 2 9 N (4N l)(2SN'+SN +9) N2 (2N+l)(2Nl)(SN 2 +SN+3)(SN 2 SN+3). This may be a winner for computing the original sum. For example. 2 where the denominator also • ITEM 125 (Polya): CONJECTURE: If a function has a power series with integer coefficients and radius of convergence 1.IT Et.1 124 (S chrocppel) : Consider 1 paRe 6 0 . then either the function is rational or the unit circle is a natural boundary. page 46. volume 2. 1 1 N1/2 N+l/2 N2 N2 l/4 ] • 2 .I (4N 2 _l)*N 2 Take the last sum and reapply this transformation. . Mathematics and Plausible Reasoning. Reference: Polya.
****************~**************************** page 61 FLOWS AND ITERATED FUNCTIONS ********************************************* ITEM 126 (Schroeppel): An analytic flow for Newton's method square root: X2 +K . then add A to the original constants in both P and Q. sometimes multiplie4 by roots of 1. 3 P and Q are each another polynomial R composed with itself different numbers of times.3X (N • 3) 5 Replace X by YA.2. p the expression for squares • X2 . then Define F(X) by N 2X N 2 2 + (X ~ tK) (X + IK) :a1K F(F(F( ••• (X»» N [N tilDes] N 2 2 (X + IK) (X • t"K)  . re~lacing X with AY+8 works. which = IK N  (coth 2 (arccoth x/If» III ITEM 127 (Schroeppel): P and Q are polynomials in Xi when does P(Q(X» :a Q(P(X» ? (That is. 2 X to different powers. For example. P X2 and Q • X3 . P composed with Q Q composed with P. 4 Solutions arising out of the flow of X2 . 6 There are no ~ore through degrees 3 and 4 (checked with Mathlab). but are there any more at all? III III III . as follows: suppose X = Y + l/Y N N then Y + Y can be written as a polynomial in X for example.) Known solutions are: 1 Various linear things. 2 _2Y+2 and Q • 1+(Y_l)3.2 (N • 2) and Q • the expression for cubes • X'. then P = 1+(Y_I)2 • y then P(Q) • 1+ (Yl)' Q(P). Similarly.
  Figure 7. ITEM 128 (Schroeppel): A map of the process n + binary string + interpret as radix 2. To convert a number to base 2: (n + ••• 101010) XOR ( ••• 101010) (reversible).. ) ... iterated. .".
will approach a limit which can be expressed in terms of elliptic integrals. write the flow power series. ITEM 129 (Schroeppel): page 63 PROBLEM: Given F(X) as a power series in X with constant term = 0. this process. what extra conditions are necessary to ~ake it unique for natural N cases like X ? ITEM 131 (Schroeppel): raking any two numbers A and B. it is possible to find the power series coefficients for P rational. FLO\l sub ZE ItO = X fLOW sub ONE = P(X) FLOW sub TWO • F(F(X» etc.) . Unoer the hypotheses of the previous problem. the Pth flow is X . NOTE (Gosper): If we remove the restriction that F has a power series. when repeated. ITEM 130 (Sala~in): P N P N If F(X)=X . finding their arithmetic mean and their geometric mean. and using these means as a new A and 8. (See PI section. the functions that satisfy an equation of the form F(F(X» = sin X can be put into onetoone correspondence with the set of all functions. which has a branch point if N is noninteger. but there is no guarantee the series will converge. PROBLEM: Is the flow interpolation unique? If it is not.
g.e. volume 2. then there are easy ways to detect looping of the flow (Knuth. 1... where S is the number of times C can be right shifted before becoming O. the number of letters in N written longhand (e. then its flow must always be cyclic.1. Set aside a table TAB(J). 0 ~ J ~ log2 (largest possible period). 0. 0 ~ 0 2 a positive loop. initially o. then the following algorithm will detect repetition before the third occurrence of any value. 0. 3. 13 3 ( S c h roe p pel. (i.) A match with entry E means the loop length is 1 more E+I than the low E+2 bits of C . or the CDR operation on a self referent list. 1. Gosper): Let N be iteratively replaced by (FLATSIZE (LONGHAND N». Let C = the number of times F has been applied. Go s per. 3. These will he the first S entries. The Art of Computer Programming. Compare each new value of F for equality with those table entries which contain old values of F.of a pseudorandom number generator. Eric Jensen calls this the RULER function.. page 7). there is no easy way to switch arguments to the function). Known loops for N to fall into are: 1 the zero loop. If F is one step. 4. 2. 16 values of J are: 0. probe 7. 0. . If. however.2 I TEf.ITEM 132 (Gosper): LOOP DETECTOR page 64 If a function F maps a finite set into itself. where J is the number of trailing zero bits in the binary of C. II e nne man & Ban k s ) ( fro m 0 a n a Scot t ?) : The "3N+1 problem" is iteratively replacing N by N/2 if N is even or by 3N+l if N is odd. Seminumerical Algorithms. 1. 1. (The first . 4 ~ 2 ~ 1 ~ 4 3 three negative loops (equivalent to the 3Nl problem with positive N) 2 ~ 1 + 2 5 + 7 + 10 + 5 17 + 25 + 37 + 55 + 82 + 41 + 61 + 91 + 136 + 68 + 34 + 17 In the range _10 8 < N < 6 * 10 7 . 0. 2. ••• . all N fall into the above loops. The process invariably loops at 4 = FOUR. so increment C and store this latest value of F into TAB{J). or any function where it is easy to supply former values as arguments. Are there any other loops? Docs N ever diverge to infinity? ITEM 134 (Schroeppe1. 0. 69 ~ SIXTY NINE ~ 9 (10 counting blanks». sec. the process of iterated application of the function is inexorable. 0. 0. No match means F hasn't been looping very long.
ITEM 135 (Gosper): page 65 The "c" Curve A brilliant archeologist is photographing a strange drawing on the wall of a cave. He holds the camera upright for some shots, moves it, and turns it 90 degrees for the rest. When he sees his prints he is amazed to find one of them apparently taken with the camera turned 45 degrees. After a moment's reflection, he correctly concludes that it is merely a double exposure. What was the drawing? Answer: It is a cousin to both the dragon and snowflake curves (and arose as a bug in a spacefilling curve). It can be constructed as follows. Start with a line segment. Replace it with the two legs of the isosceles right triangle of which it is hypotenuse. Repeat this for the two new segments, always bUlging outward in the same direction. We now have four segments forming half a square, with the middle two segments collinear. Replacing these four segments with eight and then sixteen, we find the middle two segments superimposed. As the process continues, the curve crosses itself more and more often, eventually taking on the shape of a wildly curly letter C which forms the envelope of a myriad of epicyclic octagons. A faster way to approach the same limiting curve is to substitute
n
,
2
the curve itself for each of its 2 90 degree ,,<It.
segments, starting with a 
Yet another way to construct it is to iteratively connect opposite ends of two copies at a 90 degree angle. (The archeologist did this with his double exposure.) If we reduce the scale by 12 each time, the distance between the endpoints stays the same. If the initial line segment is red and there is some other blue shape elsewhere in the picture, the iteration will simultaneously proliferate and shrink the blue shapes, until they are all piled up along the red "C". Thus, no matter what you start with, you eventually get something that looks like the "C" curve. There are other pictures besides the C curve which are preserved by this process, but they are of infinite size. You can get them by starting with anything and running the iteration backwards as well as forwards, superimposing all the results. A backward step consists of rotating the two copies in directions opposite those in the forward step and stretching by 12 instead of shrinking. David Silver has sketched an arrangement of mirrors which might do this to a real scene.
Figure 8.
Two orders of the "C" curve.
****************************************
page
67
PI
****************************************
ITEM 136: GAUSSIAN INTEGERS (For use by next item.) Reference: Hardy and \'lright, Theory of Numbers. The Gaussian integers are x+iy where x and yare integers. Unique factorization holds, except for powers of i, and the Gaussian primes are (1) a+bi if a 2 +b 2 is prime and (2) integer primes that = 3 mod 4. If N(x+iy) • X2 +y2, then N(uv) • N(u)N(v). If P is prime and not 3 mod 4, then ~ • a 2 +b 2 has exactly one solution. If n • 3 mod 4, then n  a +b 2 has no solution. To factor x+iy into Gaussian primes, first factor N(x+iy). (A) If 2 divides N(x+iy), then l+i and li divide x+iy. Either factor may be used since i(il) • i+1. (8) If p=3 mod 4 divides N(x+iy), then p divides x+iy. (C) If p=l mod 4 divides N(x+iy) and p a 2 +b 2 • then a+ib or b+ia = i(aib) divides x+iy. If both do, then p divides x+iy.
:I
ITEM 137 (Salamin): GENERATION OF ARCTANGENT FORMULAS FOR n nl atan(yl/xl) + n2 atan(y2/x2) + ••• n 1 a rg ( x1+i y 1) + n 2 a r g ( x 2+i y 2) + ••• If each x+iy is factored and the n's chosen so all prime factors except l+i cancel out, the right hand side is a mUltiple K of n/4. Some care is needed because of the multiple valuedness of arg. Then, if K 0, we get an arctangent identity, otherwise we get a n formula. In the special ~ase of atan(l/x), factorization of x+i is needed. Then case (8) above can't occur, and in case (e), a+ib and aib can't both divide x+i. Example: 8 2 +1 = 13 x 5 18 2 +1 = 13 x 52 57 2 +1 = 13 x 53 x 2 From this we get the factorization 8+i (3+2i) (2i) l8+i (32i) (2_i)2 i 57+i (32i) (2+i) 3 (Ii) Since we only care about the phase, multiplication by a positive real number may be ignored below. abc (8+i) (18+i) (57+i)
g
:I :I :I :I
:I
abc (3+2i)
~ie
a2b+3c (2+1) (Ii)
:I
c
b
i
require abc = 0 and a2b+3c = 0, which has the minimal nontrivial solution a = 51 b = 2, c 3. Then we have (8+i)5 (18+i)2 (57+i) (1_i)3 i 2 Taking the phase of both sides, we get 5 atan(1/8) + 2 atan(1/18) + 3 atan(1/57) n/4.
:I
:I
2 atan(I/132) . n/4 = 7 atan(1/9) + atan(1/32) .2 atan(I/132) + 5 atan(1/378) There are many easily found arctangent identities.atan(l/x 2n ) + atan(l/x 2n ) = atan(l/x 2n+l ) • atan(l/i 2nl ) ) I!. when used in conjunction with a conscientiously applied program of oral hygiene and regular professional care. .atan(I/2943) II Infinite sets of arctangent identities: atan(l/n) . Government.4 atan(1/378) This last angle has been measured against the International Standard PlatinumIridium Right Angle and certified adequate for any purpose of the U. Some are: atan(I/57) + atan(I/68) atan(1/3l) = atan(1/44) + atan(I/105) atan(I/50) = atan(I/91) + atan(I/1ll) atan(1/239) = atan(1/70) .5 atan(1/32) + 3 atan(1/132) .atan(1/38) n/4 = 4 atan(l/S) .atan(I/99) = atan(I/408) + atan(1/577) atan(1/2441) • atan(1/1164) .n formulas: page 68 n/4 = atan(1/2) + atan(1/3) n/4 = 2 atan(1/3) + atan(I/7) n/4 • 4 atan(l/S) .2 atan(I/378) n/4 = 7 atan(I/13) + 8 atan(I/32) .atan(1/239) n/4 • 2 atan(1/4) + atan(I/7) + 2 atan(1/13) n/4 • 3 atan(1/4) + atan(1/13) . y =x +y o 0 n nl nl n nl nl x /y n n are the continued fraction approximants to atan(l/y 2n atan(l/y 2n ) . S.atan(I/378) • 2 atan(1/13) + atan(I/239) .atan(I/70) + atan(1/99) n/4 • 5 atan(1/8) + 2 atan(1/18) + 3 atan(I/57) n/2 • 7 atan(1/4) .atan(I/(n+l» • atan(1/(n 2 +n+l» Let x =1. x =x +2y . ITEM 138 (Gosper): n • 28 arctan (3/79) + 20 arctan (29/278) n = 48 arctan (3/79) + 20 arctan (1457/22049) Which isn't too interesting except that it means that (79+3i)" (22049+1457i)20 is a negative real number.atan(I/2225) • atan(1/4714) + atan(I/499S) atan(I/32) = atan(1/38) + atan(1/132) . y =0.
For other n series.) ITEM 141: The fraction part of 10 760 n begins: . Cambridge U. the only other 5 digit terms are the 15543rd =19055 and the 23398th 19308. Press (1927) • ITEM 140: Counting the initial 3 as the zeroth. Daykin & Rathbone. £ + _£'/3 X approx n/2: X + X + cos X. (1*3*5* ••• *(4Nl» (1) (1123 + 21460 N) (882 E N=O 2N+l This series gives about 6 decimal places accuracy per term. 387). £ + £ /3 . £ + £"6 X + X + cot X. (Gosper) In the first 26491 terms of n. 45. vol. page 350 (1914). of Computation 25 (1971) p.ITEM 139 (Ramanujan): 4/n = N ~ page 69 (1*3*5* ••• *(2Nl» ) N (32 ) (N 1) .tan X. For more goodies. 1 ~ (1103 + 26390 N) 4N+2 (99 ) I (1*3*5* ••• *(2Nl» N (1*3*S* ••• *(4Nl» IBn = E N=O (32 ) (N!)' This series gives about 8 decimal places accuracy per term. £ + £'/6 X + X . Math. see "Collected Papers of Srinivasa Ramanujan". the 431st denominator in the regular continued fraction for n is 20776.49999998 ••• ITEM 142 (Sa1amin): Some superfast convergents to n if one already has a superfast computation of trig functions. X approx n: X + X + sin X. see Ramanujan's paper "Modular Equations and Approximations to Pi" in Quarterly Journal of Pure and Applied Mathematics. (Choong. (Computed from 35570 terms of the (nonregular) fraction for 4 arctan 1.
Quadratic convergence rate: A n+l .. This gives a super fast method of computing elliptic integrals. 17.8 )2 ISA n n+l It is known that K'(x 2 ) AGM(I. RE FE REN CES : Whittaker & Watson. 6 1 1. which covers the complex mplane twice. 3. sec t. Modern Analysis. log. 22 Abramowitz & Stegun. So K'(M) can be computed for 2n < arg(m) < 2 w. 1 7.t 2 ) (1 . Handling the phase when taking square roots will permit exploration of more of the Riemann surface. x) • n/2 [lee A&Sl.m) • and B 0 are given. It is easy to compute AGM(I.ITEM 143 (Salamin): Computation of elliptic integrals. ELLIPTIC INTEGRALS page 70 Define elliptic integrals: 1 K(m) K' (m) If A 0 II / o :I 1/1(1 .B n+l • (A n . and arithmetic mean of A and B n n 8 A n+l 8 :I n+ 1 then define • geometric mean of A and n n AGM(A . . x) for x in the complex plane cut from zero to infinity along the negative real axis. Handbook of Mathematical Functions.8 ) 0 0 II lim A n • lim 8 n This is called the arithmeticgeometric mean.m t 2 Y dt K(l . and n. chap.
s 0 1vedt 0 gi v c bot h nan d log 2. use x • 2 and x • e*2 • The n s i mu 1tan e 0 use qua t ion s can be .07 billion and 2 31 • 2. then n n AGM(I. 1/ log x) I < I 4/ x 21 < £ x can be complex. K(rn) • (If/2) (1 + m/4 + page 71 O(m 2 » + If (K' (m) /K(m» e • (m/16) (1 . 3. log x = K'(16/x 2 ) = n/(2 AGM(I. instead of x = e . P I n Let x n = e . so k = 30 gives 0. LOGARITHMS For small m. k . 2 30 = 1. x can be brought into range by reciprocating or repeated squarina.15 billion. Thus n = 2. 4 e ). m/2 + O(m 2 » Solve for K'(m) and let m • l6/x 2 K'(16/x 2 ) • log x + (4/x 2 ) (log xI) + O(log x/x"). If Ixl is not too close to I. 4/x». ITEM 144 (Schroeppel): n n n In the above. n e is calculated by starting with lIe and squaring k times. and therefore takes longer. This avoids having to square e.93 billion places accuracy and k • 31 gives 1. but requires two AGM's. Then the above equation for 1f is valid when n > 1.86 billion places. Requiring a given number of bits accuracy in log x is equivalent to requiring I (K' (16/x 2 ) this becomes  log x) flog xl < £ I (4/ x 2) (1 Ixl > 2/1£.15 billion.2. =2 Suppose £ = 10 to the minus a billion. For x sufficiently large.
377767.*. 9..Can't use TLCA over data.. ••• ) ITEM 147 (Schroeppel): Munching squares is just views of the graph Y • X XOR T for consecutive values of T • time.757757. it makes pretty patterns) with the low 9 bits = Y and the 9 next higher a X.. 300000.. also. Recommended variations include: CHANGE: GOOD INITIAL CONTENTS OF 1: none 377767. 3=Y.<right half» Also try the FADR after the XOR. (Try lOR. 1001. (And 105. \ .. 105=69. 757777.0. Beeler): A modification to munching squares which reveals them in frozen states through opening and closing curtains: insert FADR 2.1(1) 1/ see below 2/ ROT 1..7.3(1) 2. there is the following: 0/ TLeA 1.2. 6. FADR.1 ROT 1. Try things like 1001002 in data switches.0 TLC 1...ll .4 1000.. ITEM 148 (Cohen.) ITEM 145 (Gosper): Proving that short programs are neither trivial nor exhausted yet. related noises with a stereo amplifier hooked to the X and Y signals..1. Try data switches = 4000..=69 hexadecimal. DATAl 2 ADDB 1. 22 XOR 1.* •••••••••••••••••••••••• PROGRAMMING HACKS page 72 ••••••••••••••••••••••••••• *. TSC. This also does interesting things with operations other than XOR.9 3/ JRST 0 This is a display hack (that is.2 JRST .0 ITEM 146: Another simple display program: ("munching squares") It is thought that this was discovered by Jackson Wright on the RLE PDPl circa 1962. ROT 14. etc. FDV{!).* ••••••••••••• WARNING: Numbers in this section are octal (and occasionally binary) unless followed by a decimal point. it makes interesting. 5.1 before the XOR..4 2=X.1 7. TLC 1. 20.. AOJA 1.2(1) 373777. and rotations other than 22..1002 (Notation: <left half>.2002 2000. AOOOOB"AOOOOB ROTC I.•••••••••••••••••• *.. switches.4 0.2 ROTC 2.1. AND.
's and R for XeN) and YeN) can be found from N:O. the circle algorithm is stable iff 1£1 < 2. ITEM ISO (Schroeppel): PROBLEM: Although the reason for the circle algorithm's stability is unclear. The . and cosines! The "circle" will be perfectly stable because the points soon become periodic.. . because it needs no sine or square root function. then we don't even need multiplication. and it was a great wonder. X(N+l) : (2_£2)*X(N) . X(N) and YeN) are also expressible in closed form in the algebra of ordered pairs described under linear recurrences. and slightly affects the eccentricity.£ * OLD Y NEW Y = OLD Y + & * NEW(!) X This makes a very round ellipse centered at the origin with its size determined by the initial point. sines. and I was trying to get a curve display hack with minimal instructions. If £ is a power of 2. The algorithm is useful nevertheless. But it was basically lineoriented. The circle algorithm was invented by mistake when I tried to save one register in a display hack! Ben Gurley had an amazing display hack using only about six or seven instructions. what is the number of distinct sets of radii? (Note: algorithm is invertible. let alone square roots.Y(Nl). CIRCLE ALGORITHM: NEW X • OLD X . but they lack the remarkable numerical stability of the "simultaneous" form of the recurrence. The . where the constant is determined by the initial point.£ X Y + Y = constant. so all points have predecessors. 2 In this case! all points lie on the ellipse X . This ellipse has its major axis at 45 degrees (if c > 0) or 135 degrees (if & < 0) and has eccentricity {E/(l + E/2).) ITEM 151 (Gosper): Separating X from Y in the above recurrence. ITEM 152 (Salamin): With exact arithmetic. It occurred to me that it would be exciting to have curves.X(NI) Y(N+l) : (2_£2)*Y(N) . even to get started. £ determines the angular velocity of the circulating point.l.'s will differ by less than n/2 so that the curve is not really a circle. ITEM 149 (Minsky): page 73 Here is an elegant way to draw almost circles on a pointplotting display.). These are just the Chebychev recurrence with cos e (the angular increment) • 1_£2/ 2 • Thus X(N) and YeN) are expressible in the form R cos(N e + .
[377777. we can use a single circle algorithm to compute orbits for the corners to follow. you are on a twoscomplement machine. not including the beginning. If arithmetic overflow is a fatal error. If the result loops with period> 1. These two routines are clearly adjustable for BLKOs and other fenceposts. including the beginning. . some fascist pig with a readonly mind is tryin~ to enforce machine independence. A is a pointer to the last word HRLOI A.l(A) EQVI A. If the result loops with period • 1 with sign +. more precisely. consider the universe. If the result loops with period> 1. algebra: let X • the sum of many powers of two • ••• 111111 now add X to itself. ITEM 155 (Liknaitzky): To subtract the right half of an accumulator from the left (as in restarting an AOBJN counter): IMUL A. you a~e on a signmagnitude machine.ORIGIN Slightly faster: change the HRLOIs to MOVSIs and the EQVI addresses to ORIGINI.ORIGIN ITEM 157 (Freiberg): If instead. 2X = XI so X = 1 therefore algebra is run on a machine (the universe) which is twoscomplement. X + X • ••• 111110 thus. ITEM 154 (Gosper): The myth that any given programming language is machine independent is easily exploded by computing the sum of powers of 2. your machine isn't binary the pattern should tell you the base.1] ITEM 156 (Mitchell): To make an AOBJN pointer when the origin is fixed and the length is a variable in A: IIRLOI A. instead of simply rotating. you are on a string or Bignum system. But the very ability to trap overflOW is machine dependent. By this strategy. The (positive or negative) radius of each orbit is determined by the distance (forward or backward) from some origin to that corner. If the result loops with period = I at I.. The solid will appear to wobble rigidly about the origin.ORIGIN(A) EQVI A. or. you are on a onescomplement machine.ITEM 153 (Minsky): page 74 To portray a 3dimensional solid on a 2dimensional display. If you run out of memory.
PUSlfJ P. Other useful angle mUltiplying formulas are tanh X • (2 tanh X/2)/(1 + (tanh X/2)2) tan X = (2 tan X/2)/(1 . cos X. jsin X • X. bits FUVRI A. For cos and cosh. X In general.sin X/3 FMPR B. In fact.ari~ment in A CAMG 8.0) PUSHJ P. a cheap and dirty test for F(E) sufficiently small is to see if the addition step has no effect.SIN . . Changing the first 3. Thus: F(X) = cos(X)l F(2X).0.ITEM 158 (Gosper. by iterated application of double and triple argument formulas.00017] . if infinity is handled correctly.2 FADRI 8.0) FMPRB A. one can use cos X = 1 . (number of iterations) Then mUltiply by 2 Here. elliptic functions. to compute functions like e .[.B .(3.Isinl in D occurs when angle is smaller than end test Changing both 3. etc. sin or Isinl in B .0 to a +9.S7079632679] jw/2 SIN: MOVM B..sin X • 4(sin X/3)'3(sin X/3) POPJ P. it is necessary to subtract out the constant in the Taylor series and transform the range reduction formula accordingly.0's gives sinh: sinh X = 3 sinh X/3 + 4 (sinh X/3)'. then inserting PUSHJ P. within 27. cosh X s 1 + 2 (sinh X/2)2.[1. .(tan X/2)2).B FSC B.0's to +3.+l is a nice way to have something happen twice.+l after PUSHJ P.. Salamin. 2F*(F+2) F(E) • _£2 / 2 X G(X) = e 1 G(2X) • G*CG+2) G(E) • E This is to prevent the destruction of the information in the rangereduced argument by the addition of a quantity near I upon the success of the £ test.2 (sin X/2)2.~ r3 I 2 13 POPJ P. The addition of such a quantity in the actual recurrences is OK since the information is restored by the multiply.A . Schroeppel): page 7S A miniature (recursive) sine and cosine routine follows.sin in A. People lucky enough to have a square root instruction can get natural log by iterating X + X/(IT+X + 1) until l+X • 1.SIN gains about 20\ in speed and uses half the pushdown space « 5 levels in the first 4 quadrants). COS: FADR A. a LSH or FSC would work.(3.
LOG2 with a floating point argument in A. so X = 13 1 2 13 • ITEM 160 (Gosper): Here is a way to get log base 2.moby flunderflo LSH B.2 LSIIC A. LOG2: LSHC A. .7 SOJG A.Spcciner's bum .B .) The correct epsilon test in such functions as the foregoing SIN are generally the largest argument for which addition of the second term has no effect on the first.ITEM 159 (Gosper. Schroeppel): page 76 (~umbcrs herein are decimal.LOGL .exponent and sign sentinel 1·10 VE I A. FMPR B. so the answer is roughly the x which makes the ratio of those terms 1/2 27 . In SIN.C . so x = 13 1 2 13 • But this is not exact.2ll000 .fails on 4th try LSH A. . Call by PUSHJ P.20 1 (A) TLC C. you just square seven times and use the low seven bits of the exponent as the next seven bits of the log.l FADR A. 33 ~10 VSIC.answer in A POPJ P. since the precise cutoff is where the neglected term is the power of 2 whose 1 bit coincides with the first neglected (28th) bit of the fraction. Thus.9 REPEAT 7. the first term is x and the second is _x 3 /6. A and B are consecutive. x 3 /6 = 112 27 * 1/2 13 . Basically. 20 0 LOGL: LSH B.
Also. use SUB into a magic table.: ROTC A. places: ROTC A.LOCI Note: LOCI must not equal LOC21 If this can happen. N. > N > 35.N ROTC B.36. and used to be a TRC.N Thus MAC's can be ROTC'cd in 2M3 instructions.N36.<# bytes/word> followed by SUBI B.N ROTC A. clobbering A.6 ITEM 165 (Freiberg): A byte pointer can be converted to a character address < 2 18 by MULl A. To get full word character address. .N ROT B.LOCI EXCH A. EXCH A.B A.6 A. Liknaitzky): To rotate three consecutive accumulators N < 37. page 77 ITEM 163 (Sussman): To exchange two variables in LISP without using a third variable: (SETQ X (PROG2 0 Y (SETQ Y X») ITEM 164 (Samson): To take MAX in A of two byte pointers (where A and B are consecutive accumulators): ROTC CAMG EXCH ROTC A. (Stallman): For 73. ITEM 166 (Gosper.LOC2 EXCH A. use MOVEEXClIMOVEM. use TLCE or TUCE if the bits are not in the right half.C ROT B.BITS TRCE A.ITEM 161 (Gosper): To swap the contents of two locations in memory: EXCII A.l<' b/w>(A). ITEM 162 (Gosper): To swap two bits in an accumulator: TRCE A.72.B A. but TRCE is less forgettable.BITS Note (Nelson): last TRCE never skips.BITS TRCE A.
's in hexadecimal shifted 7 IUIVI A.'s in hexadecimal iif A is 6 bit quantity.4l DIVI A.B gets 7 bit character in A with even parity IMUL A.[421042l0421] ievery 4th bit IDIVI A. Freiberg): page 78 .where bits coincide with reverse repeated base 2 .where bits coincide with reverse repeated base 2 8 jcasting out 377's .casting out 15.casting out 15.[2010040201] i5 adjacent copies ievery 4th bit of left 4 copies + right copy ANU A. B gets number of l's (Schroeppel) IMUL A.[2102l02l00l0] IDIVI A.[20420420020] ANDI A.[1000400200l] AND A.9+7 iPowcrs of 2 3 are ±l mod 9 ichanging 7555555400 to 27555555400 gives even parity .[7555555400] .377 jcasting out 2 8 _1'5 jreverse 7 bits (Schroeppel) IMUL A.[1044220l0] iwhere bits coincide with reverse repeated base 2 8 IDIVI A. o'flow) .[2020202] i4 copies shifted AND A.l's ) .ITEM 167 (Gasper.n . icasting out 2 10 .[10020040l002] AND B.[IOOlOOlOOl] i4 copies AND A.[21042104377] . B gets 6 bits reversed (Schroeppel) IMUL A.if A is a 9 bit quantity.17+7 jodd parity on 7 bits (Schroeppel) IMUL A.17 .4 copies sep by OOO's base 2 (may set arith.5 copies in A and B 10 .leaves every 3rd bit+offset+right copy IDIVI A.1777 .[10040201] i4 adjacent copies lOR A.377 jreverse 8 bits (Schroeppel) MUL A.
. cleven suffice up to 254 •• FOO: . Lenard.333333] SUB A.. ••• ADDB 2.070707) IDIVI A.A then LSH B.3 ADD A..[707070707070] jor 171717171717. [Root and Mann]): To count the ones in a PDP6/10 word: LDB B.333333] SUBB A.(360600.2 AND 2.ITEM 168 (PDPl hackers): page 79 foo.B AND A.'5 These ten instructions.I AND B. This translates to the PDP6 (roughly) as: DATAl 2 ADDB 1. 454545454545.[070707.[333333.. ITEM 169 (in order of oneupsmanship: Gosper.. and slides. Mann.[333333.3 LDB 0. would work on word lengths up to 62. arpeggios.B LSII B.B .2] JRST FOO Listen to the square waves from the low bits of O. 363636363636.cach octal digit is replaced by number of lis in it LSJI B..l AND B. lat IDATAI switches adm a IADDB and (707070 adm b iot 14 loutput AC sign bit to a music flipflop jmp foo Makes startling chords.[014300"A] jor MOVE B.77 jcasting out 63. with just the sign of the AC. with constants extenaed.
line feed. doubling the dividend and divisor beforehand will distinguish division by zero from division by I or anything else."O jconvert digit to character SETOM CCT jthat was no digit! • lOT TYOCHN. jor OATAO or IOPB ••• TYO: This is the standard recursive decimal print of the positive number in F. store the argument in it. and call the garbage collector when the set is empty. G AOS G. called CONS. @ CON S Returns cell addressed by A to free storage listj returns former cell contents in A. When called with a 36.) EXCH A. ITEM 172 (Gosper): The fundamental operation for building list structure. ITEM 171 (Gosper): Since integer division can never produce a larger quotient than dividend. is defined to: find a free cell in memory. (BXCH A. the addresslinked chain of EXCH's indicated by the nested brackets is concocted by the garbage collector. It falls into the typeout routine which returns in G the number of characters since the last carriage return. DPT types carriage return. but with a LOB instead of a HLRZ.ITEM 170 (Jensen): page 80 Useful strings of nondigits and zeros can arise when carefully chosen negative numbers are fed to unsuspecting decimal print routines. and resets CCT. .(P) ..tuck remainder on pushdown list SKIPE F PUSHJ P. Example (Gosper): UPT: IOIVI F. the character position counter.(P)] jretrieve low 6 bits of remainder TRCE G.OPT LUB G. This can be done in two instructions: CONS: EXCH A.CONS EX CH A. return a pointer to it.GC] ••• ]] EXCH A. remove it from the set of free cells.[EXCH A. Different sets arise from different methods of charactertodigit conversion. in situations where division by zero does nothing.[ ••• [PUSHJ P.12 HRLM G.CCT POPJ P.CONS Of course.[220600.. UNCONS: IIRLI A. This method has the additional advantage of not constraining an accumulator for the free storage pointer.
This works on both machines and doesn't involve A+l.A MOVN e.c. B.] ior FADR for rounded fix! TLC A.. ITEM 174 (Gosper.[±233000. you can FAD A.233000 iif those bits really bother you When you know the sign of A._ .e MOVE D.(±233400.B AND C. On the PDPlO UFA A. = 243507216435 is a fixed point of the float function on the PDP6/l0.A . Nelson): 21963283741.400 iexponent to A. it is the only positive number whose floating point representation equals its fixed.8(A) ianswer in A+l If number is known positive. FADRI saves a cycle and a constant.. fraction to A+1 TSC A.A XOR D. C.20027.) inot in PDP6 repertoire TLC A+1.C . and IAI < 2 26 .B ADD A. and rounds.l's complement magnitude of excess 200 exponent ASH A+l. ITEM 175 (Gosper): To iet the next higher number (in A) with the same number of 1 bits: (A.ITEM 173 (Gosper): page 81 The incantation to fix a floating number is usually MULl A. On the 10. i. D do not have to be consecutive) MOVE B.C lOR A.233400 iif those bits are relevant where the sign of the constant must match A's. you can omit the TSC.B LSII D..2 IDIVM D.
(If F increases with Y. and we have only to check whether changing the other (decrementing X) will reduce the magnitude of F. and thus a loop. thus forcing A. First.) F can often be manipulated so that the inequality simplifies and so that F is easily computed incrementally from X and Y. This ensures that every 4letter string output occurs in the original. 11e can show that for reasonable F. The editing program TECO finds five. Thus. The program typed BANANANANANANANA •••• \~e note an ambigui ty in the phrase. only two different increments (say north and northwest) are needed to visit the desired points. divide the curve into arcs within which the curve's tangent lies within one 45 degree semiquadrant. in another." In one sense. searching for a random occurrence of that sequence in the text.Y+I) means decrement X. if near the curve F is monotone with distance from the curve. and is thus obligated to type N next. The following algorithm will draw most such curves more accurately than polygonal approximations and more easily than techniques which search for a "next" X and Y just one move away. Many curves and contours are definable by FeX.Y) = 0 with F changing sign on opposite sides of the curve.********************************************* pag e 82 PROGRAMMING ALGORITHMS. "the Nth occurrence of. HEURISTICS ********************************************* ITEM 176 (Gosper): The "banana phenomenon" was encountered when processing a character string by taking the last 3 letters typed out. F(X. there are five OO's in 0000000000.t This tends to choose the nearer endpoint of each graph paper line segment which the curve crosses. has opposite sign and smaller magnitude than on one or more of its four immediate neighbors. By Murphy's Law. when evaluated on one of them. ITEM 177 (Gosper): DRAWING CURVES INCREMENTALLY Certain plotters and displays are constrained to approximate curves by a sequence of kingmoves hetween points on a lattice.Y+I) > FeXI. we will be changing one coordinate (incrementing Y) every step. there is but one NAN. taking the letter following that occurrence. . and iterating. Thus it finds only the first ANA in BANANA. there are nine. although it would require backing up NI characters before seeking the next N character string. An option to find overlapped instances would he useful. typing it out. We observe that a good choice of lattice points is just those for which F.
is possible. X + + R F+2Y+l.e. 1100 (or 0011) will not occur with a curve of limited curvature: thus. Knowing this value. F XI go to Cl + (Link to next arc) if Y • XI. or the loop may be closed at C2 and C3 with two PUSHJ's to provide the palindrome of decisions for the first quadrant.As an example. with four diagonal segments. . I: All this suggests that displays might be designed with an increment mode which accepts bit strings along with declarations of the form: "0 means north. however.. if Y < ift F > X. do not choose both points but rather have some arbitrary yet consistent preference for. Y + Y+l F2X+l. Y + 0. we can replace C3 and C4 with a simple loop count and an oddeven test for C4. it could be used as an escape code. i. The problem can't arise for C2 in the example because the inequality F ~ X is really F > (F2X+l) or F > X. the outer one. say. Y Y+l. page 83 the following computes the first semiquadrant of the circle co: Cl: C2: C3: C4: F F + + 0. X + XI This can be bummed by maintaining Z • 2Y+l instead of Y. There is an expression for the number of steps per quadrant.S. F has equal magnitudes with opposite signs on adjacent points. X + XI. Symmetry may be used to compute all eight semiquadrants at once. t In case of a tie. See the following illustration of circles drawn this way. 1 means northwest". The loop must be toptested (C3 before Cl) if the "circle" R 1. but it has a threeway conditional dependent upon the midpoint geometry. but this would be an annoying restriction.
.
non S.next . be computed as functions of the sought string.A C.could be SAS. Then YeA) can be evaluated to N places in time proportional to N(ln N)3. . Also.could be an S o 1 2 3 4 is. Salamin): page 85 Suppose Y satisfies a differential equation of the form P(X)Y(Nth derivative) + ••••• + Q(X) • R(X) where P. and the first derivative of F(X).A C.skip if A . and R are polynomials in X (for example.A C. e and In X or any elementary function can be evaluated to N places in N(ln N)2 for X a real number. however. a number> 0 in the top row is a location in the program where the corresponding letter of the middle row is compared with a character of the input string."S TO C.A C. If it differs. Let S ASS Y o 1 022 stand for the program TO: Tl: ILDB CAIE JRST ILDB T2: CAIE JRST ILDB T 3: CAIE JRST ILDB T4: CAIE JRST ILDB CAIE JRST jfound SASSY C. the number in the bottom row indicates the location where comparison is to resume.A C. ITEM 179 (Gosper): A program which searches a character string for a given substring can always be written by iterating the sequence fetchcomparetransfer (ILDBCAIEJRST on the PDP6/l0) once for each character in the sought string.ITEM 178 (Schroeppel. ••••• Q. A.ASSY jcould be SASS. X Further. t(3) and y can be done in N(ln N)3. The destinations of the transfers (address fields of the JRST's) must. If it matches. If F(X) can be evaluated in such time. so can 'the inverse of F(X) (by Newton's method)."S T2 C. X 2 Y"+XY'+(X 2 _N 2 )y • 0) and A is an algebraic number.C gets next char from pointer in A jskip if it's an S ilooP back on failure jnext ."S TO C. so start over ."A Tl C."Y T2 . the next character of the middle row is compared with the next character of the input string.ASSY In other words. Bessel's equation.
We define the corner of a broken line segment to be the point the sum of whose distances from the endpoints is maximal. Open the loop by making this place both endpoints and calling it a corner. omitting the initial ILDB from all but the first. The perpendicular distance which the vector C lies from the line connecting vectors A and 8 is just (C . If it is a closed loop. initially O. This will uivide the segment in two. K(J) • K(P). ••• we compute K(J) as follows: K(l) = O. The distance sum hack can lose on very squashed Z's. 2. Otherwise.A) x (8 . It might be reasonable to compile such an instruction sequence whenever a search is initiated.page 86 Let J be a number in the top row and K be the number below J. we produce a program of ILDBCAIEJRST's for each of the sought strings. until our corner isn't much cornerier than the others along the line. allowing us to proceed recursively. For each J ~ 1. increment P.) J= K(J)= 0 1 0 I 1 I MI S S I S S I P P I 0 1 1 1 1 I 1 I 1 2 3 4 5 S S I S S I P P I 0 1 1 0 I I 0 5 1 0 I 0 1 2 3 C 0 C A C 0 L A 0 I 0 2 0 I 3 1 0 1 2 3 S A S S A F R A S 0 1 0 2 I 3 1 I 0 To generalize this method to search for N strings at once. We must compute the destination of the Jth JRST in the Ith program. For each succeeding J. find the vertex furthest from the centroid (or any place). (P(J) is the largest number such that the first P characters match the last P characters in the first J characters of the sought string. Assume you have a broken line. K(J) = P. which is the location of the Kth compare in the Mth program. If the Pth letter = the Jth. since alternative schemes usually require saving or backing up the character pointer. TKM(I. and P is reset to O. 81 . so that TK is the address field of the Jth JRST.J). ITEM 180 (Gosper): A problem which may arise in machine processing of visual information is the identification of corners on a noisy boundary of a polygon.A) 2 fA  but maximizing this can lose on very pointy V's. Let P be a counter.
You might check this in your PDP6/10. so you will be off by 2 smidgens (thati is. 2) A disadvantage is that the termination of the normalization process is ambiguous. Overnormalized negative powers of 2 work in compares and most floating arithmetic.777777. not (2) . This means it is necessary to check whether shifting left one more bit will bring in a one: if it brings in a zero. relating to excess200.. and when you then renormalize.0+0 with minus 200777. the normalizing amount will be doubled. (2 ).also.********************************************* IlARD'~ARc page 87 ********************************************* ITEM 181 (Gosper): A bug you might try to avoid when designing floating point hardware. except as divisors and dividends. Unnormalized floating operands win completely on the PDPIO. the latter suffering truncation error. (That is. Normally.. A special case arises with n n negated powers of two. and the correct FMPR result is minus 200777.777776.. Note that rounding can overnormalize as well as unnormalize. . the next to low order bit).) Then the fraction is 400.777777+20. so you can't just stop normalization after rounding. combine 201400. rounding will unnormalize. They lose with MOVN and as dividends. the correct FMP result is minus 200777. the number is normalized.. when the sign bit unequals the highest bit of fraction. 2's complement fraction convention: 1) An advantage is that negation and numerical comparison can be accomplished with the same instructions for both fixed and floating point numbers. For o ~ 0 ~ 7777. For example.. you should do it If you should but don't. you will overnormalize if it brings in a one.0 and the sign is . l's complement exponent.
fundamental. (A current mirror supplies a current on one wire equal to that drawn from a second wire. but be careful and lucky or it may oscillate at a frequency determined by the crystal holder capacitance and not by the crystal. . transistor II crystal. CMOS. transistor (drives at least I TTL load) III crystal. paRe 88 ITEM 183 (Roe): CURRENT MIRRORS The CA3083 (and CA3084) transistor arrays can be used to make neat current mirrors.) ITEM 184 (Roc): ONESHOT A dual MUS Utype flipflop (such as the CD4013AE) can be used to make a oneshot as follows: c rCLOCK tJ •• ~ ! 5"0 1\$ t CLOCK 50 "5 . fundamental. draws 330 microamperes. overtone. with the exception that the turns ratio be such that Vb (see graph) not exceed BVebo (about 5 volts for silicon transistors).ITEM 182 (Roc): VOLTAGE REGULATORS Fairchild is now supplying positive voltage regulators costing about 2 dollars in lots of I (for example.&3RC \ I ITEM 1~5 (Roc): OSCILLATORS Evryone has their own favorite oscillator circuits.4 volts and no load. Ie (a favorite of Nelson's. the uA7805 for +5 volts). note similarity to noncrystal oscillator V) V not crystal controlled. for comparison with IV VI The following blocking oscillator is quite uncritical of component values. I crystal. here are some we like. varies about 10 liz per volt of Vee) IV crystal. low frequency (drives I TTL load. at 5. with a 165 KHz. 32 pf crystal. fundamental. 1v <t 5 @ 'OV ~.
v . .e te. 1I.page 89 tS I . o =~ CbJf001AE.
5 RC ITEM 186 (Roe): FM RADIO LINK In work on education at our lab. . Use a commercial FM tuner as receiver. . II 'turn~ 15K _4+..page 90 +'1 'V OV ...' 4ntennCl. r  18 +' I.7 ~.r~ %J)IA Y LONG.jruuD ... .'\J 't' "'" .' .. to t.. we built a motorized "turtle" controlled by computer commands in the childoriented language "Logo." The following is a transmitter designed as a radio link between the computer and turtle.. Note: this transmitter is ILLEGAL no matter what.stt!. part 15 low power rule only allows if duty is less than about 1 second per 15 minutes. output is about 88~lz. Input (modulation) is either o or +12 volts. +v +.COI Ho1e: or't io". Uon't worry about it unless you interfere with broadcast stations.
a human attendant at the tournament moves the pieces. punches the clock.r . and communicates with the program via a portable terminal coupled to a telephone line. As we all know. It is desirable that the program know when its chess clock is running. '" '320 Hz t'l ~ 1. . It switches between two frequencies. Also shown is the receiver. The following is a 10 mw tran~mitter whose input is the microswitch and whose output goes onto the phone line. Input should be at least 100 mv rms (threshold is 20 mv and overload is above 68 volts) with peak to peak signal to noise ratio greater than 4:1. \_".. connections to phone lines are illegal unless made through a data coupler supplied by TPC (The Phone Company). Therefore we built a clock holder with a microswitch to sense the clock state. about 320 and 470 liz. even though the attendant may not notice immediately that the opponent has made his move and punched the clock.ITEM 187 (Roe): PHONE LINE XHTR..~3=_ _+_ _.170 Hz. .. RCVR page 91 When the chess program written at our lab is playing in a chess tournament.t .1 +.
I K. Since its path is to be as straight as possible.2.. Diagram II shows the actual circuit used in the turtle. Diagram I shows a simplified velocity servoing circuit.ITEM 188 (Roe): UC MOTOR VELOCITY SERVO page 92 une version of the "turtle" mentioned above (see RADIO LINK) uses a UC motor to drive each of its two powered wheels.hQt\ical l"eSr~tcu'('t + I~s ~ ""ore control «.l0'3 1N36'f5 1NS1'O b. (ttlj '"'sts mec.no.~K J[ . a triangular pulse is generated (to represent one "step" of the motor) and the motor's velocity servoed to this analog command. An additional digital command enables foreward or reverse motion. It has the disadvantage that only half the maximum voltage available (V to +V) can be applied across the motor at anyone time.
whose coils are wound on opposite sides of a ceramic ferrite.y 'trtm de.ITEM 189 (Roe): OPTICAL COUPLER page 93 When two circuits are at potentials differing by a few hundred volts but wish to communicate with each other. hut the signal from a lightsensitive transistor is much stronger. MCTl +5 +. . Diodes make very fastresponding sensors. the photocathode sits at several thousand volts negative. Shown is a compromise.f70 ITE~1 190 (Roc): PHOTOCATHODE CURRENT aSCI LLATOR In our fourth computerinterfaced image sensing device. one solution is to use an optical coupler. The following circuit draws no more than 400 microamperes at 10 volts (at 20 KHz out. one wishes to sense the current it draws. Nevertheless. since overcurrent should shut down the photocathode voltage to avoid damage to the photocathode.'JA.IJ ~tLO de1q.sec '17 I'M' /. These employ a lightemitting device placed close to a lightsensitive device. about 200 microamperes at 10 KHz) and couples the current information out as the frequency sent to T2. using a transistor as a diode. with associated cleverness to get the oelay (from input to output) down from 10 microseconds to 1. not a TV).l<lY . TVD (really a vidissector.
the device should be constructed like a 144 ~iz transmitter to avoid its becomming one. Q15. 6 * = temperature protection circuit (overtemperature cutout). Case temperature about 70 degrees C max. 4 lUl03 = GE thermistor mounted at center of main heat sink. lN4l54. 8 All transistors Motorola. as with most fast highgain circuits. 2 Capacitances in microfarads/volts. . B Gr~und loops: reference ground (triangles) and power ground must be interconnected only at the cold side of the sense resistor. better. QIl. which could improve settling time ~ore than the reduced gainbandwidth would increase it. 9 All zeners 1 watt. Except for the notes with the diagram. mentioned above. Q7 Q17 Q12.lN4009 etc. uses a very carefully designed printed circuit amplifier to supply current to its magnetic deflection coils. take care to avoid stray current through the cold side of the signal input. stored charge no more than 80 picocoulombs at 1 milliampere foreward current. damping R about ISO ohms for critical damping. 12 Slews from + (or ) 2 A to . Q13. and ceramic capacitors with leads as short as practicable used for bypassing. Q14. Q6. Q12. 10 VE48X = Varo. we submit it without further explanation or cautions. Ql6 mounted on one 1 Centigrade degree per watt heat sink (e. Q4. Ql4. 1/4 watt. 13 Layout is critical. Ground heat sink and insulate transistors. Q2. Q4.USI 2N 5194 2N 5191 MPSU02 MPSU52 2N 3906 2N 3904 Q6 Ql6 QH. electrolytics aluminum. Q3. resistors 10%.. 11 Output capacitance about 800 pf. Q9. a ground plane) should be used for ground bus. 3 Uiodes IN4727. Q19 Q18 '113 Q3 HPSUOI ttPS . 14 The 100 pf stabilizing capacitor may want to be higher to decrease hunting and ringing. Notes: 1 Except where noted. A Bypassing and lead inductance: Short wide strips (or. S 220J = Analog Uevices chopper amplifier. Best bypass capacitor is AllenBradley CL series. C In general. could be two 2 A SO PIV fast recovery. dE/dt at hot side of deflection coil is about a billion v/sec.ITEf·1 191 (Roe): UEFLECTION AMPLI FIER page 94 TVU. Ql. 7 Q2.g. Q5. Wakefield 621K 1/2 inch in front of Rotron Muffin fan). Q5.(or +) 2 A in 4 microseconds. Q15.
"0 so ~ ~ V1 ~ ..+15 • so +. .::I:.
.
continued fraction 63 101 122 137 approximation 101 arbitrary 19 III 177 arc 123 177 arccos 14 IS 116 arccoth 126 arcerf 45 archaeologist 135 arcsin 10 .INDEX {cross reference} (explanation) Compiled by Rich Schroeppe1 and Hi1arie Orman.8453 45 1 {one} 22 57 107 125 158 159 167 169 171 173 175 177 181 1st 49 60 62 115 132 159 1st order 6 15 1:2 80 2 {two} 14 23 31 32 35 43 45 47 48 57 60 63 97 120123 137 144 149 152 154 159 160 2dimensiona1 153 2NOTS 19 n o 2 20 24 64 3 {three} 35 49 68 97 107 116 127 3rd 123 132 163 3dimensiona1 112 153 3space 77 3N+1 133 4 47 50 89 92 115 127 134 136 fourinarow 112 4th power 6 14 63 4letter 176 4space 107 4vector 107 4. Honth1y 48 120 amicable number 61 62 analysis 25 143 analytic function 11 126 analyze game 68 74 81 88 94 AND 1119 22 23 43 115 angle 45 101 131 158 angular velocity 149 151 annoying 111 answer 45 57 105 AOBJN 155 156 appear 39 153 append 101 122 Applied Combinatorial Math.86\ 29 5 47 51 57 61 78 81 90 103 fiveinarow 91 5th power 63 121 6 73 83 141 7 31 82 97 113 114 160 7co1oring 114 9 72 141 14 105 18 83 20omino 77 23 63 28 61 30 12 34 68 40 47 63 51 72 bits 25 104 120 60 130 50 220 62 239 63 256 82 284 62 292 101 355 101 672 60 1093 45 3511 45 7094 112 23000 41 2 18 41 28 ' 57 Abramowitz 120 143 acce1eraiing 120 124 accumulator 155 162 164 166 172 Adams. 77 86 approximant. {zero} 43 68 . Clifford 49 add 18 40 43 50 addl 64 addition 101 158 159 chain 12 additional 172 address 151 165 172 179 adjacent 68 167 111 advantage 101 172 181 AGM 131 143 144 alephtwo 129 algebra 13 151 154 algebraic functions 101 number 32 101 178 algorithm 17 101 115 132 149153 176180 f1g9 alternating series 120 amazing 149 ambiguity 116 181 American Math.
Elwyn 69 Bernoulli 12 121 Bessel functons 99 101 178 best 17 72 bignum 101 154 billion 143 binary 12 22 60 63 115 122 128 fig7 132 145 154 binomial 38 42 43 116 118 120 121 bisector 3 bishop 70 78 bit 22 25 37 55 fig1a fig1b fig2 101 104 115 122 128 fig7 132 143 145 159 160 162 167 168 170 173 175 177 181 black 70 84 88 89 black box 19 blackout 68 board 68 76 78 84 9092 94 112 Boolean 1724 boundary 20 125 180 bounded 45 47 77 box 112 bracket 30 branch point 130 143 bridge 46 Brillhart.arctan 16 63 101 137 138 140 area 114 arg. for Fun and . Chess for Blood 70 Chinese remainder theorem 48 Choong 140 chord 168 chromatic number 113 circle 20 32 83 123 fig6a fig6b 125 149153 177 fig9 circumscribing 20 claim 65 122 Clements. Robert 112 clever 71 clock 123 fig6a fig6b closed form 10 14 116 118 131 151 177 180 closest 3 15 closure 105 clue 19 101 cluster point 32 code 25 coefficient 13 14 43 44 101 118 125 130 Cohen. Joe 117 148 coin 67 color 71 73 110114 common divisor 53 Communications of the ACM 112 commutative 101 127 comparison 101 181 compile 179 complement 75 105 122 173 181 complex number 14 55 fig1a fig1b fig2 123 fi~6a fia6b 136138 143 complicate 101 composition of functions 101 107 127 computation 1214 65 68 83 101 115 123 140 142 153 154 158 177 179 Computers in Number Theory 77 concurrences 2 condition 11 101 III 130 conformal map 11 conjecture {problem} 33 35 S6 101 112 125 conjugate 32 107 123 conjunction 137 connected SO 73 114 115 180 CONS 172 consecutive 25 121 160 164 166 175 constant 14 SO 51 127 129 152 158 169 173 . Roger 20 133 base {radix} basis vector 13 14 Ber1ekamp. complex number 137 argument 132 158160 172 arithmetic 101 expression 101 geometric mean {AGM} mean 131 143 series 14 35 99 101 arpeggios 168 array 18 38 120 121 Art of Computer Programming {Knuth} aspect ratio 80 112 associative 12 asymptotic 77 86 automatic 101 axis 3 107 143 152 backing up 176 179 banananana 176 Banks. John 28 65 broken line 180 Brown. Steve 75 bug 45 135 181 bum 160 177 byte 164 165 C curVe 135 fig8 calculate 26 68 143 carriage return 170 carry 43 115 casting out 167 169 CDR 132 center 51 68 76 112 114 123 149 symmetrically 74 centroid 180 certified 137 chanaing 123 158 167 character 21 134 165 167 170 176 179 cheap 158 Chebychev 14 15 151 checkerboard 84 112 checkers 93 chess 70 78 87 88 95 Chess.
l.nt 14g element 82 102 121 elementary function 178 ellipse 149 152 elliptic function 10 131 143 158 empirically 101 empty S2 78 101 172 endpoint 101 177 180 energy 46 epsilon 149 152 159 equal 132 161 174 equation 3 8 9 178 equilateral 112 equivalence class 75 error 3 45 101 117 154 181 bounds 101 escalation 88 escape code 177 estimates 82 93 101 Euler 107 120 .constrain 101 172 177 construct 39 4$ 80 135 continued fraction 97101 122 137 140 arithmetic 101 continuous 107 115 contours 177 converge 3 12 120 122 124 125 130 142 143 convergent 101 convex 20 24 coordinate 48 52 107 177 copy 24 35 115 122 167 corner 48 SO 68 112 153 180 corollary 51 correct 159 correction 101 cosh 158 cosine 14 15 26 107 i42 149 151 158 cotangent 142 coth 126 count 18 29 77 81 82 108 112 115 169 177 counter 64 155 170 179 counter (token) 90 counterexample 12 counterintuitive 75 cover 21 50 72 86 110 III Coxeter 113 cross product 107 180 cube (box) 71 112 (power) 6 45 58 63 magic 50 51 root 8 159 cubic equation 8 10 partition 18 polynomial 127 curious 59 77 118 curtains 148 curve 55 fig1a fii1b fig2 66 115 122 123 135 fig8 149 151 177 fig9 cycle 47 132 173 data 29 75 77 Daykin 140 decimal 33 36 37 56 57 101 139 145 159 170 decomposable 112 decrease 19 S6 degree (polynomial) 5 13 IS 127 (angle) 152 177 delta 120 181 denominator 12 45 54 101 122124 140 dense set 3 density 35 dependent 13 derivative 178 determinant 5 101 determine 39 42 47 118 149 152 153 deuce rule 42 diagonal 2 50 68 90 120 121 177 diamonds 112 dice 67 72 difference 14 forward 37 38 120 differential equation 178 differentiate 118 digit 33 37 39 43 56 57 72 101 115 120 140 141 169 170 dimension two 48 107 153 three 18 107 112 153 four 107 n 77 83 of vector space 1 direction 45 123 dirty 158 disadvantage 181 discover 18 49 64 71 146 149 discriminant 4 5 disordered 46 display 123 145 146 149 153 177 dissection 85 fig4 distance 153 117 180 distinct 22 56 68 71 103 112 lIS 150 171 distribution 26 32 40 46 107 diverge 133 divide into parts 177 180 division 101 181 by zero 3 171 divisor 43 53 60 101 110 136 domino 86 III 112 don't care 17 dot product 107 121 dots 69 73 double 14 45 78 158 171 181 dragon curve 135 draw (game) 73 94 (picture) 55 fi. fil1b fil2 114 149 177 fig9 dual 7S e 12 37 101 117 118 143 144 158 178 edle 50 112 egest 101 elea.
Ben 149 hack 145 149 180 hackers 168 hairy 67 97 half 32 123 halfline 18 ha1fword 148 155 162 Hamiltonian path 103 hand 46 94 123 fie6a fig6b Handbook of Math. G. Introduction to 113 gigantic 101 giveaway chess 87 Go 96 golden ratio 12 32 goodies 139 government 137 graph 147 177 greater 175 greatest integer . Martin 49 80 fig3a 112 gates 17 Gaussian distribution 26 27 40 Gaussian integer 55 fig1a fig1b 136 137 GCD 52 101 generalize 14 18 21 47 generate 11 26 27 64 101 137 generating function 7 15 18 geometric dissections 85 geometric mean 131 143 geometric series 38 geometry 2 177 Geometry.evaluate 13 14 68 116 177 178 even 54 115 133 167 177 exact {closed form} 10 26 41 159 arithmetic 3 152 example 61 68 76 85 86 101 102 110 113 124 127 137 170 177 178 181 exception 32 45 47 138 181 excess200 173 181 exchange 163 exciting 149 Execuport 21 exist 11 14 18 39 48 76 97 102 107 expected value 29 107 exponent 43 160 173 181 express 1 13 34 47 63 131 expression 14 36 43 57 127 177 extend 77 extra move 94 factor 28 29 45 47 52 61 63 120 136 137 factorial 1 31 34 43 98 103 116 117 121 123 139 fascinating 123 fascist 154 fast 120 142 143 fatal error 154 favorite 25 feedback 17 101 fencepost 157 Fermat 106 fetch 179 Fibonacci 12 14 47 123 field 13 107 find 21 22 31 68 80 86 III fine structure constant 101 finite 33 39 132 finitestate 115 fit 83 fixed point number 173 174 181 of a function 174 f1atsize 134 flipflop 168 floating point 3 101 160 173 174 181 flow 25 126 127 129 130 132 FMP 181 foo 168 forced win 94 form {closed} 38 47 56 73 112 114 178 formula 1 12 14 18 77 86 120 137 158 forward difference 37 38 120 found 49 61 112 137 179 fraction {continued} 32 122 159 173 181 fractional fibonacci 12 fractional part S5 fig2 141 Fredkin. Bill 133 heptahedron 114 heptomino 109 heuristic 75 176180  . Edward 38 58 free 172 Freiberg. 136 hemisphere 107 Henneman. Jerry 157 165 167 frob 113 FSC 158 function 57 1012 15 1719 25 68 83 98 99 118 123 fig6a fig6b 125 129 131 132 142 143 151 158 159 174 178 179 future 25 game 42 46 6776 78 84 8796 112 gamma 117 120 178 gaps 83 garbage collector 172 Gardner. Functions 143 handicap 42 hardware 181191 Hardy. H.34 101 120 group S6 82 102104 107 grow 101 gruesome 73 guidance 107 Gurley.
Jud 169 length 27 39 47 49 56 57 61 68 123 132 156 169 lexicographic 75 Liknaitzky. Edward 70 last 106 123 157 176 179 last digit 57 last move 68 84 lattice 48 52 68 177 least common multiple 47 left 112 181 Legendre 29 lemma 19 50 Lenard. Jan 2 Komo1goroff 105 L 68 language 80 fii3b 154 large 32 94 122 larger 62 171 largest 14 29 43 72 132 159 179 Lasker." hex 94 hexadecimal 122 145 167 hexafrobs 112 hexagon 49 85 fig4 112 114 hexiamond 112 figS hexomino 109 HiQ 76 high order bit 181 hole 77 112 113 homographic 101 how many? 39 57 77 how much? 42 Hurwitz numbers 101 iamonds 112 figS identify 101 identity (equation) 42 101 118 137 identity (group) 12 101 102 107 illustration 55 fig1a figlb fig2 80 fig3a fig3b 85 fig4 112 fig5 123 fig6a fig6b 128 fig7 135 fig8 177 fig9 image 19 123 fig6a fig6b imaginary axis 3 impossible 49 50 64 72 112 imprecise 101 increase 18 56 68 99 increment 132 151 177 fig9 179 independent variables 26 29 40 101 independent vectors 14 independently 64 71 77 indicator 68 induction 32 75 inexorable 132 infinite 35 39 91 101 123 135 infinity 83 133 information 158 180 input 17 64 101 115 170 179 Instant Insanity 71 instruction 64 104 149 158 166 169 172 179 181 integer 18 32 34 40 47 52 60 83 101 120 125 130 136 171 integral 116 143 interesting '112 121 123 138 145 146 interexpressib1e 1 international 137 interpolation 130 interval 15 101 115 intriguing 123 Introduction to Geometry 113 invariant 101 inverse 1214 25 112 115 118 150 178 invisible 48 iridium 137 irrational 45 101 irreducible 13 isomorphic 107 isosceles triangle 135 iterate 12 14 25 56 61 72 115 124 132135 158 176 179 itself 122 132 Jensen. Eric 132 170 joys 63 jump 64 76 king 70 78 87 88 89 kingmoves 177 knight 38 70 78 known 39 45 61 63 64 80 fig3a 85 86 127 133 143 173 Knuth. Harry 85 line 18 38 68 73 93 170 177 180 lineoriented 149 linear 101 linear combination 13 127 151 linked 172 177 Lisp 163 list 68 82 132 170 172 listen 168 location. Rici 64 155 166 limit 35 77 115 131 142 143 Lindgreen. memory 161 172 179 locus 45 log 1214 26 29 35 117 143 144 158 160 178 10g2 120 132 160 logic 1724 long 68 123 132 longest 33 longhand 134 loop 3 25 57 61 62 101 132134 154 176 177 179 180 lose 180 181 low 22 25 145 160 168 170 181 lowest 5 46 lowest terms 101 LSH 25 158 machine 25 64 66 101 115 180  . Donald 29 55 fig2 101 132 Kok.
and Plausible Reasoning 125 Math. Marvin 64 149 153 mirror 135 mistake 149 Mitchell. Bill 169 map 11 18 107 113 115 128 fig7 132 mask 22 match 101 115 132 173 179 Math. of Computation 140 Math1ab 4 127 matrix 14 107 maximum 35 39 56 63 67 68 164 180 mean 131 143 measure 45 107 137 member 47 61 62 115 120 memory 115 154 161 172 Mersenne 28 63 method 3 12 21 26 29 42 126 143 170 172 178 179 metric 101 midpoint 177 minichess 78 minimal 12 21 22 85 137 149 minimal representation 101 minimum 17 21 62 73 98 Minsky. Wolfgang 63 multinomial coefficient 43 44 mUltiple 45 57 mUltiple valued 137 mUltiplication 12 101 107 137 149 mUltiplication formula 1 14 158 mUltiply perfect number 60 mu1tiprecison {bianum} munching squares 146148 Murphy 176 music 168 myth 154 nspace 11 27 nsphere 11 107 narrowness 101 natural boundary 125 130 nearer 177 nearest inteaer 101 necessary III 130 negation 101 123 181 negative 133 138 143 153 170 negative radix 128 fig7 neglected term 159 neighborhood 107 177 Nelson. W. 86 more 37 112 122 most 46 fif3b 95 114 move {aame 25 MOVN 181 Mozart. George 156 mode 177 modern analysis 143 modular function. E.80 majority 17 Mann. elliptic 10 139 modulus 12 13 43 45 47 86 101 122 136 167 monotonic 18 101 177 Montro11.machine independent 154 magic 4951 81 165 magnitude 123 154 173 177 1. Stuart 162 174 never 94 162 171 new 149 Newton's method 3 12 126 178 next 120 123·160 Nim 68 74 no 18 SO 51 63 76 107 112 127 132 noise 145 180 noncommutative1y 107 nondigits 170 nonexponential 68 noninteger 130 nonregular continued fraction 122 140 nontrivial 28 137 145 nonuniform distribution 32 nonlinear recurrence 15 nonzero 13 57 107 norm 136 normalize 27 181 not 17 19 68 113 115 161 172 noted 56 nth 5 7 14 IS 37 38 43 57 101 115 120 121 130 176 numerators 101 numerical 22 151 181 representations 101 n n 118 occurrence 62 octagons 135 octal 145 169 octant 18 odd 45 68 133 167 oddeven 177 offset 167 omino {po1yomino} one {I} 67 101 122 169 181 onedigit 56 onetoone 11 101 115 oneupsmanship 169 onescomplement 154 only 45 47 57 63 64 71 76 174 onto mapping 11 115 opening 148 operand 101 181 operation 11 34 101 132 146 172 opponent 78 88 optimal 67 72 option 176 OR 18 19 23 25 orbit 153 orchestras 63 .
large 32 I I precision 101 predecessor 115 150 prediction 25 29 47 preempt 101 preserve 22 115 previous 122 130 prime 17 29 30 33 35 41 43 45 47 48 52 62 65 136 137 primitive root 57 print. most 46 probably 32 35 83 85 problem 1 2 11 17 19 21 22 27 31 32 34 36 39 42 47 49 68 70 73 101 103 107 110 I I I 116 119 123 127 129 130 133 150 177 180 procedurally 101 procedure 13 product 13 45 47 S6 107 122 PROG2 163 program 57 61 64 75 7796 101 103 123 137 145180 progression 35 99 project 11 projective 107 promoted pawn 87 proof 13 18 32 50 S2 94 97 106 113 propoganda 101 prove 89 proved 31 3S 47 64 85 122 pseudorandom 132 pushdown 158 170 PUSHJ 158 177 puzzle (games) 56 71 79 112 pUZZle (question) 18 Pythagoras. partial 18 origin 52 149 153 156 original 22 124 orthogonal matrix 107 outer 177 output 25 101 115 168 176 overflow 154 167 overlap 84 176 packed 71 pair 12 61 62 101 103 151 palindrome 177 parallel 50 parallelogram 112 114 parameter 107 parity 115 122 167 partition 18 Pascal's triangle 121 Paterson. Dave 71 plus 23 75 point 32 42 48 52 107' 123 130 145 149 150 152 160 174 177 180 181 pointer 156 \157 164 165 172 179 poker dice 67 polar 107 pole 101 Po1ya. Mike 71 path 19 103 pattern 114 122 123 145 154 pawn 70 78 87 89 PDP1 74 75 123 fig6a fig6b 146 168 PDP6/10 104 168 169 173 174 179 181 peg SOlitaire 75 76 pentagon 85 pentomino 84 perfect number 6062 period 68 101 132 154 periodic 45 101 149 permutation 22 56 75 103 104 perpendicular 3 107 120 180 Perron 100 phase 137 143 phenomenon 176 phi function 45 phrase 176 physically 123 pi 45 52 55 63 101 107 116 119 120 124 137139 143 pi(x) 65 pingpong 42 pitch 107 PL(n) 18 place 139 166 178 180 placing 68 84 90 planar partition 18 plane 52 109 III 114 143 platinum 137 player 42 6769 7274 84 87 88 90 92 94 plotter 123 fig6a fig6b 149 177 Plumer. Georgie 125 polygon 2 20 180 polygonal 17. 139 .7 polyiamond 112 fia5 polynomial {x 2 } 5 12 14 15 101. Joe 58 quadrant 18 158 177 quadratic 3 143 quadrillion 30 quadrisecting 115 Quarterly Journal of Pure and Applied Math. 121 127 178 po1yomino 77'1 108110 112 pos i tion 22 168 76 93 95 96 10 3' 11 5 1 70 positive 34 98 133 137 153 170 173 174 possible 68 72 130 132 power 12 14 32 37 38 43 47 53 57 63 101 118 120 121 125 127 129 130 149 154 159 167 181 power.order 12 14 15 50 51 77 81 94 108 112 117 169 181 ordered pairs 12 151 ordering. decimal 170 probability 29 37 42 5254 57 107 probable.
minimal 62 sequence 14 38 39 115 176 177 179 series 12 47 115125 129 130 139 158 set 3 17 35 4S 48 52 84 105 107 115 132 137 ISO 170 172 SETQ 163 Shanks. negative. octal. John 90 Schutzenberger. Marco 39 Scientific American 49 79 80 85 fig4 112 Scientific American Book of Puzzles 80 fig3a score 42 67 72 Scott. map into 132 selfreferent list 132 semiaroups 82 semiquadrant 177 sentinel 160 separating 151 separation. ternary. Daniel 65 shape 20 48 III 112 115 shift 25 132 167 181 short program 101 145 show 42 72 107 110 112 shrink 20 101 123 135 .quartic equation 4 9 quaternary 37 quaternion 107 queens 87 question 57 114 quintic equation 10 quotient 99 171 radius 83 125 150 153 radix {binary. complex} 33 37 43 55 figla figlb fig2 63 101 115 122 128 fig7 154 Ramanujan 31 139 random number generator 25 132 random number 2527 29 32 37 52 54 57 random variable 40 random vector 27 range 40 83 101 133 158 rangereduced 143 158 rapidly 14 122 raster 21 rate 14 143 Rathbone 140 ratio 38 80 101 159 rational function 12 101 125 rational number 38 45 54 101 130 Rayfield. Steve 61 169 ROT 104 rotate 11 103 107 123 135 153 166 rotation 81 107 146 roundoff 3 101 173 181 row 50 78 90 91 112 115 120 121 179 rule 12 42 67 84 102 ruler function 132 salvaged 45 Samson. quarternary. Malcolm 135 renormalize 181 reactionary 101 readonly 154 real number 3 32 45 105 115 137 138 143 178 recant 101 reciprocal 101 120 recognize 101 rectangle 68 80 fig3b 86 110 112 recurrence 1216 44 151 158 recursive 158 170 rediscovered 64 redouble 45 reduce 101 references 48 49 56 70 77 79 80 85 86 100 105 112 113 120 125 136 139 140 143 reflection 1 81 region 2 20 24 register 25 149 regular 101 Rektorys 12 related 45 63 145 relation 13 14 121 relatively prime 48 52 relevant 173 remarkable 151 remove digits 33 repeated 12 67 131 132 143 167 repeating pattern 114 replace 127 133 134 169 177 representation 107 representing 20 reqUired 37 113 restored 158 reverse bits 167 reverse paths 103 Riemann surface 143 right angle 137 rightmost dieit 14 33 rigid rotation 107 roll 72 107 rook 78 root 3 5 8 9 12 14 34 57 77 101 126 127 143 149 151 158 Root. decimal. hexadecimal. Peter fig3h 164 satisfying 9 45 115 129 178 scalar 12 107 scale {stretch} Scarne. Dana 133 search 31 61 176 177 179 seems 47 68 segment 39 177 180 self.
magic SO 147 square. 12 susceptibility 25 suspicious 32 122 Sussman.side 20 49 68 76 78 80 fia3b 86 94 95 110 112 114 137 177 sigma 116 118 120 123 124 sign 154 160 168 173 177 181 sianmagnitude 154 signals 145 Silver. Richard 166 standard form 101 starting 76 state 25 46 115 148 Stegun 120 143 step 135 step function 83 step (walk) 45 step (number required) 12 14 stereo 145 stereographically 11 stop 1 19 stopped 57 store 132 172 straight 38 strategy 67 72 73 154 stretch '11 52 135 127 string 18 37 39 122 128 fig7 154 170 176 177 179 String fig3b subcycles 47 subproblem 39 subexpression 101 subgroup 107 subroutine 101 substitute 101 122 substring 179 subtract 64 101 155 158 succesive appoximations 101 successor 68 suit 46 sum 29 43 SO 60 61 72 76 121124 fia6a fig6b 154 180 superfast 142 143 superimposing 20 135 surface 143 Survey of Applicable Math. Michael 18 62 160 speed 123 158 speed of light 101 sphere 11 27 107 sporadic 122 square (rectangle) 48 68 69 80 fig3a fig3b 85 fig4 86 90 112 115 square root 9 34 97 101 126 137 143 152 158 159 sqrt (2) 32 sqrt(3) 116 square (exponent) 5 6 12 14 31 36 45 47 59 63 80 119 124 127 144 169 square. munching 146 148 square waves 168 squashed 180 stability 150 151 stable'149 152 stalemate 73 Stallman. David 135 Silver. lalt 101 terminate 101 termination 181 ternary 36 37 tessellatina 109 tesseract 51 test 47 158 159 177 text 176 . Rollo 25 Sim 73 similar 51 6897 similarity 127 simple 18 97 115 146 simplify 177 simultaneous 68 144 lSI sine 10 26 101 107 129 142 149 151 158 159 single 153 sinh 158 size 29 149 skip 83 162 179 sliding block puzzle 79 slope 38 small 80 101 106 158 small~r 62 158 smallest 48 68 80 fig3a smidgen 45 181 snowflake curve 135 solid 153 solitaire 76 solution 810 21 27 31 35 49 71 112 fia5 127 136 137 solve 10 21 68 71 78 79 84 9096 143 144 Soma 112 somalike 77 112 space 11 19 27 77 107 123 158 spacecraft 107 spacefilling curve 66 115 122 135 spacewar 114 special 64 137 181 Speciner. Gera14 163 swap 103 161 162 sweep 123 switch 132 146 148 168 symbolic functions 101 symmetric function 57 symmetry fil1b 101 synthesize 17 19 system 107 154 table 115 132 165 tabulated 72 Tactix 74 takeaway laaes 68 tanlent 16 107 142 158 177 tanh 101 158 Taylor seriel 158 TechnololY Review 56 Teco 176 Teeko 90 term 14 34 101 120 122 123 129 139 140 159 term.
checkers} 70 84 88 89 Whittaker 12 143 win 42 6769 7275 84 87 89 90 92 94 windowdice 72 wobble 153 wonder.ons '101 fig1a figlb fi&2 transcendental 101 102 130 136 unit {sphere. Pascal's value 13 17 25 29 SO 121 trick 101 99 107 122 132 trillion 29 30 147 177 trinomial variable 6 7 1720 coefficient 116 40 156 163 triple 14 88 158 variance 40 truncation error 101 variations 112 123 145 181 vector 12 13 27 107 twice 39 50 86 123 158 180 twin primes 30 velocity 149 Venn diagram 20 24 verboten 88 verified 77 107 112 verify 28 85 vertex 180 views 147 visible 48 visual information 180 volume 107 Waltz.. transform 12 158 square} 27 32 83 transformation 120 124 107 114 115 123 translate 11 107 127 universal 64 168 universe 154 trap 154 unknown 101 trapezoid 112 unnormalized 181 TReE.> two {2} S2 57 61 62 theorem 29 38 48 85 68 72 73 84 89 90 106 162 163 172 177 theory 68 77 Theory of Numbers 180 181 two counter 64 136 twodimensional 18 thermodynamic 46 three {3} 60 70 166 twomember 61 62 twoscomplement 154 Thue 122 181 tictactoe 91 92 112 typeout 170 Tiger Puzzle 79 typical 77 time 28 65 68 93 123 typo 10 101 144 147 160 178 unclear 123 150 toptested 177 underflow 160 toroidal space 101 unequal 46 52 80 181 unfeasible 93 114 total 25 72 . circle. Dave 21 Watson 143 waves 168 white {chess. division by 3 171 zeroless 57 zeta function 53 119 124 178 . cell. 136 Wright. Jackson 146 x 2 _2 127 x 2 x1 12 XOR 17 23 ~5 68 115 147 Yao.ranc es 64 yaw 107 year 93 zero digit 18 36 57 122 132 170 181 zero element 13 47 107 zero loop 133 zero of polynomial 5 zero (number) 32 35 45 64 101 143 zero. F. E. great 149 word (computer) 25 157 165 169 Wright. number 101 122 interval. 162 unproven 92 unstable 3 tree search 75 triangle 73 75 85 upward 19 useful 151 176 1·12 valid 113 143 triangle. uniform 26 27 32 uniformly 32 40 107 tracing 123 union 52 101 trailing 132 unique 13 49 55 transcendent'al functi. M. transfer {jump} 179 quaternion.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.