4
PROBLEMSECTION AMTHOR'S SOLUTION OF ARCHIMEDES' CATTLE PROBLEM* RUdiger Loos Visiting Professor, University of California, Berkeley On leave from the Universit~t Kaiserslautern I. INTRODUCTION Archimedes' problem for his colleagues in Alexandria, as stated in this Bulletin [l], amounts to solving the system (I)-(9) for positive integers W, X, Y, Z and w, x, y, z. (l) (2) (3) (4) (5) (6) (7) W = (l/2+I/3)X + Y , X = (I/4+I/5)Z + Y , Z = (I/6+I/7)W + Y , w = (I/3 + I/4)(X +x) , x = (]/4+ 1/5)(Z + z) , z : (115 + I/6)(Y +y) , y = (I/6+I/7)(W+w) and (8) (9) W+X = a square Y + Z = a triangular number . In 1880 the problem was completely solved by A (Amthor [2]). He broke the problem into manageable parts. We checked his extensive hand calculations with MACSYMA, and except for the long floating point test, SAC-2; the computer calculations verify all hand calculated results as stated by Amthor. This settles the question among competitive hand calculations giving different results in his favor. We give a resume of his solution and state the algorithms involved. 2. THE REDUCTION OF THE PROBLEM For any positive integer n the linear Diophan- tine system (I)-(7) has the solutions (10) W = 2.3.7-53-4657n , X = 2-32-89.4657n , y = 34.11.4657n Z = 22.5.79.4657n , w = 23.3-5.7-23.373n , x = 2-32.17.15991n , y = 32.13.46489n z = 22-3-5.7.11.761n . This research has been supported in part by National Science Foundation Grant MCS74-13278-AOI. In order to satisfy (8) set W+X = q2 = Q.n with Q = 22-3.11-29.4657. Let Qf be the squarefree part and Qs be the square part of 0 : Qs'Qf. Since q2 is a square, n m~s~ be ofthe form Qf.t ~ and consequently q~ = QsN~t z. In (I0) n becomes (II) n = 3.11,29-4657t 2 which satisfies now (I)-(8). In order to finally satisfy (9) set ~+Z = nT = v(v+l)/2 for positive v. With n = Qft one gets v(v+l)/2 : nT = Qft2T and after multiplication by (8) (12) u2-Dt 2 = l , with T - 7-353.4657, ~ = 2v+l, D = 8QfT = 23.3.7.11.29.353.4657 ~. Equation (12) is the Pell equation, which always has the trivial solution t = ~, u = ±l, which is excluded here. That u has to be odd in our case is no restriction since D is even and also Dt 2. Before we follow Author's solution we would like to consider the Pell equation from a constructive point of view related to well known algorithms and problems for algebraic systems. 3. THE PELL EQUATION Trivially, one may consider (12) as an instance of the extended Euclidean algorithm for l and -D. Since u 2 and t 2 have the same prime fac- tors as u and t, all solutions must be relatively prime. Further, a solution of (12) satisfies u2 ~ l mod D which says that l is a quadratic residue of D. Since such u always exist, u2 = l+sD, reduc- ing the Rroblem to the question whether s can be a square t ~. To settle this question let us rewrite (12), t = 0 being excluded, as For sufficiently large t this can be viewed as an approximation of the "radical" ruby the rational number (u/t), i.e. as an approximate solution of

Amthor's solution of Archimedes' cattle problem

Embed Size (px)

Citation preview

Page 1: Amthor's solution of Archimedes' cattle problem

PROBLEM SECTION

AMTHOR'S SOLUTION OF ARCHIMEDES' CATTLE PROBLEM*

RUdiger Loos

V is i t i ng Professor, Universi ty of Cal i fo rn ia , Berkeley On leave from the Universi t~t Kaiserslautern

I . INTRODUCTION

Archimedes' problem for his colleagues in Alexandria, as stated in th is Bu l le t in [ l ] , amounts to solving the system ( I ) - (9 ) for posi t ive integers W, X, Y, Z and w, x, y, z.

(l) (2) (3) (4) (5) (6) (7)

W = ( l / 2 + I / 3 ) X + Y ,

X = ( I / 4 + I / 5 ) Z + Y ,

Z = ( I /6+ I /7 )W + Y ,

w = ( I /3 + I /4)(X +x) ,

x = ( ] / 4 + 1/5)(Z + z) ,

z : (115 + I / 6 ) ( Y +y ) ,

y = ( I / 6 + I / 7 ) ( W + w )

and

(8) (9)

W+X = a square

Y + Z = a t r iangu lar number .

In 1880 the problem was completely solved by A (Amthor [2 ] ) . He broke the problem into manageable parts. We checked his extensive hand calculat ions with MACSYMA, and except for the long f loa t ing point test , SAC-2; the computer calculat ions ve r i f y a l l hand calculated results as stated by Amthor. This sett les the question among competitive hand calculat ions giv ing d i f fe ren t results in his favor. We give a resume of his solut ion and state the algorithms involved.

2. THE REDUCTION OF THE PROBLEM

For any posi t ive integer n the l inear Diophan- t ine system ( I ) - (7 ) has the solutions

(10)

W = 2.3.7-53-4657n ,

X = 2-32-89.4657n ,

y = 34.11.4657n

Z = 22.5.79.4657n ,

w = 23.3-5.7-23.373n ,

x = 2-32.17.15991n ,

y = 32.13.46489n

z = 22-3-5.7.11.761n .

This research has been supported in part by National Science Foundation Grant MCS74-13278-AOI.

In order to sat is fy (8) set W+X = q2 = Q.n with Q = 22-3.11-29.4657. Let Qf be the squarefree part and Qs be the square par t of 0 : Qs'Qf. Since q2 is a square, n m~s~ be o f t h e form Q f . t ~ and consequent ly q~ = QsN~t z. In ( I0 ) n becomes

( I I ) n = 3.11,29-4657t 2

which sat is f ies now ( I ) - ( 8 ) . In order to f i n a l l y sat is fy (9) set ~+Z = nT = v(v+ l ) /2 for posi t ive v. With n = Qft one gets

v(v+ l ) /2 : nT = Qft2T

and af ter mu l t ip l i ca t ion by (8)

(12) u 2 -D t 2 = l ,

with T - 7-353.4657, ~ = 2 v + l , D = 8QfT = 23.3.7.11.29.353.4657 ~.

Equation (12) is the Pell equation, which always has the t r i v i a l solut ion t = ~, u = ± l , which is excluded here. That u has to be odd in our case is no res t r i c t i on since D is even and also Dt 2. Before we fol low Author's solut ion we would l i ke to consider the Pell equation from a constructive point of view related to well known algorithms and problems for algebraic systems.

3. THE PELL EQUATION

T r i v i a l l y , one may consider (12) as an instance of the extended Euclidean algorithm for l and -D. Since u 2 and t 2 have the same prime fac- tors as u and t , a l l solutions must be re l a t i ve l y prime.

Further, a solut ion of (12) sa t is f ies u 2 ~ l mod D which says that l is a quadratic residue of D. Since such u always ex is t , u 2 = l +sD , reduc- ing the Rroblem to the question whether s can be a square t ~.

To set t le th is question le t us rewrite (12), t = 0 being excluded, as

For s u f f i c i e n t l y large t th is can be viewed as an approximation of the "radical" r u b y the rat ional number ( u / t ) , i .e . as an approximate solut ion of

Page 2: Amthor's solution of Archimedes' cattle problem

x 2-D = O. Lagrange isolates a real root by an interval of length l with integer endpoints. A simple search gives a 0 = Ix ] , and b 0 = a n + l , thereby ref ining the star t interval [ 0 , ~ to [ao,bo). For further refinement he transforms the interval [ao,bo) into [0,~) again, sending a 0 to and b 0 to O, with the transformation

l x = x 0 = a 0 + ~ I

and searches fo r a I = LXlJ now. The a t t r a c t i v e po in t f o r an a lgebra ic system is the observat ion tha t a l l ref inements can be done by using a 0 instead o f v~, working there fo re on ly w i t h i n t e - gers. Let us consider a n o n - t r i v i a l example, say D = 31 w i th a 0 = Lv~] = 5 and b 0 = 6. The ca l cu la - t i o n proceeds as f o l l ows :

v ~ i - : 5 + ( v ~ T - 5) : 5 + - - ~ T + 5

v~T+5 - 1 + v ~ i - - I _ 1 ÷ _ _ _ 5 _ _ ,

6 6 v~i-+ l

v~T+l v~T-4 3 - - - I + - I + - - 5 5 v~i-+

v~T+4 - 3 + v ~ - - 5 _ 3 ÷ _ _ _ 2 - ,

3 3 v~T+5

v~T+5 v'3T- 5 3 - T - 5 + 2 - 5 ÷ - - ,

v~T+5

v~T+5 / 3 T - 4 5 - - - 3 + - 3 + - -

4

3 3 v~i-+ 4 '

3 ~ + 4 - I + v'~"-1 - 1 ÷----6--- 5 5 v~T+I '

v~'T + l ,73T- 5 I - - - I + - - - 1 ÷ ~

6 6 v~i-+ 5

6

~ i -+5 v~T+5 = 10+(3~-5) = l O + - -

The sequence repeats i t s e l f from here i n f i n i t e l y . The calculation can be described by

(14) x 0 = v~ = a 0 +-]- Xn '

v~+P x _ n_ a + 1 n Qn n Xn+ l '

where a n = ~(l~. +Pn)/Qn] ~ L(ao+Pn)/QnJ = Lxn] and PO = O, QO . Table l summarizes the periods and in the periods symmetric sequences {a i } , {Qi } and {Pi } of the example.

Table 1

{a i } , {Qi} and {Pi} of

i 0 l 2 3 4 5 6 7 8

a. 5 1 l 3 5 3 1 l lO 1

Qi 1 6 5 3 2 3 5 6 1

Pi 0 5 l 4 5 5 4 l 5

From (14) one finds by back substitution

(15)

where

÷ AnX n An_ l

X 0 - BnXn+Bn_ l '

(16) A-l = l ' A O=a O, A n=An_la n+An_ 2 n > 2 .

B_l=O, B O=l , B n=Bn_la n+Bn_ 2 ,

The connection of Lagrange's real square root iso- lat ion algorithm, sometimes called continued frac- t ion expansion, with the Pell equation becomes sim- ple now. Substitution of (14) into (15) gives . xo = ,/~ = (An(v~+Pn)+An-IQn)/IBn-l(V~+Pn)+BnQn) which sp l i t s immediately into an i r ra t ional part An_ l = Bn_iPn+Bn_2Qn and a rational part DBn-I = An_iPn+An_2Qn . The difference of the i r ra t iona l part mult ipl ied by An_ l and the rational part mul- t i p l i ed by Bn_ l y ields

(17) AR-I - DBn2-1 = (An-IBn-2-AR-2Bn-I)QR

The expression in parenthesis can be simpl i f ied i f one eliminates a n from (16): AnBn_ l -An_IB n = - (An-l.Bn-2-An- 2Bn-l ) . . . . (-l)n(AOB_l -A-l BO) =

n+l ( - l ) . Therefore (17) is s impl i f ied to

(18) A 2 -DB~ 1 = (-l)nOn n-I - • "

From Table l we conclude 00 = 08 = Ql6 . . . . . l , hence

A 2 2 = l m = O,l ,2 . . . . 8.m-I - DBo.m_l

and one computes from (16) for m = l for example A 7 = 1520 and B 7 = 273. Our observations do not hold accidentally. Let k denote the period length, in the example 8, then

u = I , t = , k even (19) Amk-' Bmk-l m = 0, I ,2 . . . .

u = A2m~-l'K t = B2m~-'K l ' k odd

give a l l solutions of the Pell equation. In gen- eral , every continued fract ion of the square root of a rational number D > l has the f i n i t e periodic form

/D= [ao;al,a 2 . . . . . a2,al,2a O]

and has the symmetries

= a n = l , k - l an k-l ' " " ' Qn = Ok-n ' n = 0 . . . . . k ,

= Pk-n Pn , n = 0 . . . . . k-l .

Moreover, no two adjacent Pi or Qi are equal, except Pi = Pi+l for an even period k = 2i , and Qi = Qi+l for an odd period k = 2i + I . The symme- t ry cuts the computation cost by a factor of 2.

We col lect our considerations in the following two algorithms given in extended ALDES, hopefully explaining i t s e l f .

Page 3: Amthor's solution of Archimedes' cattle problem

L ÷ CF2(D)

[Continued fraction expansion of a square root. D > I is an integer. L =[aO;al,...,ak_l,2aO], a l i s t of integers, k is the period length, which is 0 for a perfect square D.]

a,D,P,Q,r E Z. [The def ini t ion of the algebra allows for polymorphic operators.]

( 1 ) [ I n i t i a l i ze ] r÷ L÷

FLOOR(D**( I /2 ) ) ; P÷r; Q~I; (2*r); L ' ÷ ( ) . [two symmetric

halves]

(2)[Expand] repeat

unti l

Q'÷Q; Q÷(D-P**2)/Q; a÷(r+P)/Q; P'÷P; Pc-a'Q-P; a on L; a on L' Q=Q, vp=p, .

(3)[Combine symmetric parts] i f P=P' then [period odd] a from L'; L ÷ r on CONC(INV(L'),L); return []

t(CF2,D) < v~.

PELL(D;A,B)

[Pell equation. D is a positive integer, not a perfect square. A, B are the smallest positive integral solutions of A2-DB 2 = I . ]

a,A,Ao,B,B 0 E Z.

(1)[L= (ao;al,a 2 . . . . . a2,al,2ao)] L÷CF2(D).

(2)[Recurrence A.=anAn l+An_2, Bn: anBn_l+Bn_2 until Yi

A O~l; A from L; Bn ÷ l ; B÷ l ; while RED(L)~() ~o

{a from L; M÷A; A÷a*A+Ao; ~÷M; M÷B; B÷a*B+Bo; ÷M}; return D

This algorithm seems to be a classical instance where exact integer arithmetic is mandatory. The output tends to be large and i t does not make much sense to solve a Diophantine problem by floating point numbers.

3. AMTHOR'S SOLUTION

The given algorithm solves the problem com- pletely-- in principle. Remembera al l that was le f t to compute was n = 3.11-29.4657t ~ with t such t h a t

u 2-23"3-7"II-29-353.46572t2 = l

Amthor sets D' = 2-3.7.11.29.353, A = u, B = 2-4657t and solves the f i r s t

A 2- D'B 2 = 1 .

The continued fraction expansion unt i l the middle element (~) is D~= [2174;1,2,1,5,2,25,3,1,I,I,I, l 1,15,1,2,16,1,2,1,I ,8,6,1,21,I, I ,3,1,I , I ,2,2,6,1, 1,5,1,17,1,I,47,3,1,I,(~) . . . . . 4348] and has a period of 91. Amthor computes by hand

A = I09931986732829734979866232821433543901088049

B = 50549485234315033074477819735540408986340

(20)

as smallest positive solutions. All other positive solutions An, B n can be computed, alternatively to (19), by

A n+Bn/D= (A+Bv~) n

Since a solution of the original Pell equation exists i t remains to find an n such that 2.46571B n. He uses the recurrence relations

(21) Am+ n = + B B D AmAn m n

Bm+ n = AmB n + AnB m

which show that a l l B n w i l l be even i f B is. Hence i t suffices to compute n such that B n z 0 mod M with M = 4657. Instead of computing B2,B 3 . . . . modM he proves the interesting theorem that only such B o z 0 mod M, M a prime, for which pI(M+l) i f (D/M) = - l or pl(M-l) i f (D/M) = +l holds. Now, (D/M) : - l , M+l = 4658 = 2.17.137 and the only Bo's to be checked have an index p = 2, 17, 34, 137, 274, 2329 or 4658. I t turns out that B2329 z Omod4657. Therefore, i f I r denotes the irrat ional part,

(22) t = Ir(A + Bye) 232g ,

A and B taken from (20). Instead of using this ingenious method we applied (21) i te ra t ive ly :

TEST.

A,B,D,M EZ; u ,u ' , u " , t , t ' EZ(M).

(1 ) [ I n i t i a l i ze search for B n z Omod M] BEGIN2; PELL(2*3*7*ll*29*353;A,B); M~4657; u ÷ l ; u ÷ A mod M; t ÷ B mod M; d ÷ D mod M; u '÷u; t ' ÷ t .

(2)[Apply recurrence (21)] while t ' #O do

{u÷ u+l ; u"÷u' ; u ' ÷ ( u * u ' + t ' * t * d ) mod M; t ' ÷ (u* t '+ u"*t) mod M};

WRITE("A =",A,"B =",B,"n =",n) []

and veri f ied A, B in (20) and n = 2329. To use (1) and (2) in the above algorithm without mod M ar i th- metic is as wasteful as using the PELL algorithm direct ly. Amthor uses logarithms

loglot = log(A+ Bye) 2329 = 2329.44.3421541

= I03272.8769

and gives log t 2 = 2~6530.5388 and W = 1598.10206541

The last four lineswere veri f ied only by R. Fateman's impressive Big-Floating-Point Arith- metic [3] in MACSYMA. Since the precision can be programmed, (22) can be computed to any desired accuracy. However, " i t does not make sense to

l enerate a number as large as a phone book" D.H. Lehmer).

6

Page 4: Amthor's solution of Archimedes' cattle problem

4. HISTORICAL REMARKS

Fermat knew that Pe l l ' s equation has i n f i n i t e - ly many solut ions. As usual, he did not publish his proof. The theorem on which the continued f rac t ion expansion algorithm is based is known as the Euler-Lagrange Theorem. The time saving te r - mination c r i t e r i on is due to Muir. A comprehen- sive treatment is given in O. Perron, "Die Lehre von den Kettenbr~chen," Leipzig, 1913. The Pell equation is t reated, unfortunately, in a non- construct ive manner, for example in W. Adams and L. Goldstein, Introduct ion to the Theory o.f_ Numbers, Englewood C l i f f s , N.J., 1976, containing many programming exercises. The solut ions of the Pell equation are units in the real quadratic extension f i e l d ~(v'D). I t is therefore reasonable to require D to be squarefree, the case used by Amthor. This context is treated in depth by H. Hasse, "Vorlesungen Uber Zahlentheorie," Ber l in , 1950_~where we took the example for the expansion of /31. Algorithms to solve l inear Diophantine equations can be found in Knuth's The Art of Computer Programming, Ch. 4, or in the Col lect ion o_f_Algorithms of the ACM. There is no analysis known to me. Before Amthor, Gauss is believed to have solved Archimedes' problem completely. For the phi lo logica l questions--which arose par t ly because of the incredib ly large numbers--see L. Dickson, History of the Theory of Numbers, Vol. I I , New York, Chelsea, 1952. I was not aware of Amthor's paper when I submitted the problem to the Bu l le t in .

ACKNOWLEDGMENTS

I thank R. Fateman for his MACSYMA and E. and M. Lauer for algorithms in ALDES in Madison.

assistance with programming the

REFERENCES

[ I ] Problem Section, "The Catt le Problem of Archimedes," SIGSAM Bu l le t in of the ACM, New York, Vol. 9, Aug. 1975.

[2] "Das Prolema bovinum des Archimedes," B. Krumbiegel und A. Amthor, Histor isch- l i t e ra r i sche Abtei lung, Ze i t s ch r i f t fur Physik und Mathematik, XXV, 1880, 153-171.

[3] R. Fateman, "The MACSYMA 'B ig-F loat ing-Point ' Ar i thmetic System," Proceedings of 1976 ACM Symposium on Symbolic and Algebraic Computa- t ion, Aug. 10-12, 1976, Yorktown Heights, N.Y., ed. R. Jenks, 209-213.

ABSTRACTS (Cont. from page S)

necessary to abtain a canonical form for functions obtained by integration and exponentiation from the set of rational functions. These aspects include a new algorithm for symbolic integration of functions involving logarithms and exponentials which avoids factorization of polynomials in those cases where algebraic extension of the constant field is not re- quired, avoids partial fraction decompositions, and only s].oves linear systems with a small number of unknowns. We also found a theorem which states, roughly speaking, that if the integrals which can be represented as logarithms are presented as such, the only algebraic dependence that a new logarithm can satisfy is given by the law of exponents or the law of logarithms.

An Avera6e-Case Analysis of the Bucketsort Algorithm for Sparse Polynomial Multiplication, by Frank Teer Informatika Rapport Nr. 14, JuG 1~6, VriJe Univer- siteit, The Netherlands. An analysis is given of the average number of arith- metic operations in multiplying two sparse polynomi- als having m and n terms respectively with a new algorithm, called the bucketsort algorithm, recently developed by the author. It is shown that the aver- age number of arithmetic operations in multiplying two polynomials is O(mn) in contrast to the O(mn" logn) of other algorithms.

Sparse Complex Polynomials and Polynomial Reducibi- lity, by D. A. Plaisted, Dept. of Comp. Science, University of Illinois at Urbana-Champaign, Urbana, Illinois 61801 We show that certain problems involving sparse poly- nomials with integer coefficients are at lease As hard as any problem in NP. These problems include determining the degree of the least common multiple of a set of such polynomials, and related problems. The proofs make use of a homomorphism from Boolean expressions over the predicate symbols (P_,...,P) onto divisors of the polynomial xN-1, where N isnthe product of the first n primes. Various combinato- rial and number theoretic applications are also pre- sented. (To appear).

Some Polynomial and Inte6er Divisibility Problems a~ NP-hard, by D. A. Plaisted, Dept. of Comp. Science, Univ. of Illinois at Urbana-Champaign, Urbana, Ill. 61801. In an earlier paper (see previous abstract, Ed.) the author showed that certain problems involving sparse polynomials and integers are NP-hard. In this paper we show that many related problems are also NP-hard. In addition, we exhibit some new NP-comple- te problems in which the non-determinism is hidden. That is the problems are not explicitly stated in temns of one of a number of possibilities being true. Furthermore, most of these problems are in the areas of number theory or the theory of functions of a comp- lex variable. Thus there is a rich mathematical theory that can be brought to bear. These results therefore introduce a class of NP-hard and NP-complete problems different from those known previously. (Proceedings of the IEE SWAT Foundations of Computer Science Conference, Houston, 1976)

Aspects of Symbolic Integration and Simplification of Exponentia& and Primitive Functions, by M. Roth- stein, University of Wisconsin Ph.D. Thesis (Dec, 76) 119 p. (Available from Xerox Univ. Microfilm, Ann Arbor, Michigan) In this thesis we cover sQme aspects of the theory