東京大学 情報理工学系研究科 電子情報学専攻 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.
题目描述
设
f=a0+a1x+⋯+amxm,g=b0+b1x+⋯+bnxn
为关于 x 的多项式,其中 ai,bi 为实数,am=0、bn=0。定义首项 LT(f)=amxm、LT(g)=bnxn,次数 deg(f)=m、deg(g)=n。用非零多项式 g 除 f 时,
其中商 q、余式 r 均为多项式,且 r=0 或 deg(r)<deg(g);记 r=remainder(f,g)、q=quotient(f,g)。
(1) 当 f=x2+7x+3、g=x+1 时,计算 quotient(f,g) 和 remainder(f,g)。
(2) 在下列多项式除法伪代码中,用适当表达式填充 (a)。可以直接使用单项式(如 7x3 或 −5x10)的四则运算以及多项式的加减运算。
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) 证明 (2) 的算法一定终止。
(4) 多项式 f,g 的最大公因式是满足下列条件的多项式 h:
- h 同时整除 f 和 g;
- 若多项式 p 同时整除 f 和 g,则 p 也整除 h。
记 h=GCD(f,g);它在相差非零常数倍的意义下唯一。利用
GCD(f,g)=GCD(f−qg,g),GCD(f,0)=f
可按下列过程计算最大公因式,并不失一般性地假设 deg(f)≥deg(g)。填写 (b)、(c)。
Input: f, g
Output: h
h = f
s = g
while (s ≠ 0) {
rem = remainder(h, s)
h = ______ (b) ______
s = ______ (c) ______
}
(5) 对任意满足 deg(f)≥deg(g) 的多项式 f,g,给出计算 GCD(f,g) 时,while 循环内调用 remainder 次数的上界,并说明理由。
- 多项式长除法:要求利用首项相消补全余式更新式,并以余式次数严格下降证明终止。
- 多项式欧几里得算法:要求依据最大公因式不变性补全迭代变量,并用次数序列估计余式调用次数上界。
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.