Prime Numbers

Prime Numbers Prime Numbers

thales.doa.fmph.uniba.sk
from thales.doa.fmph.uniba.sk More from this publisher
10.12.2012 Views

9.6 Polynomial arithmetic 511 Incidentally, if polynomial multiplication in rings is done via fast integer convolution (recall that acyclic convolution is sufficient, and so zero-padded cyclic will do), then one may obtain a different expression for the complexity bound. For the Nussbaumer Algorithm 9.5.25 one requires O(M(ln m)D ln D) bit operations, where M is the usual integer-multiplication complexity. It is interesting to compare these various estimates for polynomial multiplication (see Exercise 9.70). 9.6.2 Fast polynomial inversion and remaindering Let x(t) = D−1 j=0 xjt j be a polynomial. If x0 = 0,thereisaformalinversion 1/x(t) =1/x0 − (x1/x 2 0)t +(x 2 1/x 3 0 − x2/x 2 0)t 2 + ··· that admits of rapid evaluation, by way of a scheme we have already invoked for reciprocation, the celebrated Newton method. We describe the scheme in the case that x0 = 1, from which case generalizations are easily inferred. In what follows, the notation z(t) modt k is a polynomial remainder (which we cover later), but in this setting it is simple truncation: The result of the mod operation is a polynomial consisting of the terms of polynomial z(t) through order t k−1 inclusive. Let us define, then, a truncated reciprocal, R[x, N] =x(t) −1 mod t N+1 as the series of 1/x(t) through degree t N ,inclusive. Algorithm 9.6.2 (Fast polynomial inversion). Let x(t) be a polynomial with first coefficient x0 = 1. This algorithm returns the truncated reciprocal R[x, N] through a desired degree N. 1. [Initialize] g(t) =1; // Degree-zero polynomial. n =1; // Working degree precision. 2. [Newton loop] while(n N+1) n = N +1; h(t) =x(t) modt n ; // Simple truncation. h(t) =h(t)g(t) modt n ; g(t) =g(t)(2 − h(t)) mod t n ; // Newton iteration. } return g(t); One point that should be stressed right off is that in principle, an operation f(t)g(t) modt n is simple truncation of a product (the operands usually themselves being approximately of degree n). This means that within

512 Chapter 9 FAST ALGORITHMS FOR LARGE-INTEGER ARITHMETIC multiplication loops, one need not handle terms of degree higher than indicated. In convolution-theory language, we are therefore doing “half-cyclic” convolutions, so when transform methods are used, there is also gain to be realized because of the truncation. As is typical of Newton methods, the dynamical precision degree n essentially doubles on each pass of the Newton loop. Let us give an example of the workings of the algorithm. Take x(t) =1+t + t 2 +4t 3 and call the algorithm to output R[x, 8]. Then the values of g(t) attheendof each pass of the Newton loop come out as 1 − t, 1 − t − 3t 3 , 1 − t − 3t 3 +7t 4 − 4t 5 +9t 6 − 33t 7 , 1 − t − 3t 3 +7t 4 − 4t 5 +9t 6 − 33t 7 +40t 8 , and indeed, this last output of g(t) multiplied by the original x(t) is 1+43t 9 − 92t 10 + 160t 11 , showing that the last output g(t) is correct through O(t 8 ). Polynomial remaindering (polynomial mod operation) can be performed in much the same way as some of our mod algorithms for integers used a “reciprocal.” However, it is not always possible to divide one polynomial by another and get a unique and legitimate remainder: This can depend on the ring of coefficients for the polynomials. However, if the divisor polynomial has its high coefficient invertible in the ring, then there is no problem with divide and remainder; see the discussion in Section 2.2.1. For simplicity, we shall restrict to the case that the divisor polynomial is monic, that is, the high coefficient is 1, since generalizing is straightforward. Assume that x(t),y(t) are polynomials and that y(t) is monic. Then there are unique polynomials q(t),r(t) such that x(t) =q(t)y(t)+r(t), and r =0ordeg(r) < deg(x). We shall write r(t) =x(t) mody(t), and view q(t) asthequotientandr(t) as the remainder. Incidentally, for some polynomial operations one demands that coefficients lie in a field, for example in the evaluation of polynomial gcd’s, but many polynomial operations do not require field coefficients. Before exhibiting a fast polynomial remaindering algorithm, we establish some nomenclature: Definition 9.6.3 (Polynomial operations). Let x(t) = D−1 j=0 xjt j be a polynomial. We define the reversal of x by degree d as the polynomial rev(x, d) = d j=0 xd−jt j ,

512 Chapter 9 FAST ALGORITHMS FOR LARGE-INTEGER ARITHMETIC<br />

multiplication loops, one need not handle terms of degree higher than<br />

indicated. In convolution-theory language, we are therefore doing “half-cyclic”<br />

convolutions, so when transform methods are used, there is also gain to be<br />

realized because of the truncation.<br />

As is typical of Newton methods, the dynamical precision degree n<br />

essentially doubles on each pass of the Newton loop. Let us give an example<br />

of the workings of the algorithm. Take<br />

x(t) =1+t + t 2 +4t 3<br />

and call the algorithm to output R[x, 8]. Then the values of g(t) attheendof<br />

each pass of the Newton loop come out as<br />

1 − t,<br />

1 − t − 3t 3 ,<br />

1 − t − 3t 3 +7t 4 − 4t 5 +9t 6 − 33t 7 ,<br />

1 − t − 3t 3 +7t 4 − 4t 5 +9t 6 − 33t 7 +40t 8 ,<br />

and indeed, this last output of g(t) multiplied by the original x(t) is<br />

1+43t 9 − 92t 10 + 160t 11 , showing that the last output g(t) is correct through<br />

O(t 8 ).<br />

Polynomial remaindering (polynomial mod operation) can be performed<br />

in much the same way as some of our mod algorithms for integers used a<br />

“reciprocal.” However, it is not always possible to divide one polynomial by<br />

another and get a unique and legitimate remainder: This can depend on the<br />

ring of coefficients for the polynomials. However, if the divisor polynomial has<br />

its high coefficient invertible in the ring, then there is no problem with divide<br />

and remainder; see the discussion in Section 2.2.1. For simplicity, we shall<br />

restrict to the case that the divisor polynomial is monic, that is, the high<br />

coefficient is 1, since generalizing is straightforward. Assume that x(t),y(t)<br />

are polynomials and that y(t) is monic. Then there are unique polynomials<br />

q(t),r(t) such that<br />

x(t) =q(t)y(t)+r(t),<br />

and r =0ordeg(r) < deg(x). We shall write<br />

r(t) =x(t) mody(t),<br />

and view q(t) asthequotientandr(t) as the remainder. Incidentally, for some<br />

polynomial operations one demands that coefficients lie in a field, for example<br />

in the evaluation of polynomial gcd’s, but many polynomial operations do not<br />

require field coefficients. Before exhibiting a fast polynomial remaindering<br />

algorithm, we establish some nomenclature:<br />

Definition 9.6.3 (Polynomial operations). Let x(t) = D−1<br />

j=0 xjt j be a<br />

polynomial. We define the reversal of x by degree d as the polynomial<br />

rev(x, d) =<br />

d<br />

j=0<br />

xd−jt j ,

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!