東京大学 情報理工学系研究科 電子情報学専攻 2014年8月実施 専門 第3問
Author
adj-matrix
Description
Let f=a0+a1x+⋯+amxm and g=b0+b1x+⋯+bnxn be polynomials of x (ai and bi are real. am=0 and bn=0). We represent the leading terms of the polynomials f and g by LT(f)=amxm and LT(g)=bnxn, and their degrees by deg(f)=m and deg(g)=n. The polynomial division, where f is divided by a non-zero polynomial g, is given by
f=qg+r.
Here quotient q and remainder r are polynomials of x satisfying r=0 or deg(r)<deg(g). In this case, we represent r=remainder(f,g) and q=quotient(f,g).
(1) Calculate quotient(f,g) and remainder(f,g) for f=x2+7x+3 and g=x+1.
(2) Complete a pseudocode of the polynomial division algorithm by filling (a) with appropriate expressions. Note that the four arithmetic operations for monomial terms (expressions that contain only one term, e.g. 7x3 or −5x10) and addition/subtraction operations for polynomials can be used as they are.
Input: f, g
Output: q, r
q = 0, r = f
while (r ≠ 0 and deg(g) ≤ deg(r)) {
q = q + LT(r)/LT(g)
r = _____ (a) _____
}
(3) Prove that the algorithm introduced in (2) always terminates.
(4) The greatest common divisor (GCD) for polynomials f and g is a polynomial h which satisfies the following conditions.
- h divides f and g
- if a polynomial p divides f and g, then p also divides h
h satisfying these conditions is represented by h=GCD(f,g). GCD(f,g) is unique up to multiplication by nonzero numbers. Given f=qg+r, by using the following relations GCD(f,g)=GCD(f−qg,g) and GCD(f,0)=f, GCD(f,g) can be calculated by the following procedure (without loss of generality, we assume deg(f)≥deg(g)). Fill (b) and (c) with appropriate expressions.
Input: f, g
Output: h
h = f
s = g
while (s ≠ 0) {
rem = remainder(h, s)
h = ______ (b) ______
s = ______ (c) ______
}
(5) Given arbitrary polynomials f and g (deg(f)≥deg(g)), calculate an upper bound of the number of times that a function remainder is called inside the while-loop during the calculation of GCD(f,g). Also provide a reason for the obtained result.
Kai
(1)
f=x2+7x+3 and g=x+1.
Since f=(x+6)g−3.
Therefore q=x+6r=−3.
(2)
- (a):
r - (LT(r) / LT(g)) * g
(3)
Let rk be the remainder at iteration k.
Since
rk+1=rk−LT(gk)LT(rk)gk
Let deg(rk)=m,deg(gk)=n, then
deg(rk+1)=deg(rk−LT(gk)LT(rk)gk)=deg(i=0∑mrixi−gnxnrmxmi=0∑ngixi)
i.e.,
deg(rk+1)=deg(i=0∑m−1rixi+rmxm−gnxnrmxm(i=0∑n−1gixi+gnxn))=deg(i=0∑m−1rixi+rmxm−gnrmxm−ni=0∑n−1gixi−rmxm−n+n)=deg(i=0∑m−1rixi−gnrmxm−ni=0∑n−1gixi)
Since
deg(i=0∑m−1rixi)≤m−1<deg(rk)
deg(gnrmxm−ni=0∑n−1gixi)=m−1<deg(rk)
Therefore
deg(rk+1)<deg(rk)
Since if deg(r)<deg(g) the loop stops and deg(g) will not change.
Therefore the algorithm always terminates.
(4)
(5)
According to (3),
deg(rk+1)=deg(i=0∑m−1rixi−gnrmxm−ni=0∑n−1gixi)=deg(i=0∑m−2rixi−gnrmxm−ni=0∑n−2gixi+(rm−1−gnrmgn−1)xm−1)
In GCD, snext=remainder(h,s).
According to the analysis of (3), we know deg(rem)<deg(s) and deg(sk+1)<deg(sk).
To find the worst case, we need let deg(sk+1)=deg(sk)−1.
In this case, the degree of s follows the sequence: n,n−1,n−2,…,1,0, where n=deg(g).
The total number of steps is the length of this sequence plus the final step: deg(g)+1.