UNIVERSITY OF ILLINOIS LIBRARY AT URBANA-CHAMPAIGN UIUCDCS-R -7^-675 /yuLZ>4 K August 1974 ON THE EVALUATION OF POWERS by Andrew Chi -Chin Yao UIUCDCS-R -7U-675 ON THE EVALUATION OF POWERS by Andrew Chi -Chin Yao August 197^ Department of Computer Science University of Illinois at Urbana -Champaign Urbana, Illinois 6l801 Research supported by NSF GJ-41538. Digitized by the Internet Archive in 2013 http://archive.org/details/onevaluationofpo675yaoa 1. Introduction An addition chain (of length r) is a sequence of r+1 integers a , a ,a , ...,a such that (i) a = 1 and (ii) for each i, a. = a. + a, for some j ^ k < i. It is well known [k] that, for any r and any set of integers (n ,n , . ..,n }, there exists an addition chain of length r which contains the values n^n , ...,n if and only if ni n.^ n-p there exists a procedure which, for any input x, computes [x , x , ...,x } in r operations using only multiplications. A theorem by Brauer [1] [k-] states that, for any n, there exists an addition chain of length Sgn + O(0gn/ ggitn) which contains the value n. This then implies the existence of a corresponding procedure to compute x in 2gn + 0(£gn/£g^n) multiplications. Furthermore, it was shown by Erdbs [2] [k] that the above result is nearly the best possible. In an open problem posed in Knuth [3], it is asked if there are fast procedures to compute n l n 2 n p (x ,x ,...,x *} for p ^ 2. This problem cannot be solved by a direct extension of the technique used by Brauer in the proof of his theorem. In this paper we show that, for any positive integers n, ,n p , ...,n there exists a procedure using only multiplications which, n l n 2 n v for any input x, computes (x ,x ,...,x ^} in ^N + constant x P Z [8gn./ 8g£$(n. +2) ] multiplications where N = max{n.}. This gives a i=1 1 1 ± ' 1 solution to Knuth' s problem and leads to a corresponding theorem on addition chains which generalizes Brauer' s theorem mentioned earlier. 2. Definition Let e., UiSJ, and f ., 1 , 3* q, be positive integers. e l e -n ^1 -^a We shall say that (x , ...,x fj is computable from (x ,...,x H ) in r multiplications (r ^ 0) if there exists a set of r positive integers, &g. is logarithm to the base 2. -2- ( f n ..... f } , such that 1 q+1' ' q+r J ' i ) for all i = q+1, . . . , q+r, f4 f4 fv x = x d • x " for some j ^ k < i. ii) {x \ . ..,x p } c {x , ...,x q+r }. Since the exponents are additive when two powers of x are multiplied, the above definition corresponds to a natural generalization of the definition of addition chains (cf. Section l). The exponents f-, f appearing in {x , ...,x Q) correspond to a set of numbers initially available in the chain, as opposed to a single number, 1, in the earlier definition. n-, n„ 3. The Computation of (x , ...,x ^} The following lemma is well-known [k]. Lemma 1 For any integer i > 0, {y } is computable from {y} in less than 2[^iJ multiplications. Proof Let the binary representation of i be v i = Z b. ' 2 J (1) where v = [^ij. Then, y 1 = n y 2d . (2) b.=l 3 2^8 2 V Thus, we first compute y ,y ,y ,...,y sequentially in v multiplications. Then we can compute y by equation (2) in no more than v-1 multiplications, The total number of multiplications is no greater than 2v-l. □ Theorem 2 For any integers m,n where < m ^ n, {x } is computable from 2^8 oW n \ i / n (x,x ,x ,x ,...,xr } in less than c^n/^#?(n+2) multiplications for some constant c. -3- Proof Assume n^ k. Define the following quantities: k = f(^n)/2j (3) D = 2 k 00 t = [% D nj (5) Let the D-ary representation for m be v3 m = E a.D J where g a. g D-l for j = 0,1, . . .,t . (6) We partition the set of integers (0, 1, ...,t} into D disjoint subsets S(0),S(1),...,S(D-1) by letting S(i) = U|a = i} for i = 0,1, ...,D-1. it follows from (6) that D-l D-l m = S i • [ S Tr] = Z i • m. (7) 1=1 teS(i) 1=1 x where m. = E D^ (8) 1 teS(i) From (7) and (8), we obtain the following two equations: x = n x for i = 1,2, ...,D-1 (9) teS(i) D" 1 m, i x m = n (x^) (10) 1=1 rj-t 2 4 Since all the sr in (9) are available in the set {x, x , x , 8 2^ n J, . . * * L m x ,...,x 1 ^ we can construct a procedure to compute x as follows: Step 1: For i = 1,2,..., D-l do the following: (a) Compute x" from (9) in less than |S(i)| multiplications. -k- m_. (b) Compute (x - 1 ) in less than 2[^iJ multiplications (by Lemma l) . Step 2: Compute x m from (10) in D-2 multiplications. Let M be the total number of multiplications in the above procedure. Then, D-l M < Z (|s(i)| + 2[^iJ) + D-2 i=l D-l =£ 2 |S(i)| + 2(D-l)%(D-l) +D-2 (ll) i=l Noting that the S(i)'s form a partition of the set {0, 1, ...,t}, we obtain from (ll) that, M < t + 1 + 2(D-l)^. (D-l) + D -2 (12) (12), together with equations (3), (k-) and (5), implies M < 2(%n/^^.n) + 1 + hi^n) 1 ' 2 Sg. Qo,n + 2(%n) 1 / 2 . (13) It follows from (13) that there exists a constant c such that M < c^n/%.^(n+2) (1*0 Thus the theorem is true if ni k . Obviously we can choose c so that the theorem is also true for n = 1,2,3. □ Theorem 3 For any set of positive integers (n ,n , ...,n }, n l ^2 n_ (x , x , ...,x^>} is computable from input {x} in less than P £g.~N + c £ [2gn./0g. 2g. (n. +2) ] multiplications for some constant c, i=l where N = maxfn.l . i 1 -5- n l n 2 "-p Corollary {x , x ,...,x } is computable from {x} in less than gg.~N + cp^N/^^(N+2) multiplications. 2 4 8 Proof of Theorem 3 and Corollary First we compute {x, x , x , x , •••, x } from input x in [ ^Nj multiplications. For each i, according n n ,2k '?[^9- n n I to Theorem 2, x x is computable from [x,x ,x , ...,x c - 1 - } in ... r 2 k p|%N| c 0gn./0g. 2g. (n. +2 J multiplications, and also from {x, x , x , ...,x J ] in c^N/^^(N+2) multiplications for some constant c. The theorem and corollary then follow immediately. □ In terms of addition chains, Theorem 3 and its corollary give the following generalization of Bauer's theorem [1] [k]. Theorem k- For any positive integers n,,n p , ...,n , there exists an P addition chain of length less than ^N + c £ Sgn./Pg. 2/g. (n. +2) containing 1=1 X X the values n,,n„,...,n for some constant c, where N = maxfn.}. 1' 2' ' p ' j_ i Corollary For positive integers n..,n , ...,n , there exists an addition chain of length less than ^N + cp^N/^^(N+2) containing n,,n p , ...,n . k. Conclusion n l n 2 n p We have shown that {x , x ,...,x } can be computed in ^N + cp^N/^^(N+2) multiplications for input x where N = max{n.} i 1 and c is a constant. On the other hand, it is well-known that to evaluate nn no rw, {x , x , ...,x V) by arithmetic operations, at least Sg.~N operations are n l n ? n D necessary. Thus, our procedures for evaluating {x ,x ,...,x *} are nearly the best possible when p « ^^(N+2). It remains an interesting n, no ru open problem to determine the complexity of computing (x ± , x , ...,x P] for general p. -6- References [1] Brauer, A., Bull. AMS k-5 (1939), pp. 736-739. [2] Erdbs, P., Acta Arithmetica 6 (i960), pp. 77-81. [3] Knuth, D. E., The Art of Computer Programming, Vol. 2, Add! son -Wesley, 1969, Section k.6.3 Ex. 32. [4] Knuth, D. E., The Art of Computer Programming, Vol. 2, Addis on -Wesley, I969, pp. 398-I+I8. BIBLIOGRAPHIC DATA SHEET 1. Report No. UIUCDCS-R-7^-675 3. Recipient's Accession No. 4. Title and Subtitle ON THE EVALUATION OF POWERS 5. Report Date August 197^ 7. Author(s) Andrew Chi -Chin Yao 8. Performing Organization Rept. No. 9. Performing Organization Name and Address Department of Computer Science University of Illinois at Urbana -Champaign Urb'ana, Illinois 618OI 10. Project/Task/Work Unit No. 11. Contract/Grant No. NSF GJ-^1538 12. Sponsoring Organization Name and Address National Science Foundation Washington, D . C . 13. Type of Report & Period Covered 14. 15. Supplementary Notes 16. Abstracts It is shown that for any set of positive integers {n_,n , ...,n ), there exists n-, n P n^ L 2 P a procedure which computes (x ,x , ...,x *} for any input x in less than P Sg~N + c s [0gn./(!g 2g (n.+2) ] multiplications for some constant c, where N = max{n.}, i=l - 1 x i x This gives a solution to an open problem in Knuth [3] and generalizes Brauer's theorem on addition chains. 17. Key Words and Document Analysis. 17o. Descriptors addition chains, Brauer's theorem 17b. Identifiers/Open-Ended Terms 17c. COSATI Field/Group 18. Availability Statement FORM NTIS-35 (10-70) 19. Security Class (This Report) UNCLASSIFIED 20. Security Class (This Page UNCLASSIFIED 21. No. of Pages 22. Price USCOMM-DC 40329-P7 1 hov i ~ \m frr '" :: " 1