Archive for the 'J2EE' Category

370 ARITHMETIC 4.5.4 Algorithm B (Monte Carlo factorization). (Domain and web hosting)

Monday, February 25th, 2008

370 ARITHMETIC 4.5.4 Algorithm B (Monte Carlo factorization). This algorithm outputs the prime factors of a given integer N 2 2, with high probability, although there is a chance that it will fail. Bl. [Initialize.] Set 2 c 5, x c 2, Ic +- 1, 1 +- 1, n +- N. (During this algorithm, 72 is the unfactored part of N, and the variables x and x represent the quantities x, modn and xl m~-l modn in (9), where f(z) = x2 + 1, A = 1, 1=l(m),andk=21-m. I B2. [Test primality.] If 72 is prime (see the discussion below), output n; the algorithm terminates. B3. [Factor found?] Set g t gcd(x -x, n). If g = 1, go on to step B4; otherwise output g. Now if g = n, the algorithm terminates (and it has failed, because we know that n isn t prime). Otherwise set n t n/g, x c xmodn, x t 5 mod 12, and return to step B2. (Note that g may not be prime; this should be tested. In the rare event that g isn t prime, its prime factors probably won t be determinable with this algorithm.) B4. [Advance.] Set k t k -1. If Ic = 0, set x c x, 1 c 21, Ic c 1. Set x t (x2 + 1) mod n and return to B3. fl As an example of Algorithm B, let s try to factor N = 25852 again. The third execution of step B3 will output g = 4 (which isn t prime). After six more iterations the algorithm finds the factor g = 23. Algorithm B has not distinguished itself in this example, but of course it was designed to factor big numbers. Algorithm A takes much longer to find large prime factors, but it can t be beat when it comes to removing the small ones. In practice, we should run Algorithm A awhile before switching over to Algorithm B. We can get a better idea of Algorithm B s prowess by considering the ten largest six-digit primes. The number of iterations, m(p), that Algorithm B needs to find the factor p is given in the following table: p= 999863 999883 999907 999917 999931 999953 999959 999961 999979 999983 m(P) = 276 409 2106 1561 1593 1091 474 1819 395 814 Experiments indicate that m(p) has an average value of about ZJir, and it never exceeds 12& when p < 1000000. The maximum m(p) for p < lo6 is ~~(874771) = 7685; and the maximum of m(p)/& occurs when p = 290047, m(p) .= 6251. According to these experimental results, almost all 12-digit numbers can be factored in fewer than 2000 iterations of Algorithm B (compared to roughly 100,000 divisions in Algorithm A). The time-consuming operations in each iteration of Algorithm B are the multiple-precision multiplication and division in step B4, and the gcd in step B3. If the gcd operation is slow, Pollard suggests gaining speed by accumulating the product mod rz of, say, ten consecutive (x/-x) values before taking each gcd; this replaces 90 percent of the gcd operations by a single multiplication and division while only slightly increasing the chance of failure. He also suggests starting with m = 4 instead of m = 1 in step Bl, where q is, say, & the number of iterations you are planning to use.

4.5.4 FACTORING INTO PRIMES 389 [Cf. G. H. (Web design online)

Sunday, February 24th, 2008

4.5.4 FACTORING INTO PRIMES 389 [Cf. G. H. Hardy and E. M. Wright 0), 522.11; see als The size of prime factors has a remarkable connection with permutations: The average number of bits in the lath largest prime factor of a random n-bit integer is asymptotically the same as the average length of the lath largest cycle of a random n-element permutation, as n + 00. [See D. E. Knuth and L. Trabb Pardo, Theoretica Comp. Sci. 3 (1976), 321-348.1 It follows that Algorithm A usually finds a few small factors and then begins a long-drawn-out search for the big ones that are left. Factoring a la Monte Carlo. Near the beginning of Chapter 3, we observed that a random number generator chosen at random isn t very random. This principle, which worked against us in that chapter, has the redeeming virtue that it leads to a surprisingly efficient method of factorization, discovered by J. M. Pollard [BIT 15 (1975), 331-3341. Th e number of computational steps in Pollard s method is on the order of &, so it is significantly faster than Algorithm A when N is large. According to (7) and Fig. 11, the running time will usually be well under N1i4. Let f(z) be any polynomial with integer coefficients, and consider the two sequences defined by x0 = yyo = A; xm+l = f(x,) mod N, ym+l = f(yd modn (9) where p is any prime factor of N. It follows that yrn = xm mod P, for m 2 1. UOi Now exercise 3.1-7 shows that we will have ym = y~(~)-i for some m 2 1, where l(m) is the greatest power of 2 that is 2 m. Thus xm -x~(~).-i will be a multiple of p. Furthermore if f(y)modp behaves as a random mapping from the set {O,l,. . . , p - 1) into itself, exercise 3.1-12 shows that the average value of the least such m will be of order Jir. In fact, exercise 4 below shows that this average value for random mappings is less than 1.625 Q(p), where the function Q(p) x m was defined in Section 1.2.11.3. If the different prime divisors of N correspond to different values of m (as they almost surely will, when N is large), we will be able to find them by calculating gcd(x, -~l(~)-i, N) for m = 1, 2, 3, . . .X until the unfactored residue is prime. From the theory in Chapter 3, we know that a linear polynomial f(z) = ax + c will not be sufficiently random for our purposes. The next-simplest case is quadratic, say f(x) = x2 + 1; although we don t know that this function is sufficiently random, our lack of knowledge tends to support the hypothesis of randomness, and empirical tests show that this f does work essentially as predicted. In fact, f is probably slightly better than random, since x2 + 1 takes on only i(p + 1) distinct values mod p. Therefore the following procedure is reasonable:

Most popular web site - 368 ARITHMETIC Fig. 11. Probability distribution functions for

Saturday, February 23rd, 2008

368 ARITHMETIC Fig. 11. Probability distribution functions for the two largest prime factors of a random integer 2 x. Dickman s (see exercise 18), we can show that the second-largest prime factor of a random integer z will be 2 Z? with approximate probability G(P), where Clearly G(P) = 1 for p 2 a. (See Fig. 11.) Numerical evaluation of (6) and (7) yields the following percentage points : F(a), G(P) = .Ol .05 .lO .20 .35 .50 .65 .80 .90 .95 .99 a = .2697 .3348 .3785 .4430 .5220 .6065 .704i .8187 .9048 .9512 .9900 B = .0056 .0273 .0531 .1003 .1611 .2117 .2582 .3104 .3590 .3967 .4517 Thus, the second-largest prime factor will be 5 x.2117 about half the time, etc. The total number of prime factors, t, has also been intensively analyzed. Obviously 1 5 t2 lg N, but these lower and upper bounds are seldom achieved. It is possible to prove that if N is chosen at random between 1 and 2, the probability that t5 In In x + cd= approaches 1 c -u=/2 (8) -Ifi –ooe du as z + co, for any fixed c. In other words, the distribution of tis essentially normal, with mean and variance lnlnz; about 99.73 percent of all the large integers 5 z have It-lnln ~1 5 3dm. Furthermore the average value of t-In In x for 1 5 N < 2 is known to approach 7 + c (ln(1 -l/p) + l/(p -1)) = LO3465 38818 9 7438. p prime

4.5.4 FACTORING INTO PRIMES 367 would imply that (Kids web site)

Friday, February 22nd, 2008

4.5.4 FACTORING INTO PRIMES 367 would imply that X(X) = L(z) + O(Jl 2 o g z),* see exercise 25. Richard Brent has used a method of D. H. Lehmer to verify Riemann s hypothesis computationally for all small values of z, by showing that c(z) has exactly 75,000,OOO zeros whose imaginary part is in the range 0 < SZ < 32585736.4; all of these zeros have !J?z = 3 and c (z) # 0. [Math. Camp. 33 (1979), 1361-1372.1 In order to analyze the average behavior of Algorithm A, we would like to know how large the largest prime factor pt will tend to be. This question was first investigated by Karl Dickman [A&iv fiir Mat., As&on. och Fys. 22A, 10 (1930), l-141, who studied the probability that a random integer between 1 and z will have its largest prime factor 5 P. Dickman gave a heuristic argument to show that this probability approaches the limiting value F(a) as 2 + 00, where F can be calculated from the functional equation F(a) = 6 F(A) T, for 0 2 QI 5 1; F(a) = 1 for QI 2 1. (6) His argument was essentially this: Given 0 < t < 1, the number of integers less than x whose largest prime factor is between xt and xtfdt is xF (t) dt. The num- ber of primes p in that range is ~IT(x~+~~ T(x ) n(xt + (ln z)xt dt) - r(xt) = ) - = xt dt/t. For every such p, the number of integers n such that np 5 z and the largest prime factor of n is < p is the number of n 5 x1-t whose largest prime factor is 5 (~?- )~/(l-~), namely x1- F(t/(l -t)). Hence xF (t) dt = (x dt/t)(xl-tF(t/(l -t))), and (6) fo11ows by integration. This heuristic argu- ment can be made rigorous; V. Ramaswami [Bull. Amer. Math. Sot. 55 (1949), 1122-11271 showed that the probability in question for fixed a is asymptotically F(a)+O(l/log x), as 2 + co, and many other authors have extended the analysis [see the survey by Karl K. Norton, Memoirs Amer. Math. Sot. 106 (1971), g-271. If 3 2 cr < 1, formula (6) simplifies to F(a) = l-s, F(&)$ = 1-l: = l+lna. Thus, for example, the probability that a random positive integer 5 x has a prime factor > fi is 1 - F( 4) = In 2, about 69 percent. In all such cases, Algorithm A must work hard. The net result of this discussion is that Algorithm A will give the answer rather quickly if we want to factor a six-digit number; but for lqrge N the amount of computer time for factorization by trial division will rapidly exceed practical limits, unless we are unusually lucky. Later in this section we will see that there are fairly good ways to determine whether or not a reasonably large number n is prime, without trying all divisors up to &i. Therefore Algorithm A would often run faster if we inserted a primality test between steps A2 and A3; the running time for this improved algorithm would then be roughly proportional to pt-1, the second-largest prime factor of N, instead of to max(p,-l, ,&). By an argument analogous to

366 ARITHMETIC 4.5.4 can be (Virtual web hosting) set up by

Friday, February 22nd, 2008

366 ARITHMETIC 4.5.4 can be set up by means of a short auxiliary program, which builds the table just after the factoring program has been loaded into the computer; see Algorithm 1.3.2P, or see exercise 8. How many trial divisions are necessary in Algorithm A? Let T(Z) be the number of primes 5 Z, so that 7r(2) = 1, ~(10) = 4; the asymptotic behavior of this function has been studied extensively by many of the world s greatest mathematicians, beginning with Legendre in 1798. Numerous advances made during the nineteenth century culminated in 1899, when Charles de la Vall6e Poussin proved that, for some A > 0, 7(x)= s21 & + o(xe-A@=). [A&m. Cowon&% Acad. Roy. Belgique 59 (1899), l-74.1 Integrating by parts yields T(x)=j& + (In:) + ($)3 + . . . + (l,;):+l + o( (log g+J C4) for all fixed r 2 0. The error term in (3) has subsequently been improved; for example, it can be replaced by 0(x exp(-A(log x)3/5/(log log x)1/5)). [See A. Walfisz, Weyl sche Exponentialsummen in der neueren Zahlentheorie (Berlin, 1963), Chapter 5.1 Bernhard Riemann conjectured in 1859 that T(X) = c p(k)L($q/k + O(1) = L(z) -&(&) -;qs) +. *. (5) k>l where L(s) = sr dt/lnt, and his formula agrees well with actual counts when z is of reasonable size. For example, we have the following table: X n(x) x/in x L(x) Riemann s formula 103 168 144.8 176.6 168.36 106 78498 72382.4 78626.5 78527.40 109 50847534 48254942.4 50849233.9 50847455.43 However, the distribution of large primes is not that simple, and Riemann s con- jecture (5) was disproved by J. E. Littlewood in 1914; see Hardy and Littlewood, Acta Math. 41 (1918), 119-196, where it is shown that there is a positive con- stant C such that T(Z) > L(x) + Cfilogloglog x/log x for infinitely many x. Littlewood s result shows that prime numbers are inherently somewhat mys- terious, and it will be necessary to develop deep properties of mathematics before their distribution is really understood. Riemann made another much more plausible conjecture, the famous Riemann hypothesis, which states that the complex function c(z) is zero only when the real part of z is equal to 4, except in the trivial cases where z is a negative even integer. This hypothesis, if true,

4.5.4 FACTORING INTO PRIMES 365 Al. Initialize No (Top ten web hosting)

Thursday, February 21st, 2008

4.5.4 FACTORING INTO PRIMES 365 Al. Initialize No A3. Divide A5. Factor found A7. n is prime Fig. 10. A simple factoring algorithm. A3. [Divide.] Set 4 t Ln/&J, T t n mod &. (Here 4 and r are the quotient and remainder obtained when n is divided by dk.) A4. [Zero remainder?] If r # 0, go to step A6. A5. [Factor found.] Increase t by 1, and set pt t d,+, n t q. Return to step A2. A6. [Low quotient?] If q > dk, increase Ic by 1 and return to step A3. A7. [n is prime.] Increase t by 1, set pt t n, and terminate the algorithm. 1 As an example of Algorithm A, consider the factorization of the number N = 25852. We immediately find that iV = 2 a 12926; hence pl = 2. Further- more, 12926 = 2.6463, so ~2 = 2. But now n = 6463 is not divisible by 2, 3, 5, * * . , 19; we find that n = 23.281, hence ps = 23. Finally 281 = 12 + 23 + 5 and 12 5 23; hence p4 = 281. The determination of 25852 s factors has therefore involved a total of 12 division operations; on the other hand, if we hadbtried to factor the slightly smaller number 25849 (which is prime), at least 38 division operations would have been performed. This illustrates the fact that Algorithm A requires a running time roughly proportional to max(pt-1, @). (If t = 1, this formula is valid if we adopt the convention ~0 = 1.) The sequence do, dl, dz, . . . of trial divisors used in Algorithm A can be taken to be simply 2, 3, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, . . . , where we alternately add 2 and 4 after the first three terms. This sequence contains all numbers that +re not multiples of 2 or 3; it also includes numbers such as 25, 35, 49, etc., which are not prime, but the algorithm will still give the correct answer. A further savings of 20 percent in computation time can be made by removing the numbers 30m f 5 from the list for m 2 1, thereby eliminating all of the spurious multiples of 5. The exclusion of multiples of 7 shortens the list by 14 percent more, etc. A compact bit table can be used to govern the choice of trial divisors. If N is known to be small, it is reasonable to have a table of all the necessary primes as part of the program. For example, if N is less than a million, we need only include the 168 primes less than a thousand (followed by the value dlss = 1000, to terminate the list in case N is a prime larger than 9972). Such a table

364 ARITHMETIC (Best web hosting) 4.5.3 44. [A42.5] Suppose we are

Wednesday, February 20th, 2008

364 ARITHMETIC 4.5.3 44. [A42.5] Suppose we are doing fixed slash arithmetic with mediant rounding, where the fraction (U/U ) is representable if and only if 1 1~1< M and 0 5 1~ < N and gcd(u, 2~ ) = 1. Prove or disprove the identity ((U/U ) @ (U/W )) 8 (V/W ) = (u/u ) for all representable (U/U ) and (U/W ), provided that U < v% and no overflow occurs. 45. [HM48] Develop the analysis of algorithms for computing the greatest common divisor of three or more integers. 4.5.4. Factoring into Primes Several of the computational methods we have encountered in this book rest on the fact that every positive integer n can be expressed in a unique way in the form n=w2...pt, Pl I P2 5 ... I Pt, (1) where each pk is prime. (When n = 1, this equation holds for t = 0.) It is unfortunately not a simple matter to find this prime factorization of n, or to determine whether or not n is prime. So far as anyone knows, it is a great deal harder to factor a large number n than to compute the greatest common divisor of two large numbers m and n; therefore we should avoid factoring large numbers whenever possible. But several ingenious ways to speed up the factoring process have been discovered, and we will now investigate some of them. Divide and factor. First let us consider the most obvious algorithm for factor- ization: If n > 1, we can divide n by successive primes p = 2, 3, 5, . . . until discovering the smallest p for which n mod p = 0. Then p is the smallest prime factor of n, and the same process may be applied to n c n/p in an attempt to divide this new value of n by p and by higher primes. If at any stage we find that nmodp # 0 but Ln/pJ 5 p, we can conclude that n is prime; for if n is not prime, then by (1) we must have n 2 pf, but pl > p implies that ~~2(~+1)~>~(~+1)>~~+(nmod~)~lnl~J~+(nmod~)=n. This leads us to the following procedure: Algorithm A (Factoring by division). Given a positive integer N, this algorithm finds the prime factors pl 5 p2 5 … 5 p, of N as in Eq. (1). The method makes use of an auxiliary sequence of trial divisors 2 = do < dl < dz < da < . , (2) which includes all prime numbers 5 m (and which may also include values that are not prime, if it is convenient to do so). The sequence of d s must also include at least one value such that dk 2 m. Al. [Initialize.] Set t t 0, k t 0, n t N. (During this algorithm the variables t, k, n are related by the following condition: % = N/p1 . . .pt, and n has no prime factors less than dk. ) A2. [n = l?] If n = 1, the algorithm terminates.

Com web hosting - 45.3 ANALYSIS OF EUCLID S ALGORITHM 363 37. [M38]

Wednesday, February 20th, 2008

45.3 ANALYSIS OF EUCLID S ALGORITHM 363 37. [M38] (T. S. Mote in and E. G. Straus.) Let al, . . . , a, be positive integers. Show that max Qn(a,(l), . . . , sp(n)), over all permutations p(1). . . p(n) of {1,2, . . . , n}, occurs when U,(I) 2 a,(,) 2 a,(2) 2 u~(~–I) 2 .+.; and the minimum occurs when u,cl) 2 a,(n) I U,(3) I %(n-2) I U,(5) 5 *** 5 a,(6) 5 %(n-3) 5 a,(4) < %(n-1) 2 a,(2). 38. [A4~?5] (J. Mikusiriski.) Let K(n) = max,zo T(m, n). Theorem F shows that K(n) < Llog+(&n + 1)j -2; prove that K(n) 2 frlog+(&n + 1)1 - 2. b 39. [A&%] (R. W. Gosper.) If a baseball player s batting average is .334, what is the fewest possible number of times he has been at bat? [Note for non-baseball-fans: Batting average = (number of hits)/(t lmes at bat), rounded to three decimal places.] b 40. [MZB] (The Stern-Peirce tree.) Consider an infinite binary tree in which each node is labeled with the fraction (pl + p,)/(ql + q7), where pl/ql is the label of the node s nearest left ancestor and p7/q7 is the label of the node s nearest right ancestor. (A left ancestor is one that precedes a node in symmetric order, while a right ancestor follows the node. See Section 2.3.1 for the definition of symmetric order.) If the node has no left ancestors, pl/ql = O/l; if it has no right ancestqrs, pr/q7 = l/O. Thus the label of the root is l/l; the labels of its two sqns are l/2 and 2/l; the labels of the four nodes on level 2 are l/3, 213, 312, and 3/l, from left to right; the labels of the eight nodes on level 3 are l/4, 215, 315, 314, 413, 513, 512, 4/l; and so on. Prove that p is relatively prime to q in each label p/q; furthermore, the node labeled p/q precedes the nbde labeled p /q in symmetric order if and only if the labels satisfy p/q < p /q . Find a connection between the cbntinued fraction for the label of a node and the path to that node, thereby showing that each positive rational number appears as the label of exactly one node in the tree. 01 (J. Shallit, 1979.) Show that the regular continued fraction expansion of f+$+$+...=cL 22"-1 VI>1 contains only l s and 2 s and has a fairly Prove that the partial quotients of Liouville s numbers c,, 1 l- gular pattern, when 1 is any integer 2 2. [The latter nurpb&, introduced by J. Liouville in J. de Math. Pures et Appl. 16 (1851), 133-142, were the first explicitly defined numbers to be proved transcendental. The former number and si&lar constants were first proved transcendental by A. J. Kempner, Trans. Amer. Math. Sot. 17 (1916), 476-482.1 42. [M30] (J. Lagrange, 1798.) Let X have the regular continued fraction expansion /AI,-&, . . . /, and let qn = &,(A;, . . . ,An). Let llzll denote the distance from z to the nearest integer, namely min, IZ -p(. Show that IlqXll 2 llqn-lXll for 1 5 q < qn. (Thus the denoniinators qn of the so-call&d convergents pn/q, = /Al,. . . ,An/ are the record-breaking integers that make IlqXll achieve new lows.) 43. [A&?01 (D. W. Matula.) Show that the media@ rounding rule for fixed-slash or floating-slash numbers, Eq. 4.5.1-1, can be implemented simply as follows, when the number z > 0 is not representable: Let the regular continued fraction expansion of 2 be uo + /al, ~2,. . . /, and let pn = Q,+l(uo,. . . ,a,), qn = Qn(ul,. . . , a,). Then round(z) = (pilqi), where (pi/qi) is representable but (pi+l/qi+l) is not. [Hint: See exercise 40 .]

Web hosting support - 362 ARITHMETIC 4.5.3 33. [MS .!?] Let h(n) be

Tuesday, February 19th, 2008

362 ARITHMETIC 4.5.3 33. [MS .!?] Let h(n) be the number of representations of n in the form n = xx + yy , x>y>o, x > y > 0, gcd(x, Y) = 1, integer Z, 2 , y, y , (a) Show that if the conditions are relaxed to allow Z = y , the number of repre- sentations is h(n) + ](n -1)/2j. (b) Sh ow that for fixed y > 0 and 0 < t 2 y, where gcd(t, y) = 1, and for each fixed 5 in the range 0 < 2 < n/(y + t) such that x t = n (modulo y), there is exactly one representation of n satisfying the restrictions of (a) and the condition z = t (modulo y). (c) Consequently where the sum is over all positive integers y, t, t such that gcd(t, y) = 1, t 5 y, t 5 y, tt 3 n (modulo y). (d) Show that each of the h(n) representations can be expressed uniquely in the form 3: = &rn(Zl, . . . , zm), Y = &m-1(51,. . . ,xm-l), 2 = &k(Xm+l, . . . , &n+k) d, Y =&k-1(%+2,…, %+k)d, where m, k, d, and the x3 are positive integers with x1 2 2, &+k 2 2, and d is a divisor of n. The identity of exercise 32 now implies that n/d = &m+k(xI, . . . , xmfk). Conversely, any given sequence of positive integers XI, . . , &+k such that x1 2 2, xm+k 2 2, and &m+k(xl, . . . , &+k) divides n, corresponds in this way to m + k -1 representations of n. (e) Therefore nT,, = [(5n -3)/2] + 2h(n). 34. [HM40] (H. Heilbronn.) (a) Let hd(n) be the number of representations of n as in exercise 33 such that xd < x , plus half the number of representations with xd = x . Let g(n) be the number of representations without the requirement that gcd(x, y) = 1. Prove that h(n)=c dd)g( = 2 c hd( f). z), g(n) dn dn (b) Generalizing exercise 33(b), sh ow that for d 2 1, hd(n) = C(n/(y(y k t))) + O(n), where the sum is over all integers y and t such that gcd(t,y) = 1 and 0 < t 2 y < Jnld. (c) Show that c 1 1,1,(~1(~ + t)) = P(Y) ln 2 i- 0(-l(~)), where the sum is over the range 0 < t 5 y, gcd(t,y) = 1; and where a-l(y) = c,,v(l/d). (d) Show that CIcyln cp(y)/y = zl

Web host - 4.5.3 ANALYSIS OF EUCLID S ALGORITHM 361 21. [HiV29]

Monday, February 18th, 2008

4.5.3 ANALYSIS OF EUCLID S ALGORITHM 361 21. [HiV29] (E. Wirsing.) The bounds (37) were obtained for a function (o correspond- ing to g with Tg(z) = l/(a: + 1). Sh ow that the function corresponding to Tg(z) = l/(z + c) yields better bounds, when c > 0 is an appropriate constant. 22. [H.46] (K. I. Babenko.) Develop efficient means to calculate accurate approxima- tions to the quantities Xj and I j(S) in (42), for small j > 3 and for 0 5 z 2 1. 23. [H.,%?] Prove (51), using results from the proof of Theorem W. 24. [M%?] What is the average value of a partial quotient A, in the regular continued fraction expansion of a random real number? 25. [HM,%] Find an example of a set 1 = 11 u 1~ U 1s lJ . e. c [0, l], where the I s are disjoint intervals, for which (43) does not hold. 26. [MH] Show that if the numbers {l/n, 2/n,. . . , ]n/2J/n} are expressed as regular continued fractions, the result is symmetric between left and right, in the sense that /At,… ,Az,AlI appears whenever /Al, AZ, . . . , At/ does. 27. [Mz?~] Derive (53) from (47) and (52). 28. [A&%?] Prove the following identities involving the three number-theoretic func- tions cp(n), p(n), A(n): a) C p(d) = &I. b) Inn = c A(d), n = c 44. dn dn dn 4 A(n) = xp(f)lnd cp(n)= cp(z)d. dn 4 29. [A&Y?] Assuming that Tn is given by (53), show that (55) equals (56). b 30. [H&f%?] The following variant of Euclid s algorithm is often suggested: Instead of replacing v by umodv during the division step, replace it by ](~modv) -v] if umodw > iv. Thus, for example, if u = 26 and v = 7, we have gcd(26,7) = gcd(-2,7) = gcd(7,2); -2 is the remainder of smallest magnitude when multiples of 7 are subtracted from 26. Compare this procedure with Euclid s algorithm; estimate the number of division steps this method saves, on the average. b 31. [A&%] Find the worst case of the modification of Euclid s algorithm suggested in exercise 30; what are the smallest inputs u > v > 0 that require n division steps? 32. [.20] (a) A Morse code sequence of length n is a string of T dots and s dashes, where r + 29 = n. For example, the Morse code sequences of length 4 are . . . . . . .-) *-.) -..-.., –. Noting that the continuant 94(x1, z2, zs, 24) is zlz2×3z4 + Z1Z2 + 2124 + Z3Z4 + 1, find and prove a simple relation between Qn(zi, . . . , zn) and Morse code sequences of length n. (b) (L. Euler, Novi Comm. Acad. Sci. Pet. 9 (1762), 53-69.) Prove that Qm+n(% *. . , %n+n) = Q&I,. . . ,~J&&m+l,. . . ,xm+n) + Qm-~(a,. . . , em-1)&n-l(zm+2,. . . , zm+n).