跳到主要内容

東京大学 情報理工学系研究科 電子情報学専攻 2014年8月実施 専門 第3問

Author

adj-matrix

Description

Let f=a0+a1x++amxmf = a_0 + a_1 x + \dots + a_m x^m and g=b0+b1x++bnxng = b_0 + b_1 x + \dots + b_n x^n be polynomials of xx (aia_i and bib_i are real. am0a_m \neq 0 and bn0b_n \neq 0). We represent the leading terms of the polynomials ff and gg by LT(f)=amxm\text{LT}(f) = a_m x^m and LT(g)=bnxn\text{LT}(g) = b_n x^n, and their degrees by deg(f)=m\deg(f) = m and deg(g)=n\deg(g) = n. The polynomial division, where ff is divided by a non-zero polynomial gg, is given by

f=qg+r.f = qg + r.

Here quotient qq and remainder rr are polynomials of xx satisfying r=0r = 0 or deg(r)<deg(g)\deg(r) < \deg(g). In this case, we represent r=remainder(f,g)r = \text{remainder}(f, g) and q=quotient(f,g)q = \text{quotient}(f, g).

(1) Calculate quotient(f,g)\text{quotient}(f, g) and remainder(f,g)\text{remainder}(f, g) for f=x2+7x+3f = x^2 + 7x + 3 and g=x+1g = 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. 7x37x^3 or 5x10-5x^{10}) 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 ff and gg is a polynomial hh which satisfies the following conditions.

  • hh divides ff and gg
  • if a polynomial pp divides ff and gg, then pp also divides hh

hh satisfying these conditions is represented by h=GCD(f,g)h = \text{GCD}(f, g). GCD(f,g)\text{GCD}(f, g) is unique up to multiplication by nonzero numbers. Given f=qg+rf = qg + r, by using the following relations GCD(f,g)=GCD(fqg,g)\text{GCD}(f, g) = \text{GCD}(f - qg, g) and GCD(f,0)=f\text{GCD}(f, 0) = f, GCD(f,g)\text{GCD}(f, g) can be calculated by the following procedure (without loss of generality, we assume deg(f)deg(g)\deg(f) \ge \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 ff and gg (deg(f)deg(g)\deg(f) \ge \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)\text{GCD}(f, g). Also provide a reason for the obtained result.

Kai

(1)

f=x2+7x+3f = x^2 + 7x + 3 and g=x+1g = x + 1.

Since f=(x+6)g3f = (x+6)g - 3.

Therefore q=x+6r=3\quad q = x + 6 \quad r = -3.

(2)

  • (a): r - (LT(r) / LT(g)) * g

(3)

Let rkr_k be the remainder at iteration kk. Since

rk+1=rkLT(rk)LT(gk)gkr_{k+1} = r_k - \frac{\text{LT}(r_k)}{\text{LT}(g_k)} g_k

Let deg(rk)=m,deg(gk)=n\deg(r_k) = m, \deg(g_k) = n, then

deg(rk+1)=deg(rkLT(rk)LT(gk)gk)=deg(i=0mrixirmxmgnxni=0ngixi)\deg(r_{k+1}) = \deg\left(r_k - \frac{\text{LT}(r_k)}{\text{LT}(g_k)} g_k\right) = \deg\left( \sum_{i=0}^m r_i x^i - \frac{r_m x^m}{g_n x^n} \sum_{i=0}^n g_i x^i \right)

i.e.,

deg(rk+1)=deg(i=0m1rixi+rmxmrmxmgnxn(i=0n1gixi+gnxn))=deg(i=0m1rixi+rmxmrmgnxmni=0n1gixirmxmn+n)=deg(i=0m1rixirmgnxmni=0n1gixi)\begin{aligned} \deg(r_{k+1}) &= \deg\left( \sum_{i=0}^{m-1} r_i x^i + r_m x^m - \frac{r_m x^m}{g_n x^n} \left( \sum_{i=0}^{n-1} g_i x^i + g_n x^n \right) \right) \\ &= \deg\left( \sum_{i=0}^{m-1} r_i x^i + r_m x^m - \frac{r_m}{g_n} x^{m-n} \sum_{i=0}^{n-1} g_i x^i - r_m x^{m-n+n} \right) \\ &= \deg\left( \sum_{i=0}^{m-1} r_i x^i - \frac{r_m}{g_n} x^{m-n} \sum_{i=0}^{n-1} g_i x^i \right) \end{aligned}

Since

deg(i=0m1rixi)m1<deg(rk)\deg\left( \sum_{i=0}^{m-1} r_i x^i \right) \le m - 1 < \deg(r_k) deg(rmgnxmni=0n1gixi)=m1<deg(rk)\deg\left( \frac{r_m}{g_n} x^{m-n} \sum_{i=0}^{n-1} g_i x^i \right) = m - 1 < \deg(r_k)

Therefore

deg(rk+1)<deg(rk)\deg(r_{k+1}) < \deg(r_k)

Since if deg(r)<deg(g)\deg(r) < \deg(g) the loop stops and deg(g)\deg(g) will not change. Therefore the algorithm always terminates.

(4)

  • (b): s
  • (c): rem

(5)

According to (3),

deg(rk+1)=deg(i=0m1rixirmgnxmni=0n1gixi)=deg(i=0m2rixirmgnxmni=0n2gixi+(rm1rmgngn1)xm1)\begin{aligned} \deg(r_{k+1}) &= \deg\left( \sum_{i=0}^{m-1} r_i x^i - \frac{r_m}{g_n} x^{m-n} \sum_{i=0}^{n-1} g_i x^i \right) \\ &= \deg\left( \sum_{i=0}^{m-2} r_i x^i - \frac{r_m}{g_n} x^{m-n} \sum_{i=0}^{n-2} g_i x^i + \left(r_{m-1} - \frac{r_m}{g_n} g_{n-1}\right) x^{m-1} \right) \end{aligned}

In GCD, snext=remainder(h,s)\quad s_{next} = \text{remainder}(h, s).

According to the analysis of (3), we know deg(rem)<deg(s)\deg(rem) < \deg(s) and deg(sk+1)<deg(sk)\deg(s_{k+1}) < \deg(s_k).

To find the worst case, we need let deg(sk+1)=deg(sk)1\deg(s_{k+1}) = \deg(s_k) - 1.

In this case, the degree of ss follows the sequence: n,n1,n2,,1,0n, n-1, n-2, \dots, 1, 0, where n=deg(g)n = \deg(g).

The total number of steps is the length of this sequence plus the final step: deg(g)+1\deg(g) + 1.