taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 2.2.4-10

Exercise 2.2.4-10

not stated yet in Lean solution written

Rating20
KindK3, find a value: compute a number, a set or a closed form from the written solution
SectionSection 2.2.4 of Volume 1

The task

Suppose the polynomials have only one variable xx, with exponents up to b3−1b^3 - 1. Say what has to be changed in Algorithms A and M.

The exact wording is in your copy of the book.

Hints

Open one hint at a time. Try the exercise again after each.

Hint 1

Look at where the algorithms treat AA, BB, CC separately.

Solution

Show the solution

Nothing needs to change. In Algorithm A the three exponents are compared as a single number ABC\mathrm{ABC}, and in the same way they are added in Algorithm M, where the exponent fields of PP and MM are added as numbers of three bytes. If the field holds the exponent of xx in base bb, the compare, the order of the terms, and the sum of exponents are the same operations. The only place where the old program looks at AA, BB, CC individually is the check for overflow of one exponent in step M2, and the text does not carry out this check.

One can say it differently. The algorithms handle polynomials in xb2x^{b^2}, xbx^{b} and xx, and so any polynomial in xx with exponents below b3b^3 is covered, since xex^e with e=Ab2+Bb+Ce = A b^2 + B b + C.

Check

Take b=64b = 64 and the exponents 50005000 and 100100. In base 6464 they are (1,14,8)(1, 14, 8) and (0,1,36)(0, 1, 36). The three-byte numbers add as 51005100, which is (1,15,44)(1, 15, 44), a correct field, and the carry between the bytes is done by the ordinary addition of the machine. The test in Algorithm A compares the three-byte numbers 50005000 and 100100 in the right order.

Remarks

The multiplication of two polynomials in one variable is then the same program, and the only limit is that the sum of two exponents must stay below b3b^3.

This solution is drafted, and a person has not reviewed it yet. The source.

In Lean

not stated yet The exercise is not stated in Lean yet.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.