4.6.3 ANSWERS TO EXERCISES 637 (Apache web server) If we form
Friday, December 7th, 20074.6.3 ANSWERS TO EXERCISES 637 If we form Dirichlet generating functions g(z) = xnEA l/n , h(z) = xneB l/n*, then the product g(z)h(z) corresponds to the multiset product AB. 20. Type 3: (SO,. . . , S,) = (MOO,. . . , M,o) = ({0}, . . . , {A}, {A-l,A}, {A-l,A,A}, {A-l,A-l,A,A,A}, . . ., {A+C-3,A+C-3,A+C-2,A+C-2,A+C-2}). Type 5: (MOO,. , NO) = ({O), . , {A), {A -&A), . , {A + C -1,A + C}, {A+C-l,A+C-l,A+C}, . . . . {A+C+D-l,A+C+D-l,A+C+D}); (MOl,. ..,M,l) = (0, . . . . 0, 0, . ..f 0, {A + C -2}, . , {A + C + D -2}), S, = Mio u Mtl. 21. For example, let u. = 28qf5, x = (2(qf1)u -1)/(2 -1) = 24 + + 2 + 1, y = 2(qt ) + 1. Then zy = (22(qt1) -1)/(2 -1). If n = 24(qf1)u + xy, we have l(n) 5 4(q $ 1)~. f q + 2 by Theorem F, but l*(n) = 4(q + 1)~ + 2q + 2 by Theorem H. 22. Underline everything except the u -1 insertions used in the calculation of x. 23. Theorem G (everything underlined). 24. Use the numbers (B < -l)/(B -l), 0 5 i 5 r, underlined when a, is underlined; and c&- (B*3 -l)/(B -1) for 0 _< j < t, 0 < i 5 b3+1 -b3, 1 < k 5 1 (B), underlined when ck is underlined, where CO, cl, is a minimum length lbchain for B. To prove the second inequality, let B = 2m and use (3). (The second inequality is rarely, if ever, an improvement on Theorem G.) 25. We may assume that dk = 1. Use the rule R Ak--l . . . AI, where A3 = XR if d3 = 1, A3 = R otherwise, and where R means take the square root, x means multiply by Z. For example, if y = (.llOllOl)z, the rule is R R XR XR R XR XR. (There exist binary square-root extraction algorithms suitable for computer hardware, requiring an execution time comparable to that of division; computers with such hardware could therefore calculate more general fractional powers using the technique in this exercise.) 26. If we know the pair (Fk, Fk-l), then we have (Fk+i, Fk) = (Fk + Fk-i, Fk) and (Fzk,Fsk--1) = (F: + 2FkFk--l,F: + F:-1); so a binary method can be used to calculate (Fnr F,-I), using O(logn) arithmetic operations. Perhaps better is to use the pair of VdUeS (Fk, Lk), where Lk = Fk-i + Fk+l (cf. Section 4.5.4); then we have (Fk+l,Lk+l) = ($(Fk + Lk), #Fk + Lk)), (Fzk, Lzk) = (FkLk,Li -2(-l)k). For the general linear recurrence x n = alxn-l + . . . + adxn-d, we can compute xn in O(d3 log n) arithmetic operations by computing the nth power of an appropriate d x d matrix. [This observation is due to J. C. P. Miller and D. J. S. Brown, Comp. J. 9 (1966), 188-190.1 27. First form the 2m -m -1 products XI . . . x2, for all sequences of exponents such that 0 2 e3 _< 1 and el + . . . + e, 2 2. Let n3 = (d3x . . . djld30)2; to complete the calculation, take x$ . . x2>, then square and multiply by xf %. . . x&~~, for i = X - 1, 1, 0. [Straus showed in AMM 71 (1964), 807-808, that 2X(n) may be replaced by &)x( n )f or any E > 0, by generalizing this binary method to 2k-ary as in Theorem D. See exercise 39 for later developments.] 28. (a) x V y = x V y V (z + y), where V is logical or , cf. exercise 4.6.2-26; clearly v(x V y) 5 v(x V y) + Y(X A y) = V(X) + v(y). (b) Note first that A,-1/2dZ-1 c A,/2da for 1 2 i I: r. Secondly, note that d, = di-1 in a nondoubling; for otherwise at-l 2 2aj 2 a9 + ak = a,. Hence Aj C A,-1 and Ak c Ai-1/2~3-~~. (c) An easy induction on i, except that close steps need closer attention. Let us say that m has property P(o) if the l s in its binary representation all appear in consecutive