palindrome pictures

7
Compur. & Graphics, Vol. 20, No. 4, pp. 597603, 1996 Copyright 0 1996 ElsevierScienceLtd Printed in Great Britain. All rights reserved 0097-8493/96 515.00-k0.00 PII: s0097-&493(96)ooo3cr1 Chaos & Graphics PALINDROME PICTURES RYAN RICHARDSON and CHRISTINE SHANNON+ Computer Science Program, Centre College, Danville, KY 40422, U.S.A. Abstract-Given an integer N, let N’ be the integer obtained by writing thedigits of N in reverse order. If N=N’, we callit a palindrome of order 0 and if it does not,we continue the process of adding theresulting number to itsreverse until either it becomes a palindrome or thenumber of steps exceeds an upper bound. In thefirstcase, the number of steps determines the order of the palindrome and in thesecond theorder is said to be infinite. Colored grids are used to lookfor patterns in these orders. Copyright 0 1996 Elsevier Science Ltd Over 25 y ago, Charles Trigg [l, 21 published several papers on numberpalindromes that wereobtained by what he called “reversal addition”. Given an integer No, let Nb be the integer obtained by writing the digits of No in reverse order. If No= Nb, then we will call No a palindrome (of order 0). Otherwise, for k>O, we let Nk+l = Nk + NI and if Nk+, is the first palindrome in the sequence {No, N,, Nz, . . . , Nk+1) then No is a palindrome of order k+ 1. If the sequence appearsto go on forever (determinedby continuing beyond some arbitrary point, like 500 iterations), we label it a palindrome of (apparently) infinite order. For example, if NO=4752, then No’=2574 and N,=4752+2574=7326, N,=7326+ 6237 = 13,563 and Ns= 13,563 + 36,531=50,094, N4 = 50,094+49,005 = 99,099, and thus 4752 is a palindrome of order 4. On the other hand, 196 is the first counting number which appears to have infinite order. It was onceconjecturedthat eachpositive integer, when subjected to this reversal addition process, would eventually resultin a palindrome. However, in the intervening years, no one has provided such a proof and indeed, Heiko Harborth proved that the conjecture is falsein bases which are a powerof 2 [3]. With the tremendous increase in computing speeds, it is now easy to execute hundreds of thousandsof operations in the search for palindromesbut the intriguing fact remains that numbers either become palindromes after a fairly small number of steps or the search appears to continue forever. As part of a college-funded, faculty-student collaborative re- searchproject last summer we undertook a careful study of integers<lo’. At first, when dealing with smaller integers, we tested up to 500 iterations, but as Table 1 shows, we neverfound a numberwhich took longer than 98 iterations to become a palindrome. We even tested some for hundredsof thousands of iterations without success. t Author for correspondence. Unable to prove or disprove the conjecture, we were nevertheless struck by all the patterns we observed and, hoping to discern evenmore of them, we decided to employ graphics to plot colors representing the orders of large blocks of integers. (See ref. [4] for another way to depict the patterns in the ordersof palindromes.) Assume you havethe following data structures and functions: colortable-an array indexed from 0 to MAX, whereMAX is an integerlarge enoughso that no order larger than MAX would appear in the calculations. In our work, MAX was 100. For each I, colortabk$j is a distinct color. Different colortables provide different colorization of the patterns. order(n:integer):iger-A function which returns a number in the range 0 . . MAX. If n is a palindrome of order k, then order(n)= k. If n appears to have infinite order, then order(n)= MAX. grid-A 2-D array having SIZE rows and SIZE columns. offset-An integer which allows you to start computing ordersat an arbitrary point. Table 1. Maximum finite order found among integers of the given size Number of digits Maximum order 1 0 2 24 3 23 4 21 5 55 6 64 7 96 8 96 9 98 To save time we eventually tested for only 200 iterations, but in the thousands of larger trials, an integer of larger order was never identified. 597

Upload: ryan-richardson

Post on 31-Aug-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Palindrome pictures

Compur. & Graphics, Vol. 20, No. 4, pp. 597603, 1996 Copyright 0 1996 Elsevier Science Ltd

Printed in Great Britain. All rights reserved 0097-8493/96 515.00-k 0.00

PII: s0097-&493(96)ooo3cr1 Chaos & Graphics

PALINDROME PICTURES

RYAN RICHARDSON and CHRISTINE SHANNON+

Computer Science Program, Centre College, Danville, KY 40422, U.S.A.

Abstract-Given an integer N, let N’ be the integer obtained by writing the digits of N in reverse order. If N=N’, we call it a palindrome of order 0 and if it does not, we continue the process of adding the resulting number to its reverse until either it becomes a palindrome or the number of steps exceeds an upper bound. In the first case, the number of steps determines the order of the palindrome and in the second the order is said to be infinite. Colored grids are used to look for patterns in these orders. Copyright 0 1996 Elsevier Science Ltd

Over 25 y ago, Charles Trigg [l, 21 published several papers on number palindromes that were obtained by what he called “reversal addition”. Given an integer No, let Nb be the integer obtained by writing the digits of No in reverse order. If No = Nb, then we will call No a palindrome (of order 0). Otherwise, for k>O, we let Nk+l = Nk + NI and if Nk+, is the first palindrome in the sequence {No, N,, Nz, . . . , Nk+ 1) then No is a palindrome of order k+ 1. If the sequence appears to go on forever (determined by continuing beyond some arbitrary point, like 500 iterations), we label it a palindrome of (apparently) infinite order. For example, if NO= 4752, then No’=2574 and N,=4752+2574=7326, N,=7326+ 6237 = 13,563 and Ns = 13,563 + 36,531= 50,094, N4 = 50,094+ 49,005 = 99,099, and thus 4752 is a palindrome of order 4. On the other hand, 196 is the first counting number which appears to have infinite order.

It was once conjectured that each positive integer, when subjected to this reversal addition process, would eventually result in a palindrome. However, in the intervening years, no one has provided such a proof and indeed, Heiko Harborth proved that the conjecture is false in bases which are a power of 2 [3]. With the tremendous increase in computing speeds, it is now easy to execute hundreds of thousands of operations in the search for palindromes but the intriguing fact remains that numbers either become palindromes after a fairly small number of steps or the search appears to continue forever. As part of a college-funded, faculty-student collaborative re- search project last summer we undertook a careful study of integers <lo’. At first, when dealing with smaller integers, we tested up to 500 iterations, but as Table 1 shows, we never found a number which took longer than 98 iterations to become a palindrome. We even tested some for hundreds of thousands of iterations without success.

t Author for correspondence.

Unable to prove or disprove the conjecture, we were nevertheless struck by all the patterns we observed and, hoping to discern even more of them, we decided to employ graphics to plot colors representing the orders of large blocks of integers. (See ref. [4] for another way to depict the patterns in the orders of palindromes.)

Assume you have the following data structures and functions:

colortable-an array indexed from 0 to MAX, where MAX is an integer large enough so that no order larger than MAX would appear in the calculations. In our work, MAX was 100. For each I, colortabk$j is a distinct color. Different colortables provide different colorization of the patterns. order(n:integer):iger-A function which returns a number in the range 0 . . MAX. If n is a palindrome of order k, then order(n)= k. If n appears to have infinite order, then order(n)= MAX. grid-A 2-D array having SIZE rows and SIZE columns. offset-An integer which allows you to start computing orders at an arbitrary point.

Table 1. Maximum finite order found among integers of the given size

Number of digits Maximum order

1 0 2 24 3 23 4 21 5 55 6 64 7 96 8 96 9 98

To save time we eventually tested for only 200 iterations, but in the thousands of larger trials, an integer of larger order was never identified.

597

Page 2: Palindrome pictures

598 R. Richardson and C. Shannon

The basic algorithm is thus:

for i:=O to SIZE-l do fori:=O to SIZE-l do

begin k: = order(SIZE*i +j + offset); grid[i, ~1: = colortable[k]; end;

display&rid)

Figures l-4 display the results for various values of offset and SIZE. Each of these was produced on a Hewlett Packard X terminal using GKS graphics.

To allow examination of the intricate patterns, we provided a very simple utility for “zooming in” on a quadrant of the grid. For example, Fig. 5 is the result of “zooming in” on the upper-right quadrant of Fig. 1; Figs 6-8 display enlarged portions of the others. The process can be repeated as often as desired so that Fig. 9 is the upper-right quadrant of Fig. 5 and hence a 2-fold enlargement of the upper comer of Fig. 1.

The generality of our software allows us to produce an infinite number of different pictures. For the most part, the eye can discern more

patterns in pictures having a greater number ot pixels. However, as we “zoom in” to the more chaotic sections of the picture, it is amazing how many patterns we can discover. While most of our work concentrated on efficient storage and algo- rithms for calculating the function order, the addition of graphics brought an added dimension which we have barely tapped. One insight that resulted from the use of graphics was the sig- nificance of the number of digits. Pictures which span a set of integers containing different numbers of digits have clear breaks in the pattern when the number of digits changes. Figure 10 plots the numbers from 1 to 250,000 in a 500 x 500 block. The l-, 2- and 3-digit numbers are plotted at the bottom in the first two rows. The next 18 rows contain the 4-digit numbers and are followed by the 5-digit numbers which end just below the middle of the slide. Much better symmetry and the disappearance of diagonal “drift” result when the number of digits remains constant and the width of the block is chosen appropriately.

Palindrome reversal is a very intriguing problem, accentuated by the appearance of the countless patterns exposed in the graphical displays.

Fig. 1. Offset= 10,000,001; size= 1000,

Page 3: Palindrome pictures

Fig. 2. Offset = 200,001; size = 500.

Fig. 3. Offset = 50,000,OOl; size = 1000.

Page 4: Palindrome pictures

Fig. 4. Offset = 100,001; size= 500.

Fig. 5. Upper-right quadrant of Fig. 1

Page 5: Palindrome pictures

Fig. 6. Lower-left quadrant of Fig. 2.

Fig. 7. Upper-left quadrant of Fig. 3.

Page 6: Palindrome pictures

Fig. 8. Upper-left quadrant of Fig. 4.

Fig. 9. Upper-right quadrant of Fig. 5.

Page 7: Palindrome pictures

Palindrome pictures 603

Fig. 10. Offset = 1; size= 500.

REFERENCES 1. C. W. Trigg, Palindromes by addition. Muthemutical

Muguzine 40,26-28 (1967). 2. C. W. Trigg, More on palindromes by reversal-addition.

Mathematical Magazine 45, 184-186 (1972).

3. H. Harbor& On palindromes. Mathematical Magazine 46, 96-99 (1973).

4. C. A. Pickover, Computers and the Imagination, Chap. 44, St Martin’s Press, New York (1991).