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($B<gJQ?t(B) $B$r7h$a$F(B, $B<gJQ?t$K4X$9$k(B 1 $BJQ?tB?9`<0(B
$B$H$7$F9T$&(B. $BBN(B $K$ $B>e$N0lJQ?tB?9`<0$N=|;;$O<!$N%"%k%4%j%:%`$G7W;;$G$-$k(B. 

\begin{al}
\begin{tabbing}
\\
Input : $f, g \in K[x]$, $g\neq 0$\\
Output : $f = qg+r$, $q,r \in K[x]$, $\deg(r) < \deg(g)$ $B$J$k(B $q,r$\\
$q\leftarrow 0$, \quad $r\leftarrow f$\\
while \= ( $\deg(r)\ge \deg(g)$ ) \{\\
\> $t \leftarrow \lc(r)/\lc(g)\cdot x^{\deg(r)-\deg(g)}$\\
\> $r \leftarrow r-tg$,\quad $q \leftarrow q+t$\\
\}\\
return $(q,r)$
\end{tabbing}
\end{al}

\section{Karatsuba $B%"%k%4%j%:%`(B}
\label{kara}

$B$3$3$G$O(B, 1 $BJQ?tB?9`<0$N9bB.>h;;K!$*$h$S$=$N1~MQ$K$D$$$F=R$Y$k(B. $B4{$K=R(B
$B$Y$?J}K!$G$O(B, 2 $B$D$N(B $n$ $B<!$NL)$JB?9`<0$N@Q7W;;$O(B $O(n^2)$ $B$N7W;;NL(B
$B$,I,MW$G$"$k(B. 
$B$3$l$KBP$7(B, Karatsuba $B%"%k%4%j%:%`$O(B $O(n^{\log_23}) \simeq
O(n^{1.58})$ $B$N7W;;NL$G@Q$r7W;;$9$k(B. $B$5$i$K7W;;NL$N>.$5$$(B FFT $B%"%k%4%j%:%`(B
$B$K$D$$$F$O(B \cite[Section 4.3]{KNUTH} $B$K>\$7$$2r@b$,$"$k(B. 

$B$^$:(B, 1 $B<!<0(B $f=ax+b$, $g=cx+d$ $B$N@Q$O(B, $B78?t4D$K$*$1$k@Q(B 3 $B2s$G<B9T$G$-$k$3$H(B
$B$KCm0U$9$k(B. $B$9$J$o$A(B, 
$$fg=(ax+b)(cx+d)=acx^2+((a-b)(d-c)+ac+bd)x+bd$$
$B$G(B, $B$3$3$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((M+8A)3^m-8A\cdot 2^m)$$
$B$G(B, $B1&JU$N(B $m=0,\cdots,6$ $B$KBP$9$kCM$O<!$N$h$&$K$J$k(B. 

\begin{center}
\begin{tabular}{|c||c|c|c|c|c|c|c|} \hline
$m$ & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\ \hline
$B1&JU(B & 0 & M-7A & 7M-31A & 37M-103A & 175M-195A & 781M-727A & 3367M-1351A \\ \hline
\end{tabular} 
\end{center}

$B0lHL$K(B, $M>A$ $B$@$+$i(B $m \ge 5$ $B$9$J$o$A(B 31 $B<!<00J>e$N@Q$KBP$7$F$O(B, Karatsuba
$BK!$O>o$K9bB.$G$"$j(B, $M$ $B$,(B $A$ $B$KHf$Y$FBg$-$$>l9g$[$I(B, $BDc$$<!?t$+$i(B Karatsuba
$BK!$,8z2LE*$G$"$k$3$H$,J,$+$k(B. $B99$K(B, $B7W;;NL$N%*!<%@$N0c$$(B 
($O(n^2)$ $B$H(B  $O(n^{\log_23})$) $B$K$h$j(B, $B9b<!Dx(B Karatsuba $BK!$,9bB.$K$J$j(B, 
$BNc$($P(B $M/A=5$ $B$N;~(B, $2^m-1$ $B<!<0$N@Q$NDL>oK!$H(B Karatsuba $BK!$N7W;;%3%9%H$N(B
$BHf$O<!$N$h$&$K$J$k(B. 

\begin{center}
\begin{tabular}{|c||c|c|c|c|c|c|c|c|c|c|c|} \hline
$m$ & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\ \hline
$B7W;;%3%9%HHf(B & 1 & 1.1 & 0.96 & 0.78 & 0.61 & 0.48 & 0.37 & 0.28 & 0.21 & 0.16 & 0.12 \\ \hline
\end{tabular} 
\end{center}

$B$9$J$o$A(B, 100 $B<!$G(B 1.5 $BG\(B, 1000 $B<!<0$G(B 8 $BG\DxEY$N:9$,$D$/$3$H$K$J$k(B. 
Karatsuba $BK!$K$*$1$k(B, $BB?9`<0$NJ,3d(B, $B4X?t8F$S=P$7$N<j4V$J$I$,(B
$B$+$+$k$?$a(B, $B<B:]$K$O$3$N?t;z$rC#@.$9$k$3$H$OFq$7$$$,(B, $BB?9`<0$N@Q$K(B
$B4X$7$F$O(B, Karatsuba $BK!$O==J,<BMQE*$G$"$k$H8@$($k(B. 

\section{$B=|;;$r>h;;$G9T$&$K$O(B?}
$B4{$K=R$Y$?B?9`<0=|;;$O(B, $B<!?t(B $n$ $B$K$D$$$F(B $O(n^2)$ $B$N7W;;NL$rI,MW$H$9$k(B. 
$B$3$l$r(B, $B$h$j>/$J$$<j4V$G7W;;$9$k$?$a$K(B, $B>h;;$rMQ$$$F=|;;$r9T$&$3$H$r(B
$B9M$($k(B. 

\begin{pr}
$f = \sum_{i=0}^n a_ix^i$ $B$r(B, $a_0\neq 0$ $B$J$kB?9`<0$H$9$k(B. 
$g_0 = 1/{a_0}, \quad g_i = 2g_{i-1}-g_{i-1}^2f \bmod x^{2^i}$
$B$H$9$l$P(B, $g_if \equiv 1 \bmod x^{2^i}.$
\end{pr}

\begin{df}
$n$ $B<!B?9`<0(B $f$ $B$KBP$7(B, $f^{*} = x^nf(1/x)$ $B$HDj5A$9$k(B. 
\end{df}

\begin{pr}
$f$, $g$ $B$r3F!9(B $n$, $m$ $B<!(B ($n\ge m$) $BB?9`<0$H$7(B, 
$f=gq+r \quad (\deg(r)<m)$
$B$H$9$k(B. $B$3$N;~(B $tg^{*}\equiv 1 \bmod x^{n-m+1}$ $B$J$k(B $t$ $B$K$h$j(B
$q = (tf^{*} \bmod x^{n-m+1})^{*}.$
\end{pr}
\proof
$f=gq+r$ $B$h$j(B 
$x^nf(1/x)=x^mg(1/x)x^{n-m}q(1/x)+x^nr(1/x).$
$B$9$J$o$A(B 
$f^{*}=g^{*}q^{*}+x^{n-\deg(r)}r^{*}.$
$B$3$3$G(B, $\deg(r)<m$ $B$h$j(B $n-\deg(r)\le n-m+1.$ $B$h$C$F(B
$f^{*}\equiv g^{*}q^{*} \bmod x^{n-m+1}.$
$B$h$C$F(B $tf^{*}\equiv q^{*} \bmod x^{n-m+1}$ $B$H$J$k$,(B, 
$\deg(q)=n-m$ $B$h$j(B
$q = (tf^{*} \bmod x^{n-m+1})^{*}.$
\qed\\
$r=f-gq$ $B$h$j(B, $q$, $r$ $B$,2?2s$+$N>h;;$G7W;;$G$-$k$3$H$,$o$+$k(B.

\begin{itemize}
\item $t$ $B$r5a$a$k:]$KI,MW$J>h;;$N2s?t$O(B $\log_2{(n-m)}$ $BDxEY(B,
\item $t$ $B$,5a$^$C$F$$$l$P(B, $q$, $r$ $B$N7W;;$K$O>h;;(B 2 $B2s$G:Q$`(B. 
\item $B>h;;$K(B Karatsuba $BK!(B ($B$"$k$$$O(B FFT $BK!(B) $B$rMQ$$$k$3$H$K$h$j(B $O(n^2)$ $B$h$j(B
$B??$K>/$J$$<j4V$G=|;;$,7W;;$G$-$k(B. 
\item $g$ $B$rK!$H$9$k1i;;$N$h$&$K(B, $g$ $B$,8GDj$N>l9g(B, $t$ $B$r(B 1 $B2s7W;;$7$F(B
$B$*$1$P$h$$$+$i(B, $n$, $m$ $B$,Bg$-$$;~$K$OM-8z(B. (50 $B<!DxEY$+$i8z$$$F$/$k(B.)
\end{itemize}


