

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


MA 522 Fall 2008
Solution: DIVISION-WITH-REMAINDER INPUT: a =
∑n i=0 ai^2
64 i, and b = ∑m i=0 bi^2
64 i
OUTPUT: q, r ∈ Z such that a = qb + r, 0 ≤ r < b. 1 r ← a 2 for i = n − m, n − m − 1 ,... 0 do 3 if rm+i 6 = 0 then 4 qi ← quo(rm+i, bm) %Use single precision division with remainder 5 if qi = 0 then qi ← quo(rm+i 264 + rm+i− 1 , bm) 6 while r − qi 264 ib < 0 do 7 qi ← qi − 1 8 r ← r − qi 264 ib 9 else qi ← 0 10 return q =
∑n−m i=0 qi^2
64 i (^) and r.
∑n i=0 aix i (^) ∈ R[x] of degree n, all ai ∈ R. The
weight w(a) of a is the number of nonzero coefficients of a besides the leading coefficient:
w(a) := #{ 0 ≤ i < n : ai 6 = 0}.
Thus w(a) ≤ deg(a), with equality if and only if all coefficients of a are nonzero. The sparse representation of a is a list (i, ai)i∈I , with each ai ∈ R and a =
i∈I aix
i. Then we
can choose #I = w(a) + 1.
(i) Show that two polynomials a, b ∈ R[x] of weight w(a) = n and w(b) = m can be multiplied in the sparse representation using at most 2 nm + n + m + 1 arithmetic opera- tions in R. Proof: The polynomial multiplication algorithm (ALGORITHM 2.3) requires (n + 1)(m + 1) multiplications in R and the resulting (n+1)(m+1) products are summed up in n+m+1. Since the summing of s items costs s − 1 additions, the total number of additions in R is (n+1)(m+1)−(n+m+1) = nm. Thus we have at most (n+1)(m+1)+nm = 2nm+n+m+ operations in R.
(iii) Let n ≥ m. Show that quotient and remainder on division of a polynomial a ∈ R[x] of degree less than n by b ∈ R[x] of degree m, with lc(b) a unit, can be computed using n − m divisions in R ans w(b) · (n − m) multiplications and subtractions in R each. Proof: The polynomial division algorithm (ALGORITHM 2.5) requires n − m divisions in R, and n − m constant multiplication and abstraction of the polynomial b. Since the lead- ing term is always 0 after the subtraction of the constant multiple of b, we do not need to
compute that term. Therefore each of these polynomial subtractions and multiplications only need w(b) operations over R, even though b has w(b) + 1 terms. Therefore the algo- rithm uses w(b)(n − m) subtractions and multiplications over R.
Since this four cases cover all possibilities, the algorithm returns the correct answer.
(iii) An upper bound for the depth of the recursion depth is
dlog 2 (ab)e = dlog 2 (a) + log 2 (b)e.
Assume that a and b has binary length n and m, respectively. Then running time satisfies the following recursion equation:
T (n + m) = max(T (n + m − 2), T (n + m − 1)) + n + m− = T (n + m − 1) + n + m.
The solution for this equation is
n∑+m
i=
i =
(n + m)(n + m + 1) 2
∈ O(n^2 ).